summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-03 06:52:42 (GMT)
committerWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-24 10:26:52 (GMT)
commita4bbc44f16e25e1d7a2b6a5f55aad0a02ea12bdb (patch)
tree44198fa91a4da79a99fc5d6f5b5abeafb55eef19
parenta95d3a1263587243a4fb7534f91f8312c748628b (diff)
refactor: create Url.__findServerProgram()
-rw-r--r--src/login.py38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/login.py b/src/login.py
index d459694..d08f4df 100644
--- a/src/login.py
+++ b/src/login.py
@@ -176,25 +176,31 @@ class Url(unicode):
# service we want, so ignore it
return result
+ @staticmethod
+ def __findServerProgram():
+ """how should we start the server?"""
+ args = []
+ serverPython = 'python3' if Options.server3 else 'python'
+ if sys.argv[0].endswith('kajongg.py'):
+ tryServer = sys.argv[0].replace('.py', 'server.py')
+ if os.path.exists(tryServer):
+ args = [serverPython, tryServer]
+ elif sys.argv[0].endswith('kajongg.pyw'):
+ tryServer = sys.argv[0].replace('.pyw', 'server.py')
+ if os.path.exists(tryServer):
+ args = [serverPython, tryServer]
+ elif sys.argv[0].endswith('kajongg.exe'):
+ tryServer = sys.argv[0].replace('.exe', 'server.exe')
+ if os.path.exists(tryServer):
+ args = [tryServer]
+ else:
+ args = ['kajonggserver']
+ return args
+
def __startLocalServer(self):
"""start a local server"""
- # pylint: disable=too-many-branches
- serverPython = 'python3' if Options.server3 else 'python'
try:
- if sys.argv[0].endswith('kajongg.py'):
- tryServer = sys.argv[0].replace('.py', 'server.py')
- if os.path.exists(tryServer):
- args = [serverPython, tryServer]
- elif sys.argv[0].endswith('kajongg.pyw'):
- tryServer = sys.argv[0].replace('.pyw', 'server.py')
- if os.path.exists(tryServer):
- args = [serverPython, tryServer]
- elif sys.argv[0].endswith('kajongg.exe'):
- tryServer = sys.argv[0].replace('.exe', 'server.exe')
- if os.path.exists(tryServer):
- args = [tryServer]
- else:
- args = ['kajonggserver']
+ args = self.__findServerProgram()
if self.useSocket or os.name == 'nt': # for nt --socket tells the server to bind to 127.0.0.1
args.append('--socket=%s' % socketName())
if removeIfExists(socketName()):