1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-20 16:54:31 +03:00

Add --force-localserver-for-auth CL arg to EDMarketConnector

This commit is contained in:
Athanasius 2021-01-22 12:47:38 +00:00
parent 11b1c436a7
commit 3b2b658881
2 changed files with 32 additions and 0 deletions

View File

@ -55,6 +55,11 @@ if __name__ == '__main__': # noqa: C901
action='store_true' 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() args = parser.parse_args()
if args.trace: if args.trace:
@ -63,6 +68,9 @@ if __name__ == '__main__': # noqa: C901
else: else:
edmclogger.set_channels_loglevel(logging.DEBUG) 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 def no_other_instance_running() -> bool: # noqa: CCR001
""" """
Ensure only one copy of the app is running for the configured journal directory. Ensure only one copy of the app is running for the configured journal directory.

View File

@ -118,6 +118,7 @@ class Config(object):
def __init__(self): def __init__(self):
self.__in_shutdown = False # Is the application currently shutting down ? 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) self.app_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], appname)
if not isdir(self.app_dir): if not isdir(self.app_dir):
@ -186,10 +187,18 @@ class Config(object):
def shutting_down(self) -> bool: def shutting_down(self) -> bool:
return self.__in_shutdown 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': elif platform=='win32':
def __init__(self): def __init__(self):
self.__in_shutdown = False # Is the application currently shutting down ? 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) self.app_dir = join(KnownFolderPath(FOLDERID_LocalAppData), appname)
if not isdir(self.app_dir): if not isdir(self.app_dir):
@ -285,12 +294,20 @@ class Config(object):
def shutting_down(self) -> bool: def shutting_down(self) -> bool:
return self.__in_shutdown 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': elif platform=='linux':
SECTION = 'config' SECTION = 'config'
def __init__(self): def __init__(self):
self.__in_shutdown = False # Is the application currently shutting down ? 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 # http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html
self.app_dir = join(getenv('XDG_DATA_HOME', expanduser('~/.local/share')), appname) self.app_dir = join(getenv('XDG_DATA_HOME', expanduser('~/.local/share')), appname)
@ -371,6 +388,13 @@ class Config(object):
def shutting_down(self) -> bool: def shutting_down(self) -> bool:
return self.__in_shutdown 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): def _escape(self, val):
return str(val).replace(u'\\', u'\\\\').replace(u'\n', u'\\n').replace(u';', u'\\;') return str(val).replace(u'\\', u'\\\\').replace(u'\n', u'\\n').replace(u';', u'\\;')