Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
Refactor entry points
Browse files Browse the repository at this point in the history
  • Loading branch information
srevinsaju committed Apr 20, 2020
1 parent aef6178 commit 4dab0ee
Show file tree
Hide file tree
Showing 34 changed files with 203 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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
#
Expand Down
34 changes: 17 additions & 17 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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 [email protected]. All
Expand 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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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. <https://fsf.org/>
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
[dev - packages]

[packages]
fonttools = "*"
Expand Down
22 changes: 13 additions & 9 deletions guiscrcpy.desktop
Original file line number Diff line number Diff line change
@@ -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
58 changes: 29 additions & 29 deletions guiscrcpy/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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',
Expand Down Expand Up @@ -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...")

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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()
Expand Down
17 changes: 8 additions & 9 deletions guiscrcpy/lib/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
environment = System()


class Scrcpy:
class scrcpy:
def __init__(self):
pass

Expand Down Expand Up @@ -55,7 +55,7 @@ def check():
environment.paths()))


class Adb:
class adb:
def __init__(self):
pass

Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -126,15 +125,15 @@ 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
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')]
Expand Down
8 changes: 4 additions & 4 deletions guiscrcpy/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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 (
Expand Down
Loading

0 comments on commit 4dab0ee

Please sign in to comment.