|
9 | 9 |
|
10 | 10 | from manimlib.utils.config_ops import merge_dicts_recursively |
11 | 11 | from manimlib.utils.init_config import init_customization |
| 12 | +from manimlib.logger import log |
12 | 13 |
|
13 | 14 |
|
14 | 15 | def parse_cli(): |
@@ -136,10 +137,15 @@ def parse_cli(): |
136 | 137 | "--config_file", |
137 | 138 | help="Path to the custom configuration file", |
138 | 139 | ) |
| 140 | + parser.add_argument( |
| 141 | + "-v", "--version", |
| 142 | + action="store_true", |
| 143 | + help="Display the version of manimgl" |
| 144 | + ) |
139 | 145 | args = parser.parse_args() |
140 | 146 | return args |
141 | 147 | except argparse.ArgumentError as err: |
142 | | - print(str(err)) |
| 148 | + log.error(str(err)) |
143 | 149 | sys.exit(2) |
144 | 150 |
|
145 | 151 |
|
@@ -185,36 +191,45 @@ def get_custom_config(): |
185 | 191 | return config |
186 | 192 |
|
187 | 193 |
|
| 194 | +def check_temporary_storage(config): |
| 195 | + if config["directories"]["temporary_storage"] == "" and sys.platform == "win32": |
| 196 | + log.warning("You may be using Windows platform and have not specified the `temporary\ |
| 197 | +_storage` path, which may cause OSError. So it is recommended that you specify the `temporary\ |
| 198 | +_storage` in the config file (.yml)") |
| 199 | + |
| 200 | + |
188 | 201 | def get_configuration(args): |
189 | 202 | global __config_file__ |
190 | 203 |
|
191 | 204 | # ensure __config_file__ always exists |
192 | 205 | if args.config_file is not None: |
193 | 206 | if not os.path.exists(args.config_file): |
194 | | - print(f"Can't find {args.config_file}.") |
| 207 | + log.error(f"Can't find {args.config_file}.") |
195 | 208 | if sys.platform == 'win32': |
196 | | - print(f"Copying default configuration file to {args.config_file}...") |
| 209 | + log.info(f"Copying default configuration file to {args.config_file}...") |
197 | 210 | os.system(f"copy default_config.yml {args.config_file}") |
198 | 211 | elif sys.platform in ["linux2", "darwin"]: |
199 | | - print(f"Copying default configuration file to {args.config_file}...") |
| 212 | + log.info(f"Copying default configuration file to {args.config_file}...") |
200 | 213 | os.system(f"cp default_config.yml {args.config_file}") |
201 | 214 | else: |
202 | | - print("Please create the configuration file manually.") |
203 | | - print("Read configuration from default_config.yml.") |
| 215 | + log.info("Please create the configuration file manually.") |
| 216 | + log.info("Read configuration from default_config.yml.") |
204 | 217 | else: |
205 | 218 | __config_file__ = args.config_file |
206 | 219 |
|
207 | 220 | global_defaults_file = os.path.join(get_manim_dir(), "manimlib", "default_config.yml") |
208 | 221 |
|
209 | 222 | if not (os.path.exists(global_defaults_file) or os.path.exists(__config_file__)): |
210 | | - print("There is no configuration file detected. Initial configuration:\n") |
| 223 | + log.info("There is no configuration file detected. Initial configuration:\n") |
211 | 224 | init_customization() |
212 | 225 |
|
213 | 226 | elif not os.path.exists(__config_file__): |
214 | | - print(f"Warning: Using the default configuration file, which you can modify in {global_defaults_file}") |
215 | | - print(f"If you want to create a local configuration file, you can create a file named {__config_file__}, or run manimgl --config") |
| 227 | + log.info(f"Using the default configuration file, which you can modify in `{global_defaults_file}`") |
| 228 | + log.info(f"If you want to create a local configuration file, you can create a file named \ |
| 229 | +`{__config_file__}`, or run `manimgl --config`") |
216 | 230 |
|
217 | 231 | custom_config = get_custom_config() |
| 232 | + check_temporary_storage(custom_config) |
218 | 233 |
|
219 | 234 | write_file = any([args.write_file, args.open, args.finder]) |
220 | 235 | if args.transparent: |
@@ -319,9 +334,9 @@ def get_camera_configuration(args, custom_config): |
319 | 334 | try: |
320 | 335 | bg_color = args.color or custom_config["style"]["background_color"] |
321 | 336 | camera_config["background_color"] = colour.Color(bg_color) |
322 | | - except AttributeError as err: |
323 | | - print("Please use a valid color") |
324 | | - print(err) |
| 337 | + except ValueError as err: |
| 338 | + log.error("Please use a valid color") |
| 339 | + log.error(err) |
325 | 340 | sys.exit(2) |
326 | 341 |
|
327 | 342 | # If rendering a transparent image/move, make sure the |
|
0 commit comments