Skip to content

Commit

Permalink
fixed Flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
k4yt3x committed Apr 6, 2022
1 parent e0dc823 commit 865e3bd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 32 deletions.
14 changes: 7 additions & 7 deletions video2x/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,18 @@ def run(self) -> None:
frame_index += 1

# most likely "not enough image data"
except ValueError as e:
self.exception = e
except ValueError as error:
self.exception = error

# ignore queue closed
if "is closed" not in str(e):
logger.exception(e)
if "is closed" not in str(error):
logger.exception(error)
break

# send exceptions into the client connection pipe
except Exception as e:
self.exception = e
logger.exception(e)
except Exception as error:
self.exception = error
logger.exception(error)
break
else:
logger.debug("Decoding queue depleted")
Expand Down
6 changes: 3 additions & 3 deletions video2x/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ def run(self) -> None:
frame_index += 1

# send exceptions into the client connection pipe
except Exception as e:
self.exception = e
logger.exception(e)
except Exception as error:
self.exception = error
logger.exception(error)
break
else:
logger.debug("Encoding queue depleted")
Expand Down
4 changes: 2 additions & 2 deletions video2x/interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def run(self) -> None:
except (SystemExit, KeyboardInterrupt):
break

except Exception as e:
logger.exception(e)
except Exception as error:
logger.exception(error)
break

logger.opt(colors=True).info(
Expand Down
4 changes: 2 additions & 2 deletions video2x/upscaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ def run(self) -> None:
except (SystemExit, KeyboardInterrupt):
break

except Exception as e:
logger.exception(e)
except Exception as error:
logger.exception(error)
break

logger.opt(colors=True).info(
Expand Down
34 changes: 16 additions & 18 deletions video2x/video2x.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Name: Video2X
Creator: K4YT3X
Date Created: February 24, 2018
Last Modified: March 21, 2022
Last Modified: April 5, 2022
Editor: BrianPetkovsek
Last Modified: June 17, 2019
Expand All @@ -49,10 +49,10 @@
import sys
import time

import cv2
import ffmpeg
from cv2 import cv2
from loguru import logger
from rich import print
from rich import print as rich_print
from rich.console import Console
from rich.file_proxy import FileProxy
from rich.progress import (
Expand Down Expand Up @@ -80,13 +80,11 @@
else:
ENABLE_HOTKEY = True

LEGAL_INFO = """Video2X\t\t{}
LEGAL_INFO = f"""Video2X\t\t{__version__}
Author:\t\tK4YT3X
License:\tGNU AGPL v3
Github Page:\thttps://github.com/k4yt3x/video2x
Contact:\t[email protected]""".format(
__version__
)
Contact:\t[email protected]"""

# algorithms available for upscaling tasks
UPSCALING_ALGORITHMS = [
Expand Down Expand Up @@ -133,7 +131,8 @@ class Video2X:
def __init__(self) -> None:
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
Expand Down Expand Up @@ -329,17 +328,16 @@ def _run(
logger.info("Processing has completed")

# if SIGTERM is received or ^C is pressed
# TODO: pause and continue here
except (SystemExit, KeyboardInterrupt) as e:
except (SystemExit, KeyboardInterrupt) as error:
self.progress.stop()
logger.warning("Exit signal received, exiting gracefully")
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()
logger.exception(e)
exception.append(e)
logger.exception(error)
exception.append(error)

finally:

Expand Down Expand Up @@ -575,7 +573,7 @@ def main() -> int:
try:
# display version and lawful informaition
if "--version" in sys.argv:
print(LEGAL_INFO)
rich_print(LEGAL_INFO)
return 0

# parse command line arguments
Expand All @@ -585,7 +583,7 @@ def main() -> int:
if not args.input.exists():
logger.critical(f"Cannot find input file: {args.input}")
return 1
elif not args.input.is_file():
if not args.input.is_file():
logger.critical("Input path is not a file")
return 1

Expand Down Expand Up @@ -633,8 +631,8 @@ def main() -> int:
except KeyboardInterrupt:
return 2

except Exception as e:
logger.exception(e)
except Exception as error:
logger.exception(error)
return 1

# if no exceptions were produced
Expand Down

0 comments on commit 865e3bd

Please sign in to comment.