1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-15 08:40:34 +03:00

EDMarketConnector: Only developers should be running develop

This commit is contained in:
Athanasius 2022-12-07 19:45:55 +00:00
parent 410b52979b
commit a69b271928
No known key found for this signature in database
GPG Key ID: 772697E181BB2767

View File

@ -49,6 +49,37 @@ 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?")
sys.exit(-1)
except Exception:
pass
# These need to be after the stdout/err redirect because they will cause
# logging to be set up.
# isort: off