From e082133f00b577448058bbc21c4ab15c18f6bb2c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 24 Sep 2020 14:14:15 +0000 Subject: [PATCH] Restyled by black --- guiscrcpy/lib/toolkit.py | 85 +++++++++++++++++++--------------------- guiscrcpy/ux/toolkit.py | 36 ++++++++++------- guiscrcpy/version.py | 2 +- setup.py | 54 ++++++++++++------------- 4 files changed, 88 insertions(+), 89 deletions(-) diff --git a/guiscrcpy/lib/toolkit.py b/guiscrcpy/lib/toolkit.py index 91dd6ccf..7ba1b67b 100644 --- a/guiscrcpy/lib/toolkit.py +++ b/guiscrcpy/lib/toolkit.py @@ -30,8 +30,7 @@ import pyautogui as auto from pygetwindow import getWindowsWithTitle except ModuleNotFoundError as e: - logging.debug("pygetwindow, pyautogui " - "failed with error code {}".format(e)) + logging.debug("pygetwindow, pyautogui " "failed with error code {}".format(e)) auto = None getWindowsWithTitle = None else: @@ -45,28 +44,29 @@ def wmctrl_xdotool_linux_send_key(key): wmctrl = shutil.which("wmctrl") xdotool = shutil.which("xdotool") if not wmctrl or not xdotool: - print('E: Could not find {} on PATH. Make sure ' - 'that a compatible package is installed ' - 'on your system for this function') + print( + "E: Could not find {} on PATH. Make sure " + "that a compatible package is installed " + "on your system for this function" + ) return - _proc = subprocess.Popen(shlex.split( - 'wmctrl -x -a scrcpy'), - stdout=sys.stdout, - stderr=sys.stderr) + _proc = subprocess.Popen( + shlex.split("wmctrl -x -a scrcpy"), stdout=sys.stdout, stderr=sys.stderr + ) if _proc.wait() == 0: - _xdotool_proc = subprocess.Popen(shlex.split( - 'xdotool key --clearmodifiers {}+{}'.format( - os.getenv('GUISCRCPY_MODIFIER') or 'alt', key) - ), + _xdotool_proc = subprocess.Popen( + shlex.split( + "xdotool key --clearmodifiers {}+{}".format( + os.getenv("GUISCRCPY_MODIFIER") or "alt", key + ) + ), stdout=sys.stdout, - stderr=sys.stderr + stderr=sys.stderr, ) if _xdotool_proc.wait() != 0: - print("E (xdotool): Failed to send key {} to " - "scrcpy window.".format(key)) + print("E (xdotool): Failed to send key {} to " "scrcpy window.".format(key)) else: - print("E (wmctrl): Failed to get scrcpy window. " - "(Is scrcpy running?)") + print("E (wmctrl): Failed to get scrcpy window. " "(Is scrcpy running?)") class UXMapper: @@ -82,16 +82,16 @@ def __init__(self, adb, device_id=None, sha_shift=5): logging.debug("Launching UX Mapper") self.has_modules = getWindowsWithTitle and auto logging.debug("Calculating Screen Size") - self.android_dimensions = adb.get_dimensions( - device_id=device_id - ) + self.android_dimensions = adb.get_dimensions(device_id=device_id) if not self.android_dimensions: - print("E: guiscrcpy has crashed because of a failure in the " - "execution of `adb shell wm size`. This might be because " - "of an improper connection of adb. Please reconnect your " - "device (disconnect from WiFi / Reconnect USB) or try \n\n" - "guiscrcpy --killserver\n\nas a command line to restart adb " - "server") + print( + "E: guiscrcpy has crashed because of a failure in the " + "execution of `adb shell wm size`. This might be because " + "of an improper connection of adb. Please reconnect your " + "device (disconnect from WiFi / Reconnect USB) or try \n\n" + "guiscrcpy --killserver\n\nas a command line to restart adb " + "server" + ) self.deviceId = device_id # each device connected is uniquely identified by the tools by @@ -104,7 +104,7 @@ def get_sha(self): A method which returns the unique UUID of the the device :return: The hexdigest of a salted hash """ - return self.__sha[self.sha_shift:self.sha_shift + 6] + return self.__sha[self.sha_shift : self.sha_shift + 6] def do_swipe(self, x1=10, y1=10, x2=10, y2=10): """ @@ -115,8 +115,9 @@ def do_swipe(self, x1=10, y1=10, x2=10, y2=10): :param y2: y2 coordinate :return: Boolean True, in success """ - self.adb.shell_input("swipe {} {} {} {}".format( - x1, y1, x2, y2), device_id=self.deviceId) + self.adb.shell_input( + "swipe {} {} {} {}".format(x1, y1, x2, y2), device_id=self.deviceId + ) return True def do_keyevent(self, key): @@ -125,8 +126,7 @@ def do_keyevent(self, key): :param key: The ADB predefined keycode :return: """ - self.adb.shell_input("keyevent {}".format(key), - device_id=self.deviceId) + self.adb.shell_input("keyevent {}".format(key), device_id=self.deviceId) return True def copy_devpc(self): @@ -135,7 +135,7 @@ def copy_devpc(self): scrcpywindow.focus() auto.hotkey("alt", "c") else: - wmctrl_xdotool_linux_send_key('c') + wmctrl_xdotool_linux_send_key("c") def key_power(self): logging.debug("Passing POWER") @@ -167,20 +167,17 @@ def key_switch(self): def reorient_portrait(self): logging.debug("Passing REORIENT [POTRAIT]") - self.adb.shell('settings put system accelerometer_rotation 0', - device_id=self.deviceId) - self.adb.shell("settings put system rotation 1", - device_id=self.deviceId) + self.adb.shell( + "settings put system accelerometer_rotation 0", device_id=self.deviceId + ) + self.adb.shell("settings put system rotation 1", device_id=self.deviceId) def reorient_landscape(self): logging.debug("Passing REORIENT [LANDSCAPE]") self.adb.shell( - 'settings put system accelerometer_rotation 0', - device_id=self.deviceId + "settings put system accelerometer_rotation 0", device_id=self.deviceId ) - self.adb.shell( - "settings put system rotation 1", - device_id=self.deviceId) + self.adb.shell("settings put system rotation 1", device_id=self.deviceId) def expand_notifications(self): logging.debug("Passing NOTIF EXPAND") @@ -196,7 +193,7 @@ def copy_pc2dev(self): scrcpywindow.focus() auto.hotkey("alt", "shift", "c") else: - wmctrl_xdotool_linux_send_key('shift+c') + wmctrl_xdotool_linux_send_key("shift+c") def fullscreen(self): if self.has_modules: @@ -204,4 +201,4 @@ def fullscreen(self): scrcpy_window.focus() auto.hotkey("alt", "f") else: - wmctrl_xdotool_linux_send_key('f') + wmctrl_xdotool_linux_send_key("f") diff --git a/guiscrcpy/ux/toolkit.py b/guiscrcpy/ux/toolkit.py index b372575b..acab9598 100644 --- a/guiscrcpy/ux/toolkit.py +++ b/guiscrcpy/ux/toolkit.py @@ -30,8 +30,7 @@ class InterfaceToolkit(QMainWindow, Ui_ToolbarPanel): - def __init__(self, ux_mapper=None, parent=None, frame=False, - always_on_top=True): + def __init__(self, ux_mapper=None, parent=None, frame=False, always_on_top=True): """ Side panel toolkit for guiscrcpy main window :param ux_mapper: @@ -60,24 +59,27 @@ def __init__(self, ux_mapper=None, parent=None, frame=False, def init(self): if platform.system() != "Linux" or ( - shutil.which('wmctrl') and - shutil.which('xdotool') and - platform.system() == "Linux"): + shutil.which("wmctrl") + and shutil.which("xdotool") + and platform.system() == "Linux" + ): self.clipD2PC.clicked.connect(self.ux.copy_devpc) self.clipPC2D.clicked.connect(self.ux.copy_pc2dev) self.fullscreenUI.clicked.connect(self.ux.fullscreen) else: # the tools do not exist on Linux. user has to manually install for button, helper in ( - (self.clipD2PC, 'Alt + C'), - (self.clipPC2D, 'Alt + Shift + C'), - (self.fullscreenUI, 'Alt + F')): + (self.clipD2PC, "Alt + C"), + (self.clipPC2D, "Alt + Shift + C"), + (self.fullscreenUI, "Alt + F"), + ): button.setDisabled(True) button.setToolTip( 'This function is disabled because "wmctrl"' ' or "xdotool" is not found on your installation.' - 'Keyboard shortcut can be used instead' - ': {}'.format(helper)) + "Keyboard shortcut can be used instead" + ": {}".format(helper) + ) self.back.clicked.connect(self.ux.key_back) self.screenfreeze.clicked.connect(self.quit_window) @@ -117,14 +119,18 @@ def quit_window(self): # This method checks if we are the last member of the windows # spawned and we ourselves are not a member of ourself by # checking the uuid generated on creation - if not instance.isHidden() \ - and instance.name != "swipe" and instance.uid != \ - self.uid: + if ( + not instance.isHidden() + and instance.name != "swipe" + and instance.uid != self.uid + ): self.hide() break else: for instance in self.parent.child_windows: # noqa - if instance.name == 'swipe' and instance.ux.get_sha() == \ - self.ux.get_sha(): + if ( + instance.name == "swipe" + and instance.ux.get_sha() == self.ux.get_sha() + ): instance.hide() self.hide() diff --git a/guiscrcpy/version.py b/guiscrcpy/version.py index b78015bf..7a6349b9 100644 --- a/guiscrcpy/version.py +++ b/guiscrcpy/version.py @@ -20,4 +20,4 @@ """ -VERSION = 'v4.7.2.post3.dev' +VERSION = "v4.7.2.post3.dev" diff --git a/setup.py b/setup.py index 848f268f..d5dd2c25 100755 --- a/setup.py +++ b/setup.py @@ -27,52 +27,48 @@ try: this_directory = os.path.abspath(os.path.dirname(__file__)) - with open( - os.path.join(this_directory, 'README.md'), - encoding='utf-8' - ) as f: + with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f: long_description = f.read() except FileNotFoundError: - long_description = \ - "Open Source Android Screen Mirroring System by @srevinsaju" + long_description = "Open Source Android Screen Mirroring System by @srevinsaju" -requirements = ['PyQt5>=5.14,<5.16', 'pynput', 'qtpy', 'click', 'colorama'] -if platform.system() == 'Windows': - requirements.extend(['pywin32', 'psutil']) -elif platform.system() == 'Linux': - requirements.extend(['psutil', 'cairosvg']) +requirements = ["PyQt5>=5.14,<5.16", "pynput", "qtpy", "click", "colorama"] +if platform.system() == "Windows": + requirements.extend(["pywin32", "psutil"]) +elif platform.system() == "Linux": + requirements.extend(["psutil", "cairosvg"]) data_files = [ - ('share/applications', ['guiscrcpy.desktop']), - ('share/icons/hicolor/scalable/apps', ['appimage/guiscrcpy.png']), + ("share/applications", ["guiscrcpy.desktop"]), + ("share/icons/hicolor/scalable/apps", ["appimage/guiscrcpy.png"]), ] setup( - name='guiscrcpy', - version='v4.7.2.post3.dev', - description='An Open Source - Fast - Android Screen Mirroring system.', + name="guiscrcpy", + version="v4.7.2.post3.dev", + description="An Open Source - Fast - Android Screen Mirroring system.", long_description=long_description, - long_description_content_type='text/markdown', - license='GPL v3', - author='srevinsaju', + long_description_content_type="text/markdown", + license="GPL v3", + author="srevinsaju", author_email="srevin03@gmail.com", packages=find_packages(), data_files=data_files, - extras_require={'pyqt5': 'PyQt5', 'pyside2': 'PySide2'}, + extras_require={"pyqt5": "PyQt5", "pyside2": "PySide2"}, url="https://srevinsaju.github.io/guiscrcpy", download_url="https://github.com/srevinsaju/guiscrcpy/archive/master.zip", include_package_data=True, install_requires=requirements, scripts=["scripts/guiscrcpy"], - entry_points={'console_scripts': ['guiscrcpy = guiscrcpy.cli:cli']}, # noqa: E501 + entry_points={"console_scripts": ["guiscrcpy = guiscrcpy.cli:cli"]}, # noqa: E501 classifiers=[ - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.8', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)' + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.8", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", ], )