fixed Flake8 issues

This commit is contained in:
k4yt3x 2022-04-06 03:39:32 +00:00
parent e0dc8237f5
commit 865e3bd193
5 changed files with 30 additions and 32 deletions

View File

@ -156,18 +156,18 @@ class VideoDecoder(threading.Thread):
frame_index += 1 frame_index += 1
# most likely "not enough image data" # most likely "not enough image data"
except ValueError as e: except ValueError as error:
self.exception = e self.exception = error
# ignore queue closed # ignore queue closed
if "is closed" not in str(e): if "is closed" not in str(error):
logger.exception(e) logger.exception(error)
break break
# send exceptions into the client connection pipe # send exceptions into the client connection pipe
except Exception as e: except Exception as error:
self.exception = e self.exception = error
logger.exception(e) logger.exception(error)
break break
else: else:
logger.debug("Decoding queue depleted") logger.debug("Decoding queue depleted")

View File

@ -165,9 +165,9 @@ class VideoEncoder(threading.Thread):
frame_index += 1 frame_index += 1
# send exceptions into the client connection pipe # send exceptions into the client connection pipe
except Exception as e: except Exception as error:
self.exception = e self.exception = error
logger.exception(e) logger.exception(error)
break break
else: else:
logger.debug("Encoding queue depleted") logger.debug("Encoding queue depleted")

View File

@ -112,8 +112,8 @@ class Interpolator(multiprocessing.Process):
except (SystemExit, KeyboardInterrupt): except (SystemExit, KeyboardInterrupt):
break break
except Exception as e: except Exception as error:
logger.exception(e) logger.exception(error)
break break
logger.opt(colors=True).info( logger.opt(colors=True).info(

View File

@ -194,8 +194,8 @@ class Upscaler(multiprocessing.Process):
except (SystemExit, KeyboardInterrupt): except (SystemExit, KeyboardInterrupt):
break break
except Exception as e: except Exception as error:
logger.exception(e) logger.exception(error)
break break
logger.opt(colors=True).info( logger.opt(colors=True).info(

View File

@ -27,7 +27,7 @@ __ __ _ _ ___ __ __
Name: Video2X Name: Video2X
Creator: K4YT3X Creator: K4YT3X
Date Created: February 24, 2018 Date Created: February 24, 2018
Last Modified: March 21, 2022 Last Modified: April 5, 2022
Editor: BrianPetkovsek Editor: BrianPetkovsek
Last Modified: June 17, 2019 Last Modified: June 17, 2019
@ -49,10 +49,10 @@ import signal
import sys import sys
import time import time
import cv2
import ffmpeg import ffmpeg
from cv2 import cv2
from loguru import logger from loguru import logger
from rich import print from rich import print as rich_print
from rich.console import Console from rich.console import Console
from rich.file_proxy import FileProxy from rich.file_proxy import FileProxy
from rich.progress import ( from rich.progress import (
@ -80,13 +80,11 @@ except ImportError:
else: else:
ENABLE_HOTKEY = True ENABLE_HOTKEY = True
LEGAL_INFO = """Video2X\t\t{} LEGAL_INFO = f"""Video2X\t\t{__version__}
Author:\t\tK4YT3X Author:\t\tK4YT3X
License:\tGNU AGPL v3 License:\tGNU AGPL v3
Github Page:\thttps://github.com/k4yt3x/video2x Github Page:\thttps://github.com/k4yt3x/video2x
Contact:\ti@k4yt3x.com""".format( Contact:\ti@k4yt3x.com"""
__version__
)
# algorithms available for upscaling tasks # algorithms available for upscaling tasks
UPSCALING_ALGORITHMS = [ UPSCALING_ALGORITHMS = [
@ -133,7 +131,8 @@ class Video2X:
def __init__(self) -> None: def __init__(self) -> None:
self.version = __version__ self.version = __version__
def _get_video_info(self, path: pathlib.Path) -> tuple: @staticmethod
def _get_video_info(path: pathlib.Path) -> tuple:
""" """
get video file information with FFmpeg get video file information with FFmpeg
@ -329,17 +328,16 @@ class Video2X:
logger.info("Processing has completed") logger.info("Processing has completed")
# if SIGTERM is received or ^C is pressed # if SIGTERM is received or ^C is pressed
# TODO: pause and continue here except (SystemExit, KeyboardInterrupt) as error:
except (SystemExit, KeyboardInterrupt) as e:
self.progress.stop() self.progress.stop()
logger.warning("Exit signal received, exiting gracefully") logger.warning("Exit signal received, exiting gracefully")
logger.warning("Press ^C again to force terminate") logger.warning("Press ^C again to force terminate")
exception.append(e) exception.append(error)
except Exception as e: except Exception as error:
self.progress.stop() self.progress.stop()
logger.exception(e) logger.exception(error)
exception.append(e) exception.append(error)
finally: finally:
@ -575,7 +573,7 @@ def main() -> int:
try: try:
# display version and lawful informaition # display version and lawful informaition
if "--version" in sys.argv: if "--version" in sys.argv:
print(LEGAL_INFO) rich_print(LEGAL_INFO)
return 0 return 0
# parse command line arguments # parse command line arguments
@ -585,7 +583,7 @@ def main() -> int:
if not args.input.exists(): if not args.input.exists():
logger.critical(f"Cannot find input file: {args.input}") logger.critical(f"Cannot find input file: {args.input}")
return 1 return 1
elif not args.input.is_file(): if not args.input.is_file():
logger.critical("Input path is not a file") logger.critical("Input path is not a file")
return 1 return 1
@ -633,8 +631,8 @@ def main() -> int:
except KeyboardInterrupt: except KeyboardInterrupt:
return 2 return 2
except Exception as e: except Exception as error:
logger.exception(e) logger.exception(error)
return 1 return 1
# if no exceptions were produced # if no exceptions were produced