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

Commit

Permalink
3.5 Stable (#71)
Browse files Browse the repository at this point in the history
* Update gitpython from 3.0.7 to 3.1.0 (#68)

* Release 3.3 Stable (#69)

* Init downloader

* Add init UI

* Edit Object name of Initializer

* Add support for selecting scrcpy executable

* Fix Toolbar appearance (panel holder)

* Update version

* Add desktop file support for Linux OS

* Amend requirements, add dependency

* PEP8 and Flake8 Fixes

* Remove unnecessary imports in setup.py

* Add dependency pywin32 to windows systems

* Fix desktop function for Windows and Linux

* Fix font manager

* Change modes

* Add windows tools

* update version in version.txt

* update version in ver.py

* Update guiscrcpy_windows spec file

* Fix #75. Fix FileNotFoundError

* Fix mapper to port for Override Resolutions #74

* Remove dependency psutil for MacOS

* Add conditional launching of psutil depending on its installed or not

* Prepare release 3.5

Signed-off-by: Srevin Saju <[email protected]>

* Prepare release 3.5

* Fix appimage config file

* Fix version

* Postpone appimage

Co-authored-by: pyup.io bot <[email protected]>
  • Loading branch information
srevinsaju and pyup-bot authored Apr 6, 2020
1 parent a907e87 commit fe45e9f
Show file tree
Hide file tree
Showing 37 changed files with 887 additions and 449 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/appimage.yml

This file was deleted.

Empty file modified CODE_OF_CONDUCT.md
100755 → 100644
Empty file.
Empty file modified guiscrcpy-windows.spec
100755 → 100644
Empty file.
3 changes: 2 additions & 1 deletion guiscrcpy.desktop
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[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
StartupWMClass=guiscrcpy
1 change: 0 additions & 1 deletion guiscrcpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

2 changes: 1 addition & 1 deletion guiscrcpy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"""


print("Running guiscrcpy as a python module")
from guiscrcpy.launcher import bootstrap
print("Running guiscrcpy as a python module")
bootstrap()
14 changes: 14 additions & 0 deletions guiscrcpy/install/finder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import sys
from PyQt5.QtWidgets import QFileDialog


def openFileNameDialog(parent, appname):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
fileName, _ = \
QFileDialog.getOpenFileName(parent, "{} could not be found. Please locate it manually".format(appname),
"", "Valid {} executable (*);;".format(appname), options=options)
if fileName:
print(fileName)
return fileName
43 changes: 32 additions & 11 deletions guiscrcpy/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@
except FileNotFoundError:
pass # Its a PyInstaller compiled package

# create app


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

# Initialize argument parser
Expand Down Expand Up @@ -141,11 +145,11 @@
logging.debug("Importing modules...")


class InterfaceGuiscrcpy(Ui_MainWindow):
def __init__(self, Ui_MainWindow):
Ui_MainWindow.__init__()
self.setupUi(Ui_MainWindow)
super(InterfaceGuiscrcpy, self).__init__()
class InterfaceGuiscrcpy(QMainWindow, Ui_MainWindow):
def __init__(self):
QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.cmx = None
logging.debug(
"Options received by class are : {} {} {} {} {} ".format(
Expand Down Expand Up @@ -465,20 +469,37 @@ def bootstrap0():
app.setStyle('Breeze')
app.setStyleSheet(darkstylesheet())

window = QtWidgets.QMainWindow() # Create windwo
prog = InterfaceGuiscrcpy(window)

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

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

app.processEvents()
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

window.show()
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()
Expand Down
7 changes: 4 additions & 3 deletions guiscrcpy/lib/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def device():

@staticmethod
def check():
scrcpy_path = check_existence(environment.paths(), ['scrcpy'], False, True)
scrcpy_path = check_existence(
environment.paths(), ['scrcpy'], False, True)
if scrcpy_path and (type(scrcpy_path) is list):
return scrcpy_path[0]
else:
Expand Down Expand Up @@ -95,7 +96,8 @@ def get_dimensions(path):
return dimValues
else:
logging.error(
"AndroidDeviceError: adb shell wm size did not return 'Physical Size' or 'Override Size'")
"AndroidDeviceError: adb shell wm size did not return 'Physical Size' or 'Override Size'"
)
return False

@staticmethod
Expand All @@ -116,7 +118,6 @@ def command(path, command):
)
return shellx


@staticmethod
def devices(increment=''):
if increment is None:
Expand Down
7 changes: 7 additions & 0 deletions guiscrcpy/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, mode='w'):
'paths': self.paths,
'scrcpy': None,
'adb': None,
'scrcpy-server': None,
'dimension': None,
'swtouches': False,
'bitrate': 8000,
Expand All @@ -57,6 +58,8 @@ def validate(self):
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

def get_config(self):
Expand Down Expand Up @@ -90,6 +93,10 @@ def check_file(self):
if not os.path.exists(self.cfgpath):
os.mkdir(self.cfgpath)
if not os.path.exists(os.path.join(self.cfgpath, self.jsonfile)):
if (self.os.system() == 'Linux') or (self.os.system() == 'Windows'):
self.os.create_desktop()
self.os.install_fonts()

self.write_file()
self.read_file()

Expand Down
59 changes: 12 additions & 47 deletions guiscrcpy/lib/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""


from guiscrcpy.lib.config import InterfaceConfig
from guiscrcpy.lib.check import adb
import argparse
from subprocess import PIPE, Popen
from pynput import keyboard
Expand All @@ -37,16 +38,11 @@
fixedpos = [0, 0]
finalpos = [0, 0]

cfgmgr = InterfaceConfig()
config = cfgmgr.get_config()
adb.path = config['adb']

jsong = 'guiscrcpy.mapper.json'
if platform.system() == "Windows":
if os.path.isfile("./scrcpy.exe"):
increment = ".\\"
# print(bcolors.BOLD + "LOG: Found scrcpy.exe in current directory.")
else:
increment = ""
else:
increment = ""

print("+++++++++++++++++++++++++++++++++++++++")
print("guiscrcpy ~ mapper by srevinsaju")
Expand All @@ -55,19 +51,10 @@
print('With USB debugging turned on.')
print("+++++++++++++++++++++++++++++++++++++++")
print("Waiting for device")
po(increment + "adb wait-for-any-device", shell=True)
adb.command(adb.path, 'wait-for-any-device')
print("Device : OK!")


# Declare key_a. path position
if (platform.system() == 'Windows'):
cfgpath = os.path.expanduser("~/AppData/Local/guiscrcpy/")
else:
if (os.getenv('XDG_CONFIG_HOME') is None):
cfgpath = os.path.expanduser("~/.config/guiscrcpy/")
else:
cfgpath = os.getenv('XDG_CONFIG_HOME').split(":")[0] + "/guiscrcpy/"

cfgpath = cfgmgr.cfgpath

parser = argparse.ArgumentParser()
parser.add_argument('-t', '--delay', default=10,
Expand All @@ -76,20 +63,7 @@
help="Remove prefernces")
args = parser.parse_args()

adb_dim = po(
"adb shell wm size", shell=True, stdout=PIPE, stderr=PIPE
)

out = adb_dim.stdout.read()
out_decoded = out.decode("utf-8")
out_decoded = out_decoded[:-1]
dimVal = out_decoded.split(": ")
try:
dimensions_ = dimVal[1]
dimValues = dimensions_.split("x")
print(dimValues, " DIMENSIONS ")
except:
print("Error Device not connected")
dimensions = adb.get_dimensions(adb.path)


class MapperUI(QtWidgets.QWidget):
Expand Down Expand Up @@ -181,8 +155,8 @@ def keyreg(self):
#print("REL POS :: ", fixedpos)
relx = fixedpos[0]/self.label.width()
rely = fixedpos[1]/self.label.height()
fixx = relx * int(dimValues[0])
fixy = rely * int(dimValues[1])
fixx = relx * int(dimensions[0])
fixy = rely * int(dimensions[1])
print("FINALIZED POS :: ", fixx, fixy)

finalpos[0] = fixx
Expand Down Expand Up @@ -255,7 +229,6 @@ def on_press0(key):

try:
if key.char in key_a.keys():

print(key.char)
print("running cmd")
finalpos0 = key_a[key.char]
Expand All @@ -278,17 +251,11 @@ def on_press0(key):

def sth():
import sys

app = QtWidgets.QApplication(sys.argv)
window = MapperUI()

sys.exit(app.exec_())


def sth_w0():
pass


def file_check():
jsong = 'guiscrcpy.mapper.json'

Expand Down Expand Up @@ -373,15 +340,13 @@ def file_checkm():
)

if not fileExist:

# Init json file for first time use
key_a = {"key": [], "pos": []}
with open(cfgpath + jsong, 'w') as f:
with open(os.path.join(cfgpath, jsong), 'w') as f:
json.dump(key_a, f)
sth_w0()

elif fileExist:
with open(cfgpath + jsong, 'r') as f:
with open(os.path.join(cfgpath, jsong), 'r') as f:
key_a = json.load(f)
listen_keypress(key_a)

Expand Down
24 changes: 14 additions & 10 deletions guiscrcpy/lib/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""


import psutil
try:
import psutil
psutil_present = True
except ModuleNotFoundError:
psutil_present = False


def is_running(processName):
# Iterate over the all the running process
for proc in psutil.process_iter():
try:
# Check if process name contains the given name string.
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
if psutil_present:
# Iterate over the all the running process
for proc in psutil.process_iter():
try:
# Check if process name contains the given name string.
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False
2 changes: 2 additions & 0 deletions guiscrcpy/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ def shellify(args):
else:
return shlex.split(args)


_ = shellify


def decode(raw_output):
pass

Expand Down
2 changes: 1 addition & 1 deletion guiscrcpy/lib/ver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""


__version__ = '3.2-raw'
__version__ = '3.4-raw'
import logging
try:
import git
Expand Down
Loading

0 comments on commit fe45e9f

Please sign in to comment.