From 4dab0ee25041c0ae7f45fb032996eaa56a6e04cd Mon Sep 17 00:00:00 2001 From: Srevin Saju Date: Mon, 20 Apr 2020 23:19:12 +0300 Subject: [PATCH] Refactor entry points --- .circleci/config.yml | 2 +- CODE_OF_CONDUCT.md | 34 ++++++------- LICENSE | 2 +- Pipfile | 2 +- guiscrcpy.desktop | 22 +++++---- guiscrcpy/launcher.py | 58 +++++++++++------------ guiscrcpy/lib/check.py | 17 ++++--- guiscrcpy/lib/config.py | 8 ++-- guiscrcpy/lib/mapper.py | 20 ++++---- guiscrcpy/lib/notify.py | 8 ++-- guiscrcpy/lib/process.py | 6 ++- guiscrcpy/lib/toolkit.py | 28 +++++------ guiscrcpy/lib/utils.py | 19 ++++---- guiscrcpy/platform/darwin.py | 2 +- guiscrcpy/platform/linux.py | 4 +- guiscrcpy/platform/windows.py | 2 +- guiscrcpy/platform/windows_tools/tools.py | 2 +- guiscrcpy/theme/style.py | 2 +- guiscrcpy/ui/downloader.py | 4 +- guiscrcpy/ui/main.py | 4 +- guiscrcpy/ui/network.py | 4 +- guiscrcpy/ui/panel.py | 4 +- guiscrcpy/ui/rsrc_rc.py | 2 +- guiscrcpy/ui/settings.py | 4 +- guiscrcpy/ui/toolkit.py | 4 +- guiscrcpy/ux/network.py | 17 ++++--- guiscrcpy/ux/panel.py | 6 +-- guiscrcpy/ux/settings.py | 4 +- guiscrcpy/ux/swipe.py | 40 ++++++++-------- guiscrcpy/ux/toolkit.py | 4 +- manifest.json | 28 +++++------ releaser | 2 +- scripts/guiscrcpy-mapper | 21 ++++---- setup.py | 14 +++--- 34 files changed, 203 insertions(+), 197 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6587f7ed..cf93c01f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,4 @@ -# Python CircleCI 2.0 configuration file +# Python CircleCI 2.0 configuration filename # # Check https://circleci.com/docs/2.0/language-python/ for more details # diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index a12c4c22..e91b063a 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,15 +1,15 @@ # Contributor Covenant Code of Conduct -## Our Pledge +# Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body +our community a harassment - free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal +level of experience, education, socio - economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. -## Our Standards +# Our Standards Examples of behavior that contributes to creating a positive environment include: @@ -23,15 +23,15 @@ include: Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks +advances +* Trolling, insulting / derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic - address, without explicit permission +address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a - professional setting +professional setting -## Our Responsibilities +# Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in @@ -43,16 +43,16 @@ that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. -## Scope +# Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail +representing a project or community include using an official project e - mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. -## Enforcement +# Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at srevin03@gmail.com. All @@ -65,12 +65,12 @@ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. -## Attribution +# Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html +This Code of Conduct is adapted from the[Contributor Covenant][homepage], version 1.4, +available at https: // www.contributor - covenant.org / version / 1 / 4 / code - of - conduct.html -[homepage]: https://www.contributor-covenant.org +[homepage]: https: // www.contributor - covenant.org For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq +https: // www.contributor - covenant.org / faq diff --git a/LICENSE b/LICENSE index df5c8666..d8c877cc 100755 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ - GNU GENERAL PUBLIC LICENSE (GPL) + GNU GENERAL PUBLIC LICENSE(GPL) Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. diff --git a/Pipfile b/Pipfile index 7f4d059e..d8ab77d0 100644 --- a/Pipfile +++ b/Pipfile @@ -3,7 +3,7 @@ name = "pypi" url = "https://pypi.org/simple" verify_ssl = true -[dev-packages] +[dev - packages] [packages] fonttools = "*" diff --git a/guiscrcpy.desktop b/guiscrcpy.desktop index 7a9c5f41..d78197d4 100644 --- a/guiscrcpy.desktop +++ b/guiscrcpy.desktop @@ -1,10 +1,14 @@ [Desktop Entry] -Name=guiscrcpy -Version=3.5 -Exec=python3 bin/guiscrcpy -Type=Application -Icon=guiscrcpy_logo -Terminal=false -Categories=Application;Development; -Keywords=Python;Screen;Mirroring;Android -StartupWMClass=guiscrcpy +Name = guiscrcpy +Version = 3.5 +Exec = python3 bin / guiscrcpy +Type = Application +Icon = guiscrcpy_logo +Terminal = false +Categories = Application +Development +Keywords = Python +Screen +Mirroring +Android +StartupWMClass = guiscrcpy diff --git a/guiscrcpy/launcher.py b/guiscrcpy/launcher.py index 657adee0..e89e1268 100644 --- a/guiscrcpy/launcher.py +++ b/guiscrcpy/launcher.py @@ -47,8 +47,8 @@ from PyQt5.QtWidgets import QMainWindow, QApplication from PyQt5.QtWidgets import QMessageBox -from guiscrcpy.lib.check import Adb -from guiscrcpy.lib.check import Scrcpy +from guiscrcpy.lib.check import adb +from guiscrcpy.lib.check import scrcpy from guiscrcpy.lib.config import InterfaceConfig from guiscrcpy.lib.process import is_running from guiscrcpy.lib.toolkit import UXMapper @@ -75,16 +75,16 @@ # Add precedence for guiscrcpy to check environment variables # for the paths of `adb` and `scrcpy` over the configuration files. if os.getenv('GUISCRCPY_ADB', None) is None: - Adb.path = config['adb'] + adb.path = config['adb'] else: - Adb.path = os.getenv('GUISCRCPY_ADB') + adb.path = os.getenv('GUISCRCPY_ADB') if os.getenv('GUISCRCPY_SCRCPY', None) is None: - Scrcpy.path = config['scrcpy'] + scrcpy.path = config['scrcpy'] else: - Scrcpy.path = os.getenv('GUISCRCPY_SCRCPY') + scrcpy.path = os.getenv('GUISCRCPY_SCRCPY') -Scrcpy.server_path = config['scrcpy-server'] +scrcpy.server_path = config['scrcpy-server'] # Initialize argument parser parser = argparse.ArgumentParser('guiscrcpy v{}'.format(VERSION)) @@ -93,7 +93,7 @@ parser.add_argument('-s', '--start', action='store_true', help="Start scrcpy first before loading the GUI") parser.add_argument('-o', '--output', action='store_true', - help="Show logging output in stdout and in .log file") + help="Show logging output in stdout and in .log filename") parser.add_argument('-d', '--debug', default=3, help="Set a logging level from 0,1,2,3,4,5") parser.add_argument('-v', '--version', action='store_true', @@ -147,7 +147,7 @@ args += " -t " if config['dispRO']: args += " --turn-screen-off " - Scrcpy.start(Scrcpy.path, args) + scrcpy.start(scrcpy.path, args) logging.debug("Importing modules...") @@ -252,7 +252,7 @@ def settings_mgr(self): def network_mgr(self): from guiscrcpy.ux.network import InterfaceNetwork - self.nm = InterfaceNetwork(Adb.path) + self.nm = InterfaceNetwork(adb.path) self.nm.init() self.nm.show() @@ -340,7 +340,7 @@ def __dial_change_cb(self): pass def __refresh_devices_combo_box_cb(self): - devices_list = Adb.devices(Adb.path) + devices_list = adb.devices(adb.path) if len(devices_list) == 0: self.private_message_box_adb.setText("DEVICE IS NOT CONNECTED") @@ -508,7 +508,7 @@ def start_act(self): f"connected; (color id " f"matches toolkit color)") - Scrcpy.start(Scrcpy.path, arguments_scrcpy) + scrcpy.start(scrcpy.path, arguments_scrcpy) final_time = time.time() eta = final_time - initial_time print("scrcpy launched in {:.2f}s".format(eta)) @@ -548,43 +548,43 @@ def bootstrap0(): app.processEvents() cfedited = False - if (Adb.path is None) or (not os.path.exists(Adb.path)): - Adb.path = openFileNameDialog(None, 'adb') + if (adb.path is None) or (not os.path.exists(adb.path)): + adb.path = openFileNameDialog(None, 'adb') cfedited = True - config['adb'] = Adb.path + config['adb'] = adb.path - if (Scrcpy.path is None) or (not os.path.exists(Scrcpy.path)): - Scrcpy.path = openFileNameDialog(None, 'scrcpy') + if (scrcpy.path is None) or (not os.path.exists(scrcpy.path)): + scrcpy.path = openFileNameDialog(None, 'scrcpy') cfedited = True - config['scrcpy'] = Scrcpy.path + config['scrcpy'] = scrcpy.path # on windows, users are likely not to add the scrcpy-server to the # SCRCPY_SERVER_PATH scrcpy_server_path_env = os.getenv('SCRCPY_SERVER_PATH', None) if scrcpy_server_path_env: if os.path.exists(scrcpy_server_path_env): - config['scrcpy-server'] = Scrcpy.server_path + config['scrcpy-server'] = scrcpy.server_path else: - Scrcpy.server_path = openFileNameDialog(None, 'scrcpy-server') + scrcpy.server_path = openFileNameDialog(None, 'scrcpy-server') cfedited = True - config['scrcpy-server'] = Scrcpy.server_path - os.environ['SCRCPY_SERVER_PATH'] = Scrcpy.server_path - elif ((Scrcpy.server_path is None) or - (not os.path.exists(Scrcpy.server_path))) and ( + config['scrcpy-server'] = scrcpy.server_path + os.environ['SCRCPY_SERVER_PATH'] = scrcpy.server_path + elif ((scrcpy.server_path is None) or + (not os.path.exists(scrcpy.server_path))) and ( platform.System().system() == 'Windows' ): - Scrcpy.server_path = openFileNameDialog(None, 'scrcpy-server') + scrcpy.server_path = openFileNameDialog(None, 'scrcpy-server') cfedited = True - config['scrcpy-server'] = Scrcpy.server_path - os.environ['SCRCPY_SERVER_PATH'] = Scrcpy.server_path + config['scrcpy-server'] = scrcpy.server_path + os.environ['SCRCPY_SERVER_PATH'] = scrcpy.server_path elif platform.System().system() == "Windows": - os.environ['SCRCPY_SERVER_PATH'] = Scrcpy.server_path + os.environ['SCRCPY_SERVER_PATH'] = scrcpy.server_path if cfedited: cfgmgr.update_config(config) cfgmgr.write_file() - Adb.devices(Adb.path) + adb.devices(adb.path) guiscrcpy = InterfaceGuiscrcpy() guiscrcpy.show() app.processEvents() diff --git a/guiscrcpy/lib/check.py b/guiscrcpy/lib/check.py index ec74373f..c5b6b2e7 100644 --- a/guiscrcpy/lib/check.py +++ b/guiscrcpy/lib/check.py @@ -26,7 +26,7 @@ environment = System() -class Scrcpy: +class scrcpy: def __init__(self): pass @@ -55,7 +55,7 @@ def check(): environment.paths())) -class Adb: +class adb: def __init__(self): pass @@ -92,7 +92,7 @@ def get_dimensions(path, device_id=None): stdout=PIPE, stderr=PIPE) else: shell_adb = Popen(_("{} shell wm size".format(path)), - stdout=PIPE, stderr=PIPE) + stdout=PIPE, stderr=PIPE) raw_dimensions = shell_adb.stdout.read().decode().strip('\n') for i in ['Override size', 'Physical size']: if i in raw_dimensions: @@ -110,12 +110,11 @@ def get_dimensions(path, device_id=None): @staticmethod def shell(path, command, device_id=None): if device_id: - Popen(_("{} -s {} shell {}".format(path, - device_id, command)), - stdout=PIPE, stderr=PIPE) + Popen(_("{} -s {} shell {}".format(path, device_id, command)), + stdout=PIPE, stderr=PIPE) else: Popen(_("{} shell {}".format(path, command)), - stdout=PIPE, stderr=PIPE) + stdout=PIPE, stderr=PIPE) return True @staticmethod @@ -126,7 +125,7 @@ def command(path, command, device_id=None): stderr=PIPE) else: adb_shell_output = Popen(_("{} {}".format(path, command)), - stdout=PIPE, stderr=PIPE) + stdout=PIPE, stderr=PIPE) return adb_shell_output @staticmethod @@ -134,7 +133,7 @@ def devices(increment=''): if increment is None: raise FileNotFoundError( "guiscrcpy couldn't find adb. " - "Please specify path to adb in configuration file" + "Please specify path to adb in configuration filename" ) proc = Popen(_(increment + " devices"), stdout=PIPE) output = [[y.strip() for y in x.split('\t')] diff --git a/guiscrcpy/lib/config.py b/guiscrcpy/lib/config.py index 67df0483..730a438a 100644 --- a/guiscrcpy/lib/config.py +++ b/guiscrcpy/lib/config.py @@ -20,8 +20,8 @@ import json import os -from guiscrcpy.lib.check import Adb -from guiscrcpy.lib.check import Scrcpy +from guiscrcpy.lib.check import adb +from guiscrcpy.lib.check import scrcpy from guiscrcpy.platform import platform @@ -51,11 +51,11 @@ def validate(self): # check scrcpy and adb are not None, else replace it with original # values if self.config['adb'] is None: - adb_path = Adb.check() + adb_path = adb.check() if adb_path: self.config['adb'] = adb_path if self.config['scrcpy'] is None: - scrcpy_path = Scrcpy.check() + scrcpy_path = scrcpy.check() if scrcpy_path: self.config['scrcpy'] = scrcpy_path if (self.config['scrcpy-server'] is not None) and ( diff --git a/guiscrcpy/lib/mapper.py b/guiscrcpy/lib/mapper.py index 6c7a6e9c..ad515ab9 100644 --- a/guiscrcpy/lib/mapper.py +++ b/guiscrcpy/lib/mapper.py @@ -33,7 +33,7 @@ from PyQt5.QtGui import QPixmap from pynput import keyboard -from guiscrcpy.lib.check import Adb +from guiscrcpy.lib.check import adb from guiscrcpy.lib.config import InterfaceConfig get1 = False @@ -42,7 +42,7 @@ cfgmgr = InterfaceConfig() config = cfgmgr.get_config() -Adb.path = config['adb'] +adb.path = config['adb'] jsong = 'guiscrcpy.mapper.json' @@ -53,7 +53,7 @@ print('With USB debugging turned on.') print("+++++++++++++++++++++++++++++++++++++++") print("Waiting for device") -Adb.command(Adb.path, 'wait-for-any-device') +adb.command(adb.path, 'wait-for-any-device') print("Device : OK!") cfgpath = cfgmgr.cfgpath @@ -65,7 +65,7 @@ help="Remove prefernces") args = parser.parse_args() -dimensions = Adb.get_dimensions(Adb.path) +dimensions = adb.get_dimensions(adb.path) class MapperUI(QtWidgets.QWidget): @@ -266,14 +266,14 @@ def file_check(): with open(cfgpath + 'guiscrcpy.mapper.json', 'r') as f: key_a = json.load(f) fileExist = True - print("LOG: Key:Pos JSON Configuration file found in ", + print("LOG: Key:Pos JSON Configuration filename found in ", cfgpath, " directory") except FileNotFoundError: print("LOG: Initializing guiscrcpy.mapper() for first time use...") key_a = {"key": []} with open(cfgpath + jsong, 'w') as f: json.dump(key_a, f) - print("LOG: Key:Pos JSON Configuration file created in ", + print("LOG: Key:Pos JSON Configuration filename created in ", cfgpath, " directory") fileExist = False if platform.system() == "Windows": @@ -293,7 +293,7 @@ def file_check(): if not fileExist: - # Init json file for first time use + # Init json filename for first time use key_a = {"key": [], "pos": []} with open(cfgpath + jsong, 'w') as f: json.dump(key_a, f) @@ -311,13 +311,13 @@ def file_checkm(): with open(cfgpath + jsong, 'r') as f: key_a = json.load(f) fileExist = True - print("LOG: Key:Pos JSON Configuration file found in ", + print("LOG: Key:Pos JSON Configuration filename found in ", cfgpath, " directory") except FileNotFoundError: print("LOG: Initializing guiscrcpy.mapper() for first time use...") with open(cfgpath + jsong, 'w') as f: json.dump(key_a, f) - print("LOG: Key:Pos JSON Configuration file created in ", + print("LOG: Key:Pos JSON Configuration filename created in ", cfgpath, " directory") fileExist = False if (args.reset): @@ -343,7 +343,7 @@ def file_checkm(): ) if not fileExist: - # Init json file for first time use + # Init json filename for first time use key_a = {"key": [], "pos": []} with open(os.path.join(cfgpath, jsong), 'w') as f: json.dump(key_a, f) diff --git a/guiscrcpy/lib/notify.py b/guiscrcpy/lib/notify.py index 66c5f3c0..87dda459 100644 --- a/guiscrcpy/lib/notify.py +++ b/guiscrcpy/lib/notify.py @@ -25,7 +25,7 @@ import pystray from PIL import Image, ImageDraw -from guiscrcpy.lib.check import Adb +from guiscrcpy.lib.check import adb logging.warning("Launching notification auditor") @@ -39,7 +39,7 @@ def __init__(self): def callback(self, icon): notif = Popen( - Adb.path + + adb.path + "adb shell dumpsys notification | grep ticker | cut -d= -f2", stdout=PIPE, shell=True, @@ -54,7 +54,7 @@ def callback(self, icon): "Notif Auditor is experimental on Windows. If you wish to help out on this issue. Open a PR on github" ) notif = Popen( - Adb.path + + adb.path + "adb shell dumpsys notification | findstr ticker ", stdout=PIPE, shell=True, @@ -62,7 +62,7 @@ def callback(self, icon): else: "Notif Auditor is experimental on Linux. If you wish to help out on this issue. Open a PR on github" notif = Popen( - Adb.path + + adb.path + "adb shell dumpsys notification | grep ticker | cut -d= -f2", stdout=PIPE, shell=True, diff --git a/guiscrcpy/lib/process.py b/guiscrcpy/lib/process.py index ecb772c5..f2c78163 100644 --- a/guiscrcpy/lib/process.py +++ b/guiscrcpy/lib/process.py @@ -19,7 +19,6 @@ try: import psutil - psutil_present = True except ModuleNotFoundError: psutil_present = False @@ -34,6 +33,9 @@ def is_running(processName): if processName.lower() in proc.name().lower(): return True except ( - psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + psutil.NoSuchProcess, + psutil.AccessDenied, + psutil.ZombieProcess + ): pass return False diff --git a/guiscrcpy/lib/toolkit.py b/guiscrcpy/lib/toolkit.py index 84825dbf..53ecdfa1 100644 --- a/guiscrcpy/lib/toolkit.py +++ b/guiscrcpy/lib/toolkit.py @@ -20,7 +20,7 @@ import logging import os -from guiscrcpy.lib.check import Adb +from guiscrcpy.lib.check import adb try: import pyautogui as auto @@ -36,8 +36,8 @@ def __init__(self, device_id=None): logging.debug("Launching UX Mapper") self.has_modules = getWindowsWithTitle and auto logging.debug("Calculating Screen Size") - self.android_dimensions = Adb.get_dimensions( - Adb.path, device_id=device_id) + self.android_dimensions = adb.get_dimensions( + adb.path, device_id=device_id) self.deviceId = device_id # each device connected is uniquely identified by the tools by @@ -49,13 +49,13 @@ def get_sha(self): return self.sha def do_swipe(self, x1=10, y1=10, x2=10, y2=10): - Adb.shell_input(Adb.path, "swipe {} {} {} {}".format( + adb.shell_input(adb.path, "swipe {} {} {} {}".format( x1, y1, x2, y2), device_id=self.deviceId) return True def do_keyevent(self, key): - Adb.shell_input(Adb.path, "keyevent {}".format(key), - device_id=self.deviceId) + adb.shell_input(adb.path, "keyevent {}".format(key), + device_id=self.deviceId) return True def copy_devpc(self): @@ -97,17 +97,17 @@ def key_switch(self): def reorientP(self): logging.debug("Passing REORIENT [POTRAIT]") - Adb.shell(Adb.path, 'settings put system accelerometer_rotation 0', - device_id=self.deviceId) - Adb.shell(Adb.path, "settings put system rotation 1", - device_id=self.deviceId) + adb.shell(adb.path, 'settings put system accelerometer_rotation 0', + device_id=self.deviceId) + adb.shell(adb.path, "settings put system rotation 1", + device_id=self.deviceId) def reorientL(self): logging.debug("Passing REORIENT [LANDSCAPE]") - Adb.shell(Adb.path, 'settings put system accelerometer_rotation 0', - device_id=self.deviceId) - Adb.shell(Adb.path, "settings put system rotation 1", - device_id=self.deviceId) + adb.shell(adb.path, 'settings put system accelerometer_rotation 0', + device_id=self.deviceId) + adb.shell(adb.path, "settings put system rotation 1", + device_id=self.deviceId) def expand_notifications(self): logging.debug("Passing NOTIF EXPAND") diff --git a/guiscrcpy/lib/utils.py b/guiscrcpy/lib/utils.py index dba5acfd..ab3c9c7a 100644 --- a/guiscrcpy/lib/utils.py +++ b/guiscrcpy/lib/utils.py @@ -36,10 +36,6 @@ def shellify(args): _ = shellify -def decode(raw_output): - pass - - def decode_process(process): try: output = process.stdout.readlines() @@ -51,10 +47,10 @@ def decode_process(process): return output -def check_existence(paths, file=(), directory=True, PATH=False): +def check_existence(paths, filename="", directory=True, PATH=False): for i in paths: j = os.path.expanduser(i) - if os.path.exists(j): # direcory exists + if os.path.exists(j): # directory exists if directory and os.path.isdir(j): return [j] else: @@ -63,21 +59,22 @@ def check_existence(paths, file=(), directory=True, PATH=False): else: append = '' - if (isinstance(file, list)) or (isinstance(file, tuple)): - for exe in file: + if (isinstance(filename, list)) or \ + (isinstance(filename, tuple)): + for exe in filename: if os.path.exists(os.path.join(j, exe + append)): return [os.path.join(j, exe + append)] else: - if os.path.exists(os.path.join(j, file + append)): - return [os.path.join(j, file + append)] + if os.path.exists(os.path.join(j, filename + append)): + return [os.path.join(j, filename + append)] else: logging.debug("{} doesn't exist".format(i)) if PATH: new_paths = os.getenv('PATH').split(os.pathsep) found_path = check_existence( - new_paths, file=file, directory=directory, PATH=False) + new_paths, filename=filename, directory=directory, PATH=False) if found_path: return found_path + ['path'] else: diff --git a/guiscrcpy/platform/darwin.py b/guiscrcpy/platform/darwin.py index 4e1cb72e..1df01907 100644 --- a/guiscrcpy/platform/darwin.py +++ b/guiscrcpy/platform/darwin.py @@ -40,7 +40,7 @@ def make_config(): os.makedirs(path) except Exception as e: logging.error( - "Error creating configuration file in dir {path}. Error code:{e}" + "Error creating configuration filename in dir {path}. Error code:{e}" .format( path=path, e=e diff --git a/guiscrcpy/platform/linux.py b/guiscrcpy/platform/linux.py index b713868d..dc47650f 100644 --- a/guiscrcpy/platform/linux.py +++ b/guiscrcpy/platform/linux.py @@ -54,7 +54,7 @@ def make_config(self): os.makedirs(path) except Exception as e: logging.error( - "Error creating configuration file in dir {path}. Error code:{e}" + "Error creating configuration filename in dir {path}. Error code:{e}" .format( path=path, e=e @@ -63,7 +63,7 @@ def make_config(self): def create_desktop(self): """ - Create Desktop file for Linux in ~/.local level + Create Desktop filename for Linux in ~/.local level :return: """ diff --git a/guiscrcpy/platform/windows.py b/guiscrcpy/platform/windows.py index 8c9aa1f4..3cc6e08f 100644 --- a/guiscrcpy/platform/windows.py +++ b/guiscrcpy/platform/windows.py @@ -37,7 +37,7 @@ def make_config(): os.makedirs(path) except Exception as e: logging.error( - "Error creating configuration file in dir {path}. Error code:{e}" + "Error creating configuration filename in dir {path}. Error code:{e}" .format( path=path, e=e diff --git a/guiscrcpy/platform/windows_tools/tools.py b/guiscrcpy/platform/windows_tools/tools.py index 38a60824..120dc56a 100644 --- a/guiscrcpy/platform/windows_tools/tools.py +++ b/guiscrcpy/platform/windows_tools/tools.py @@ -27,7 +27,7 @@ def get_conda_active_env(): return conda_env -# batch file to activate the environment +# batch filename to activate the environment # for Anaconda Python before running command. conda_env = get_conda_active_env() ENVRUNNER = """ diff --git a/guiscrcpy/theme/style.py b/guiscrcpy/theme/style.py index f41d81bf..9f9dfd4d 100644 --- a/guiscrcpy/theme/style.py +++ b/guiscrcpy/theme/style.py @@ -28,7 +28,7 @@ def darkstylesheet(): The definitions are in the "qdarkstyle.qss._styles.scss" module - WARNING! All changes made in this file will be lost! + WARNING! All changes made in this filename will be lost! --------------------------------------------------------------------------- */ /* QDarkStyleSheet ----------------------------------------------------------- diff --git a/guiscrcpy/ui/downloader.py b/guiscrcpy/ui/downloader.py index ecf0199f..9e412e5e 100644 --- a/guiscrcpy/ui/downloader.py +++ b/guiscrcpy/ui/downloader.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'guiscrcpy/ui/downloader.ui' +# Form implementation generated from reading ui filename 'guiscrcpy/ui/downloader.ui' # # Created by: PyQt5 UI code generator 5.14.1 # -# WARNING! All changes made in this file will be lost! +# WARNING! All changes made in this filename will be lost! from PyQt5 import QtCore, QtGui, QtWidgets diff --git a/guiscrcpy/ui/main.py b/guiscrcpy/ui/main.py index bf62d3c3..827255a9 100644 --- a/guiscrcpy/ui/main.py +++ b/guiscrcpy/ui/main.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'guiscrcpy/ui/mainwindow.ui' +# Form implementation generated from reading ui filename 'guiscrcpy/ui/mainwindow.ui' # # Created by: PyQt5 UI code generator 5.14.2 # -# WARNING! All changes made in this file will be lost! +# WARNING! All changes made in this filename will be lost! from PyQt5 import QtCore, QtGui, QtWidgets diff --git a/guiscrcpy/ui/network.py b/guiscrcpy/ui/network.py index f701ec49..69549232 100644 --- a/guiscrcpy/ui/network.py +++ b/guiscrcpy/ui/network.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'guiscrcpy/ui/network.ui' +# Form implementation generated from reading ui filename 'guiscrcpy/ui/network.ui' # # Created by: PyQt5 UI code generator 5.14.2 # -# WARNING! All changes made in this file will be lost! +# WARNING! All changes made in this filename will be lost! from PyQt5 import QtCore, QtGui, QtWidgets diff --git a/guiscrcpy/ui/panel.py b/guiscrcpy/ui/panel.py index 7ed8422d..17d873fa 100644 --- a/guiscrcpy/ui/panel.py +++ b/guiscrcpy/ui/panel.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'guiscrcpy/ui/bottompanelui.ui' +# Form implementation generated from reading ui filename 'guiscrcpy/ui/bottompanelui.ui' # # Created by: PyQt5 UI code generator 5.14.2 # -# WARNING! All changes made in this file will be lost! +# WARNING! All changes made in this filename will be lost! from PyQt5 import QtCore, QtGui, QtWidgets diff --git a/guiscrcpy/ui/rsrc_rc.py b/guiscrcpy/ui/rsrc_rc.py index 3ff9e5b7..26ccdd27 100644 --- a/guiscrcpy/ui/rsrc_rc.py +++ b/guiscrcpy/ui/rsrc_rc.py @@ -4,7 +4,7 @@ # # Created by: The Resource Compiler for PyQt5 (Qt v5.14.2) # -# WARNING! All changes made in this file will be lost! +# WARNING! All changes made in this filename will be lost! from PyQt5 import QtCore diff --git a/guiscrcpy/ui/settings.py b/guiscrcpy/ui/settings.py index 1ecdefba..4d8c8665 100644 --- a/guiscrcpy/ui/settings.py +++ b/guiscrcpy/ui/settings.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'settings.ui' +# Form implementation generated from reading ui filename 'settings.ui' # # Created by: PyQt5 UI code generator 5.14.1 # -# WARNING! All changes made in this file will be lost! +# WARNING! All changes made in this filename will be lost! from PyQt5 import QtCore, QtWidgets diff --git a/guiscrcpy/ui/toolkit.py b/guiscrcpy/ui/toolkit.py index 9abe2665..c2d39548 100644 --- a/guiscrcpy/ui/toolkit.py +++ b/guiscrcpy/ui/toolkit.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'guiscrcpy/ui/toolkit_ui.ui' +# Form implementation generated from reading ui filename 'guiscrcpy/ui/toolkit_ui.ui' # # Created by: PyQt5 UI code generator 5.14.2 # -# WARNING! All changes made in this file will be lost! +# WARNING! All changes made in this filename will be lost! from PyQt5 import QtCore, QtGui, QtWidgets diff --git a/guiscrcpy/ux/network.py b/guiscrcpy/ux/network.py index ccc79f9b..706e36e8 100644 --- a/guiscrcpy/ux/network.py +++ b/guiscrcpy/ux/network.py @@ -21,7 +21,7 @@ from PyQt5.QtWidgets import QMainWindow -from guiscrcpy.lib.check import Adb +from guiscrcpy.lib.check import adb from guiscrcpy.network.network import NetworkManager from guiscrcpy.platform.platform import System from guiscrcpy.ui.network import Ui_NetworkUI @@ -30,7 +30,8 @@ class InterfaceNetwork(QMainWindow, Ui_NetworkUI): """ Network manager UI UX Kit for guiscrcpy - Scans the open IP Addresses connected on the system, on Linux and Mac only, as far as tested + Scans the open IP Addresses connected on the system, + on Linux and Mac only, as far as tested Does not work satisfactorily on Windows. """ @@ -39,7 +40,7 @@ def __init__(self, adb_path=None): Ui_NetworkUI.__init__(self) self.os = System() self.setupUi(self) - Adb.path = adb_path + adb.path = adb_path self.nm = NetworkManager() def init(self): @@ -58,8 +59,9 @@ def init(self): self.nm_det.setText("Click Refresh to load IP addresses") self.tcpip.pressed.connect(self.tcpip_launch) - def tcpip_launch(self): - Adb.command(Adb.path, 'tcpip') + @staticmethod + def tcpip_launch(): + adb.command(adb.path, 'tcpip') def connect(self): try: @@ -80,10 +82,11 @@ def connect(self): "Please enter an IP address in the text box") else: self.nm_det.setText( - "Please enter an IP address in the text box. / Click refresh") + "Please enter an IP address in the text box. / " + "Click refresh") return - sp = Adb.command(Adb.path, 'connect {}:5555'.format(ip)) + sp = adb.command(adb.path, 'connect {}:5555'.format(ip)) count = 0 while True: count += 1 diff --git a/guiscrcpy/ux/panel.py b/guiscrcpy/ux/panel.py index 20c934be..974c6ad0 100644 --- a/guiscrcpy/ux/panel.py +++ b/guiscrcpy/ux/panel.py @@ -46,7 +46,7 @@ def __init__(self, parent=None, ux_mapper=None): self.ux = UXMapper() def init(self): - self.bp_close.clicked.connect(self.quitn) + self.bp_close.clicked.connect(self.quit_window) self.backk.clicked.connect(self.ux.key_back) self.menuUII.clicked.connect(self.ux.key_menu) self.homee.clicked.connect(self.ux.key_home) @@ -72,7 +72,7 @@ def mouseMoveEvent(self, event): except (TypeError, AttributeError): pass - def quitn(self): + def quit_window(self): for instance in self.parent.child_windows: # We are checking for any more windows running before killing # the main window. self.child_windows has the list of all @@ -86,4 +86,4 @@ def quitn(self): self.hide() break else: - sys.exit() \ No newline at end of file + sys.exit(0) diff --git a/guiscrcpy/ux/settings.py b/guiscrcpy/ux/settings.py index 36643b02..8536de04 100644 --- a/guiscrcpy/ux/settings.py +++ b/guiscrcpy/ux/settings.py @@ -48,10 +48,10 @@ def __init__(self, parent): def init(self): self.updatebutton.clicked.connect(self.complete) - self.a6d1.clicked.connect(self.filechooser) + self.a6d1.clicked.connect(self.file_chooser) self.show() - def filechooser(self): + def file_chooser(self): dialog = QFileDialog() dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden) dialog.setDefaultSuffix('mp4') diff --git a/guiscrcpy/ux/swipe.py b/guiscrcpy/ux/swipe.py index ef291deb..d6fa3d7b 100644 --- a/guiscrcpy/ux/swipe.py +++ b/guiscrcpy/ux/swipe.py @@ -181,32 +181,32 @@ def mouseMoveEvent(self, event): def swipdn(self): logging.debug("Passing SWIPE DOWN") - dimValues = self.ux.android_dimensions - posy = int(dimValues[1]) - 200 - posx = int(dimValues[0]) - newposx = posx / 2 # find center - self.ux.do_swipe(newposx, 200, newposx, posy) + dim_values = self.ux.android_dimensions + pos_y = int(dim_values[1]) - 200 + pos_x = int(dim_values[0]) + new_pos_x = pos_x / 2 # find center + self.ux.do_swipe(new_pos_x, 200, new_pos_x, pos_y) def swipup(self): logging.debug("Passing SWIPE UP") - dimValues = self.ux.android_dimensions - posy = int(dimValues[1]) - 100 - posx = int(dimValues[0]) - newposx = int(posx / 2) # find center - self.ux.do_swipe(newposx, posy, newposx, 200) + dim_values = self.ux.android_dimensions + pos_y = int(dim_values[1]) - 100 + pos_x = int(dim_values[0]) + new_pos_x = int(pos_x / 2) # find center + self.ux.do_swipe(new_pos_x, pos_y, new_pos_x, 200) def swipleft(self): logging.debug("Passing SWIPE LEFT") - dimValues = self.ux.android_dimensions - posy = int(dimValues[1]) - posx = int(dimValues[0]) - 10 - newposy = int(posy / 2) # find center - self.ux.do_swipe(10, newposy, posx, newposy) + dim_values = self.ux.android_dimensions + pos_y = int(dim_values[1]) + pos_x = int(dim_values[0]) - 10 + new_pos_y = int(pos_y / 2) # find center + self.ux.do_swipe(10, new_pos_y, pos_x, new_pos_y) def swipright(self): logging.debug("Passing SWIPE RIGHT") - dimValues = self.ux.android_dimensions - posy = int(dimValues[1]) - posx = int(dimValues[0]) - 10 - newposy = int(posy / 2) # find center - self.ux.do_swipe(posx, newposy, 10, newposy) + dim_values = self.ux.android_dimensions + pos_y = int(dim_values[1]) + pos_x = int(dim_values[0]) - 10 + new_pos_y = int(pos_y / 2) # find center + self.ux.do_swipe(pos_x, new_pos_y, 10, new_pos_y) diff --git a/guiscrcpy/ux/toolkit.py b/guiscrcpy/ux/toolkit.py index 963a409f..5d439542 100644 --- a/guiscrcpy/ux/toolkit.py +++ b/guiscrcpy/ux/toolkit.py @@ -50,7 +50,7 @@ def init(self): self.clipD2PC.clicked.connect(self.ux.copy_devpc) self.clipPC2D.clicked.connect(self.ux.copy_pc2dev) self.back.clicked.connect(self.ux.key_back) - self.screenfreeze.clicked.connect(self.quitn) + self.screenfreeze.clicked.connect(self.quit_window) self.appswi.clicked.connect(self.ux.key_switch) self.menuUI.clicked.connect(self.ux.key_menu) self.home.clicked.connect(self.ux.key_home) @@ -80,7 +80,7 @@ def mouseMoveEvent(self, event): except (TypeError, AttributeError): pass - def quitn(self): + def quit_window(self): for instance in self.parent.child_windows: # We are checking for any more windows running before killing # the main window. self.child_windows has the list of all diff --git a/manifest.json b/manifest.json index 8f6e917f..e804ebe9 100644 --- a/manifest.json +++ b/manifest.json @@ -1,16 +1,16 @@ { - "name": "guiscrcpy", - "version": "3.5", - "manifest_version": 2, - "description": "Open Source Android Screen Mirroring System", - - "icons": { - "16": "/docs/img/guiscrcpy_logo.png", - "48": "/docs/img/guiscrcpy_logo.png", - "128": "/docs/img/guiscrcpy_logo.png" - }, - "browser_action": { - "default_title": "guiscrcpy", - "default_icon": "/docs/img/guiscrcpy_logo.png" - }, + "name": "guiscrcpy", + "version": "3.5", + "manifest_version": 2, + "description": "Open Source Android Screen Mirroring System", + + "icons": { + "16": "/docs/img/guiscrcpy_logo.png", + "48": "/docs/img/guiscrcpy_logo.png", + "128": "/docs/img/guiscrcpy_logo.png" + }, + "browser_action": { + "default_title": "guiscrcpy", + "default_icon": "/docs/img/guiscrcpy_logo.png" + }, } diff --git a/releaser b/releaser index d92e115a..dde395d1 100755 --- a/releaser +++ b/releaser @@ -152,5 +152,5 @@ with open("guiscrcpy/version.py", 'w') as w: version=v, )) -print("Setup file generated.") +print("Setup filename generated.") print("GUISCRCPY >> VERSION : {}".format(v)) diff --git a/scripts/guiscrcpy-mapper b/scripts/guiscrcpy-mapper index ef9de7e6..56c81e41 100644 --- a/scripts/guiscrcpy-mapper +++ b/scripts/guiscrcpy-mapper @@ -10,27 +10,28 @@ parser = argparse.ArgumentParser() parser.add_argument('-r', '--reset', action="store_true", help="Remove prefernces") args = parser.parse_args() -if (platform.system() == 'Windows'): - cfgpath = os.path.expanduser("~/AppData/Local/guiscrcpy/") +if platform.system() == 'Windows': + config_path = os.path.expanduser("~/AppData/Local/guiscrcpy/") else: - if (os.getenv('XDG_CONFIG_HOME') is None): - cfgpath = os.path.expanduser("~/.config/guiscrcpy/") + if os.getenv('XDG_CONFIG_HOME') is None: + config_path = os.path.expanduser("~/.config/guiscrcpy/") else: - cfgpath = os.getenv('XDG_CONFIG_HOME').split(":")[0] + "/guiscrcpy/" + config_path = os.getenv('XDG_CONFIG_HOME').split(":")[0] + \ + "/guiscrcpy/" -if (args.reset): - os.remove(cfgpath+"guiscrcpy.mapper.json") +if args.reset: + os.remove(config_path + "guiscrcpy.mapper.json") print("FILE RESET") sys.exit() -patz = list(guiscrcpy.__path__)[0] +paths = list(guiscrcpy.__path__)[0] -sys.path.append(patz) +sys.path.append(paths) sys.path.append('') # print("PATH: ", sys.path) mapper.file_check() -os.chdir(patz) +os.chdir(paths) diff --git a/setup.py b/setup.py index 4581fbb9..23e53863 100755 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ """ from setuptools import setup -import platform +import platform requirements = ['PyQt5==5.14.2', 'pynput'] if platform.system() == 'Windows': @@ -30,7 +30,6 @@ requirements.extend(['fonttools', 'psutil']) - setup( name='guiscrcpy', version='3.4.post59.dev', @@ -95,16 +94,18 @@ author='srevinsaju', author_email="srevin03@gmail.com", packages=['guiscrcpy'], - data_files = [ - ('share/applications', ['guiscrcpy.desktop'] ) + data_files=[ + ('share/applications', ['guiscrcpy.desktop']) ], url="https://srevinsaju.github.io/guiscrcpy", download_url="https://github.com/srevinsaju/guiscrcpy/archive/master.zip", - package_data={'guiscrcpy': ['*', '*.*', 'resources/*', 'ui/*', 'lib/*', 'platform/*', 'theme/*', 'ux/*', 'network/*', 'settings/*', 'install/*', 'platform/windows_tools/*', 'ui/icons/*', 'ui/fonts/*', 'ui/rsrc/*', 'ui/ui/*']}, + package_data={'guiscrcpy': ['*', '*.*', 'resources/*', 'ui/*', 'lib/*', 'platform/*', 'theme/*', 'ux/*', 'network/*', + 'settings/*', 'install/*', 'platform/windows_tools/*', 'ui/icons/*', 'ui/fonts/*', 'ui/rsrc/*', 'ui/ui/*']}, include_package_data=True, install_requires=requirements, scripts=["scripts/guiscrcpy", "scripts/guiscrcpy-mapper"], - entry_points={'console_scripts': ['guiscrcpy = guiscrcpy.launcher:bootstrap']}, + entry_points={'console_scripts': [ + 'guiscrcpy = guiscrcpy.launcher:bootstrap']}, classifiers=['Operating System :: OS Independent', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.6', @@ -114,4 +115,3 @@ 'Operating System :: POSIX', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)'], ) -