1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-16 09:10:35 +03:00

EDMarketConnector: Improve 'develop only for devs' check

* Move it later, after CLI args processing.  This would allow for a magic
  'override' this, providing a key or similar.
* Correct text 'XAthan' to 'Athan' in 'win32' check.
* If `git_branch != 'develop'` check if `-alpha0` is in the app version.
  Such version strings are never in any pre-release or release.
This commit is contained in:
Athanasius 2022-12-08 10:49:35 +00:00
parent 0d65adb77e
commit 0523e2289a
No known key found for this signature in database
GPG Key ID: 772697E181BB2767

View File

@ -49,39 +49,6 @@ if __name__ == '__main__':
sys.stdout = sys.stderr = open(join(tempfile.gettempdir(), f'{appname}.log'), mode='wt', buffering=1)
# TODO: Test: Make *sure* this redirect is working, else py2exe is going to cause an exit popup
try:
import subprocess
git_cmd = subprocess.Popen('git branch --show-current'.split(),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
out, err = git_cmd.communicate()
git_branch = out.decode().rstrip('\n')
if (
git_branch == 'develop'
and (
(
sys.platform == 'linux'
and environ.get('USER') is not None
and environ['USER'] not in ['ad', 'athan']
)
or (
sys.platform == 'win32'
and environ.get('USERNAME') is not None
and environ['USERNAME'] not in ['XAthan']
)
)
):
print("Why are you running the develop branch if you're not a developer?")
print("Please check https://github.com/EDCD/EDMarketConnector/wiki/Running-from-source#running-from-source")
print("You probably want the 'stable' branch.")
print("\n\rIf Athanasius or A_D asked you to run this, tell them about this message.")
sys.exit(-1)
except Exception:
pass
# These need to be after the stdout/err redirect because they will cause
# logging to be set up.
@ -399,6 +366,42 @@ if __name__ == '__main__': # noqa: C901
sys.stdout.seek(0)
sys.stdout.truncate()
git_branch = ""
try:
import subprocess
git_cmd = subprocess.Popen('git branch --show-current'.split(),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
out, err = git_cmd.communicate()
git_branch = out.decode().rstrip('\n')
except Exception:
pass
if (
(
git_branch == 'develop'
or '-alpha0' in str(appversion())
) and (
(
sys.platform == 'linux'
and environ.get('USER') is not None
and environ['USER'] not in ['ad', 'athan']
)
or (
sys.platform == 'win32'
and environ.get('USERNAME') is not None
and environ['USERNAME'] not in ['Athan']
)
)
):
print("Why are you running the develop branch if you're not a developer?")
print("Please check https://github.com/EDCD/EDMarketConnector/wiki/Running-from-source#running-from-source")
print("You probably want the 'stable' branch.")
print("\n\rIf Athanasius or A_D asked you to run this, tell them about this message.")
sys.exit(-1)
# See EDMCLogging.py docs.
# isort: off