예제 #1
0
 def __init__(self):
     self.ping = check_existence(platform.System().paths(),
                                 'ping',
                                 path=True,
                                 directory=False)
     if len(self.ping) >= 1:
         self.ping = self.ping[0]
예제 #2
0
 def __init__(self):
     """
     Manages guiscrcpy's configuration files
     """
     self.os = platform.System()
     self.cfgpath = self.os.cfgpath()
     self.paths = self.os.paths()
     self.config = {
         'paths': self.paths,
         'scrcpy': None,
         'adb': None,
         'panels': {
             'swipe': True,
             'bottom': True,
             'toolkit': True
         },
         'sha_shift': 5,
         'scrcpy-server': None,
         'dimension': None,
         'swtouches': False,
         'bitrate': 8000,
         'fullscreen': False,
         'dispRO': False,
         'extra': "",
         'cmx': "",
         'device': {},
         'theme': 'Breeze'
     }
     self.json_file = 'guiscrcpy.json'
     self.check_file()
     self.validate()
예제 #3
0
 def __init__(self, load=True):
     """
     Manages guiscrcpy's configuration files
     """
     self.os = platform.System()
     self.cfgpath = self.os.cfgpath()
     self.paths = self.os.paths()
     self.config = {
         "paths": self.paths,
         "scrcpy": None,
         "adb": None,
         "panels": {
             "swipe": True,
             "bottom": True,
             "toolkit": True
         },
         "mapper": "",
         "sha_shift": 5,
         "scrcpy-server": None,
         "dimension": None,
         "swtouches": False,
         "bitrate": 8000,
         "fullscreen": False,
         "dispRO": False,
         "extra": "",
         "cmx": "",
         "device": {},
         "theme": "Breeze",
     }
     self.json_file = "guiscrcpy.json"
     if load:
         self.load_config()
예제 #4
0
파일: config.py 프로젝트: xiedou1/guiscrcpy
 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()
         if adb_path:
             self.config['adb'] = adb_path
     if self.config['scrcpy'] is None:
         scrcpy_path = scrcpy.check()
         if scrcpy_path:
             self.config['scrcpy'] = scrcpy_path
     if (self.config['scrcpy-server'] is not None) and (platform.System()
                                                        == "Windows"):
         os.environ['SCRCPY_SERVER_PATH'] = self.config['scrcpy-server']
     return True
예제 #5
0
 def validate(self):
     # check scrcpy and adb are not None, else replace it with original
     # values
     if os.getenv('APPIMAGE') is not None:
         # no need further configuration for adb, scrcpy and scrcpy_server
         return True
     if self.config['adb'] is None:
         adb_path = shutil.which('adb')
         self.config['adb'] = adb_path
     if self.config['scrcpy'] is None:
         scrcpy_path = shutil.which('scrcpy')
         self.config['scrcpy'] = scrcpy_path
     if (self.config['scrcpy-server'] is not None) and (platform.System()
                                                        == "Windows"):
         os.environ['SCRCPY_SERVER_PATH'] = self.config['scrcpy-server']
     return True
예제 #6
0
파일: config.py 프로젝트: ix4/guiscrcpy
 def __init__(self, mode='w'):
     self.os = platform.System()
     self.cfgpath = self.os.cfgpath()
     self.paths = self.os.paths()
     self.config = {
         'paths': self.paths,
         'scrcpy': None,
         'adb': None,
         'dimension': None,
         'swtouches': False,
         'bitrate': 8000,
         'fullscreen': False,
         'dispRO': False,
         'extra': ""
     }
     self.jsonfile = 'guiscrcpy.json'
     self.check_file()
     self.validate()
예제 #7
0
def bootstrap0():
    # enable highdpi scaling
    QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
    QApplication.setAttribute(
        QtCore.Qt.AA_UseHighDpiPixmaps, True)  # use highdpi icons
    app = QtWidgets.QApplication(sys.argv)

    app.setStyle('Breeze')
    app.setStyleSheet(darkstylesheet())

    splash_pix = QPixmap(":/res/ui/guiscrcpy-branding.png")
    splash = QtWidgets.QSplashScreen(splash_pix)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()
    cfedited = False

    from guiscrcpy.install.finder import openFileNameDialog
    if adb.path is None:
        adb.path = openFileNameDialog(None, 'adb')
        cfedited = True
        config['adb'] = adb.path

    if scrcpy.path is None:
        scrcpy.path = openFileNameDialog(None, 'scrcpy')
        cfedited = True
        config['scrcpy'] = scrcpy.path

    if (scrcpy.server_path is None) and (platform.System() == 'Windows'):
        scrcpy.server_path = openFileNameDialog(None, 'scrcpy-server')
        cfedited = True
        config['scrcpy-server'] = scrcpy.server_path

    if cfedited:
        cfgmgr.update_config(config)
        cfgmgr.write_file()

    adb.devices(adb.path)
    prog = InterfaceGuiscrcpy()
    prog.show()
    app.processEvents()
    splash.hide()
    app.exec_()
    sys.exit()
예제 #8
0
 def __init__(self):
     """
     Manages guiscrcpy's configuration files
     """
     self.os = platform.System()
     self.cfgpath = self.os.cfgpath()
     self.paths = self.os.paths()
     self.config = {
         'paths': self.paths,
         'scrcpy': None,
         'adb': None,
         'scrcpy-server': None,
         'dimension': None,
         'swtouches': False,
         'bitrate': 8000,
         'fullscreen': False,
         'dispRO': False,
         'extra': "",
         'cmx': ""
     }
     self.json_file = 'guiscrcpy.json'
     self.check_file()
     self.validate()
예제 #9
0
 def validate(self):
     # check scrcpy and adb are not None, else replace it with original
     # values
     if os.getenv("APPIMAGE") is not None:
         # no need further configuration for adb, scrcpy and scrcpy_server
         self.config["adb"] = os.getenv("GUISCRCPY_ADB")
         self.config["scrcpy"] = os.getenv("GUISCRCPY_SCRCPY")
         return True
     if self.config["adb"] is None:
         adb_path = shutil.which("adb")
         self.config["adb"] = adb_path
     else:
         _adb_path = self.config["adb"]
         if not os.path.exists(_adb_path):
             raise InvalidConfigurationError(
                 "The configuration key 'adb' is "
                 "invalid. {} does not exist. "
                 "If you did not set it on purpose, "
                 "run `guiscrcpy config -r` to reset "
                 "the configuration".format(self.config["adb"]))
     if self.config["scrcpy"] is None:
         scrcpy_path = shutil.which("scrcpy")
         self.config["scrcpy"] = scrcpy_path
     else:
         _scrcpy_path = self.config["scrcpy"]
         if not os.path.exists(_scrcpy_path):
             raise InvalidConfigurationError(
                 "The configuration key 'scrcpy' is "
                 "invalid. {} does not exist. "
                 "If you did not set it on purpose, "
                 "run `guiscrcpy config -r` to reset "
                 "the configuration".format(self.config["scrcpy"]))
     if (self.config["scrcpy-server"] is not None) and (platform.System()
                                                        == "Windows"):
         os.environ["SCRCPY_SERVER_PATH"] = self.config["scrcpy-server"]
     return True
예제 #10
0
파일: launcher.py 프로젝트: ix4/guiscrcpy
from guiscrcpy.ui.toolkit import Ui_ToolbarPanel
from guiscrcpy.ui.panel import Ui_HorizontalPanel
from guiscrcpy.lib.toolkit import UXMapper
from guiscrcpy.ux.panel import Panel
from guiscrcpy.ux.swipe import SwipeUX
from guiscrcpy.ux.toolkit import InterfaceToolkit

try:
    os.chdir(os.path.dirname(__file__))
except FileNotFoundError:
    pass  # Its a PyInstaller compiled package

# initialize config manager
cfgmgr = InterfaceConfig()
config = cfgmgr.get_config()
environment = platform.System()
adb.path = config['adb']
scrcpy.path = config['scrcpy']
v = version()

# Initialize argument parser
parser = argparse.ArgumentParser('guiscrcpy v{}'.format(v.get_commit()))
parser.add_argument('-i', '--install', action='store_true',
                    help="Install guiscrcpy system wide on Linux")
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 as well as in .log file")
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',
예제 #11
0
def bootstrap0():
    """
    Launch the guiscrcpy window
    :return:
    """
    # enable High DPI scaling
    QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
    QApplication.setAttribute(
        QtCore.Qt.AA_UseHighDpiPixmaps, True)  # use HIGH DPI icons
    app = QtWidgets.QApplication(sys.argv)

    app.setStyle('Breeze')
    app.setStyleSheet(dark_stylesheet())

    splash_pix = QPixmap(":/res/ui/guiscrcpy-branding.png")
    splash = QtWidgets.QSplashScreen(splash_pix)
    splash.setMask(splash_pix.mask())
    splash.show()
    app.processEvents()
    cfg_edited = False

    if (adb.path is None) or (not os.path.exists(adb.path)):
        adb.path = open_exe_name_dialog(None, 'adb')
        cfg_edited = True
        config['adb'] = adb.path

    if (scrcpy.path is None) or (not os.path.exists(scrcpy.path)):
        scrcpy.path = open_exe_name_dialog(None, 'scrcpy')
        cfg_edited = True
        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
        else:
            scrcpy.server_path = open_exe_name_dialog(None, 'scrcpy-server')
            cfg_edited = 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 (
        platform.System().system() == 'Windows'
    ):
        scrcpy.server_path = open_exe_name_dialog(None, 'scrcpy-server')
        cfg_edited = True
        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

    if cfg_edited:
        cfgmgr.update_config(config)
        cfgmgr.write_file()

    adb.devices(adb.path)
    guiscrcpy = InterfaceGuiscrcpy()
    guiscrcpy.show()
    app.processEvents()
    splash.hide()
    app.exec_()
    sys.exit()