From 3b2b658881684cda271efd7c6cdbce0e36effdcd Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 22 Jan 2021 12:47:38 +0000 Subject: [PATCH] Add `--force-localserver-for-auth` CL arg to EDMarketConnector --- EDMarketConnector.py | 8 ++++++++ config.py | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index eb9b81eb..5b2ac883 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -55,6 +55,11 @@ if __name__ == '__main__': # noqa: C901 action='store_true' ) + parser.add_argument('--force-localserver-for-auth', + help='Force EDMC to use a localhost webserver for Frontier Auth callback', + action='store_true' + ) + args = parser.parse_args() if args.trace: @@ -63,6 +68,9 @@ if __name__ == '__main__': # noqa: C901 else: edmclogger.set_channels_loglevel(logging.DEBUG) + if args.force_localserver_for_auth: + config.set_auth_force_localserver() + def no_other_instance_running() -> bool: # noqa: CCR001 """ Ensure only one copy of the app is running for the configured journal directory. diff --git a/config.py b/config.py index 7d077d2b..d9ac1099 100644 --- a/config.py +++ b/config.py @@ -118,6 +118,7 @@ class Config(object): def __init__(self): self.__in_shutdown = False # Is the application currently shutting down ? + self.__auth_force_localserver = False # Should we use localhost for auth callback ? self.app_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], appname) if not isdir(self.app_dir): @@ -186,10 +187,18 @@ class Config(object): def shutting_down(self) -> bool: return self.__in_shutdown + def set_auth_force_localserver(self): + self.__auth_force_localserver = True + + @property + def auth_force_localserver(self) -> bool: + return self.__auth_force_localserver + elif platform=='win32': def __init__(self): self.__in_shutdown = False # Is the application currently shutting down ? + self.__auth_force_localserver = False # Should we use localhost for auth callback ? self.app_dir = join(KnownFolderPath(FOLDERID_LocalAppData), appname) if not isdir(self.app_dir): @@ -285,12 +294,20 @@ class Config(object): def shutting_down(self) -> bool: return self.__in_shutdown + def set_auth_force_localserver(self): + self.__auth_force_localserver = True + + @property + def auth_force_localserver(self) -> bool: + return self.__auth_force_localserver + elif platform=='linux': SECTION = 'config' def __init__(self): self.__in_shutdown = False # Is the application currently shutting down ? + self.__auth_force_localserver = False # Should we use localhost for auth callback ? # http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html self.app_dir = join(getenv('XDG_DATA_HOME', expanduser('~/.local/share')), appname) @@ -371,6 +388,13 @@ class Config(object): def shutting_down(self) -> bool: return self.__in_shutdown + def set_auth_force_localserver(self): + self.__auth_force_localserver = True + + @property + def auth_force_localserver(self) -> bool: + return self.__auth_force_localserver + def _escape(self, val): return str(val).replace(u'\\', u'\\\\').replace(u'\n', u'\\n').replace(u';', u'\\;')