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

Commit

Permalink
Fix configuration break on guiscrcpy appimage due to caching of AppIm…
Browse files Browse the repository at this point in the history
…age temp paths
  • Loading branch information
srevinsaju committed Sep 7, 2020
1 parent dfee20b commit a27b0dd
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions guiscrcpy/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
from guiscrcpy.platform import platform


class InvalidConfigurationError(RuntimeError):
pass


class InterfaceConfig:
def __init__(self):
"""
Expand Down Expand Up @@ -62,13 +66,35 @@ def validate(self):
# 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:
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']
Expand Down Expand Up @@ -113,11 +139,6 @@ def check_file(self):
if not os.path.exists(self.cfgpath):
os.makedirs(self.cfgpath)
if not os.path.exists(os.path.join(self.cfgpath, self.json_file)):
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

0 comments on commit a27b0dd

Please sign in to comment.