Repository: ManimCommunity/manim

Issue:
Version checker throws an error when manim is run without internet
## Description of bug / unexpected behavior
Title.


## Expected behavior
Version checker should just log that the version can't be checked, and not produce a traceback.


## How to reproduce the issue
<!-- Provide a piece of code illustrating the undesired behavior. -->

<details><summary>Code for reproducing the problem</summary>

```py
Paste your code here.
```

</details>


## Additional media files
<!-- Paste in the files manim produced on rendering the code above. -->

<details><summary>Images/GIFs</summary>

<!-- PASTE MEDIA HERE -->

</details>


## Logs
<details><summary>Terminal output</summary>
<!-- Add "-v DEBUG" when calling manim to generate more detailed logs -->

```
C:\Users\Daryl\manim-dev\manim>manim -p test.py
Manim Community v0.4.0

1: Become
2: BecomePoints
3: BecomePointsScene
4: BecomeStyle
5: BecomeStyle2
6: Image

Choose number corresponding to desired scene/arguments.
(Use comma separated list for multiple entries)
Choice(s):  6
[04/19/21 10:55:41] INFO                                                                        scene_file_writer.py:585
                             File ready at C:\Users\Daryl\manim-dev\manim\media\images\test\Ima
                             ge_ManimCE_v0.4.0.png

                    INFO     Rendered Image                                                                 scene.py:199
                             Played 0 animations
                    INFO     Previewed File at:                                                           file_ops.py:98
                             C:\Users\Daryl\manim-dev\manim\media\images\test\Image_ManimCE_v0.4.0.png
Traceback (most recent call last):
  File "C:\Users\Daryl\AppData\Local\pypoetry\Cache\virtualenvs\manim-WZ_QM4hs-py3.9\Scripts\manim", line 5, in <module>
    main()
  File "C:\Users\Daryl\AppData\Local\pypoetry\Cache\virtualenvs\manim-WZ_QM4hs-py3.9\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Daryl\AppData\Local\pypoetry\Cache\virtualenvs\manim-WZ_QM4hs-py3.9\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\Daryl\AppData\Local\pypoetry\Cache\virtualenvs\manim-WZ_QM4hs-py3.9\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\Daryl\AppData\Local\pypoetry\Cache\virtualenvs\manim-WZ_QM4hs-py3.9\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Daryl\AppData\Local\pypoetry\Cache\virtualenvs\manim-WZ_QM4hs-py3.9\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\Daryl\AppData\Local\pypoetry\Cache\virtualenvs\manim-WZ_QM4hs-py3.9\lib\site-packages\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\Daryl\manim-dev\manim\manim\cli\render\commands.py", line 166, in render
    stable = req_info.json()["info"]["version"]
AttributeError: 'dict' object has no attribute 'json'
```

<!-- Insert screenshots here (only when absolutely necessary, we prefer copy/pasted output!) -->

</details>


## System specifications

<details><summary>System Details</summary>

- OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)):
- RAM:
- Python version (`python/py/python3 --version`):
- Installed modules (provide output from `pip list`):
```
PASTE HERE
```
</details>

<details><summary>LaTeX details</summary>

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:
<!-- output of `tlmgr list --only-installed` for TeX Live or a screenshot of the Packages page for MikTeX -->
</details>

<details><summary>FFMPEG</summary>

Output of `ffmpeg -version`:

```
PASTE HERE
```
</details>

## Additional comments
<!-- Add further context that you think might be relevant for this issue here. -->



Discussion:
Was added in #1237. Pinging @RickyC0626 as the PR author.
Should be simple enough to do. It is as simple as running that line only when the previous one succeeded. https://github.com/ManimCommunity/manim/blob/master/manim/cli/render/commands.py#L166
Marking it as a Good First Issue and it must be fixed ASAP.

Resolving patch:
diff --git a/manim/cli/render/commands.py b/manim/cli/render/commands.py
--- a/manim/cli/render/commands.py
+++ b/manim/cli/render/commands.py
@@ -154,18 +154,8 @@ def __repr__(self):
         try:
             req_info = requests.get(manim_info_url)
             req_info.raise_for_status()
-        except requests.exceptions.HTTPError:
-            logger.debug(f"HTTP Error: {warn_prompt}")
-        except requests.exceptions.ConnectionError:
-            logger.debug(f"Connection Error: {warn_prompt}")
-        except requests.exceptions.Timeout:
-            logger.debug(f"Timed Out: {warn_prompt}")
-        except Exception:
-            logger.debug(f"Something went wrong: {warn_prompt}")
 
-        try:
             stable = req_info.json()["info"]["version"]
-
             if stable != __version__:
                 console.print(
                     f"You are using manim version [red]v{__version__}[/red], but version [green]v{stable}[/green] is available."
@@ -173,8 +163,16 @@ def __repr__(self):
                 console.print(
                     "You should consider upgrading via [yellow]pip install -U manim[/yellow]"
                 )
+        except requests.exceptions.HTTPError:
+            logger.debug(f"HTTP Error: {warn_prompt}")
+        except requests.exceptions.ConnectionError:
+            logger.debug(f"Connection Error: {warn_prompt}")
+        except requests.exceptions.Timeout:
+            logger.debug(f"Timed Out: {warn_prompt}")
         except json.JSONDecodeError:
             logger.debug(warn_prompt)
             logger.debug(f"Error decoding JSON from {manim_info_url}")
+        except Exception:
+            logger.debug(f"Something went wrong: {warn_prompt}")
 
     return args


Test patch: