瀏覽代碼

fix lgtm alerts

Nick Sweeting 4 年之前
父節點
當前提交
2c07d8f1f3
共有 2 個文件被更改,包括 3 次插入5 次删除
  1. 2 3
      archivebox/config.py
  2. 1 2
      archivebox/logging_util.py

+ 2 - 3
archivebox/config.py

@@ -502,7 +502,7 @@ def write_config_file(config: Dict[str, str], out_dir: str=None) -> ConfigDict:
             key.upper(): CONFIG.get(key.upper())
             key.upper(): CONFIG.get(key.upper())
             for key in config.keys()
             for key in config.keys()
         }
         }
-    except:
+    except BaseException:
         # something went horribly wrong, rever to the previous version
         # something went horribly wrong, rever to the previous version
         with open(f'{config_path}.bak', 'r', encoding='utf-8') as old:
         with open(f'{config_path}.bak', 'r', encoding='utf-8') as old:
             atomic_write(config_path, old.read())
             atomic_write(config_path, old.read())
@@ -547,7 +547,7 @@ def load_config(defaults: ConfigDefaultDict,
             stderr('    For config documentation and examples see:')
             stderr('    For config documentation and examples see:')
             stderr('        https://github.com/ArchiveBox/ArchiveBox/wiki/Configuration')
             stderr('        https://github.com/ArchiveBox/ArchiveBox/wiki/Configuration')
             stderr()
             stderr()
-            raise
+            # raise
             raise SystemExit(2)
             raise SystemExit(2)
     
     
     return extended_config
     return extended_config
@@ -1067,7 +1067,6 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG,
     assert isinstance(output_dir, Path) and isinstance(config['PACKAGE_DIR'], Path)
     assert isinstance(output_dir, Path) and isinstance(config['PACKAGE_DIR'], Path)
 
 
     try:
     try:
-        import django
         from django.core.management import call_command
         from django.core.management import call_command
 
 
         sys.path.append(str(config['PACKAGE_DIR']))
         sys.path.append(str(config['PACKAGE_DIR']))

+ 1 - 2
archivebox/logging_util.py

@@ -157,7 +157,7 @@ class TimedProgress:
                 # kill the progress bar subprocess
                 # kill the progress bar subprocess
                 try:
                 try:
                     self.p.close()   # must be closed *before* its terminnated
                     self.p.close()   # must be closed *before* its terminnated
-                except:
+                except BaseException:
                     pass
                     pass
                 self.p.terminate()
                 self.p.terminate()
                 self.p.join()
                 self.p.join()
@@ -223,7 +223,6 @@ def progress_bar(seconds: int, prefix: str='') -> None:
         # sys.stdout.flush()
         # sys.stdout.flush()
     except (KeyboardInterrupt, BrokenPipeError):
     except (KeyboardInterrupt, BrokenPipeError):
         print()
         print()
-        pass
 
 
 
 
 def log_cli_command(subcommand: str, subcommand_args: List[str], stdin: Optional[str], pwd: str):
 def log_cli_command(subcommand: str, subcommand_args: List[str], stdin: Optional[str], pwd: str):