From 74af3025f57d1b84e9f74d2442216087d0cd7774 Mon Sep 17 00:00:00 2001 From: marcelveldt Date: Wed, 16 Oct 2019 08:42:25 +0200 Subject: [PATCH] Update mass.py --- mass.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mass.py b/mass.py index 5fd436df..dd6ac694 100755 --- a/mass.py +++ b/mass.py @@ -31,39 +31,41 @@ def get_config(): if os.environ.get('mass_datadir'): data_dir = os.environ['mass_datadir'] if os.environ.get('mass_debug'): - debug = os.environ['mass_datadir'].lower() != 'false' + debug = os.environ['mass_debug'].lower() != 'false' if os.environ.get('mass_update'): update_latest = os.environ['mass_update'].lower() != 'false' # config file found - if os.path.isfile('options.json'): + base_dir = os.path.dirname(os.path.abspath(__file__)) + conf_file = os.path.join(base_dir, 'options.json') + if os.path.isfile(conf_file): try: import json - with open('options.json') as f: + with open(conf_file) as f: conf = json.loads(f.read()) data_dir = conf['data_dir'] debug = conf['debug_messages'] - update_latest = conf['auto_update'] + update_latest = conf['use_nightly'] except: logger.exception('could not load options.json') return data_dir, debug, update_latest def do_update(): ''' auto update to latest git version ''' - if os.path.isdir(".git"): + base_dir = os.path.dirname(os.path.abspath(__file__)) + if os.path.isdir(".git") or os.path.isdir("%s/.git" % base_dir): # dev environment return logger.info("Updating to latest Git version!") import subprocess # TODO: handle this properly args = """ - cd /tmp + cd %s curl -LOks "https://github.com/marcelveldt/musicassistant/archive/master.zip" unzip -q master.zip - rm -R music_assistant cp -rf musicassistant-master/music_assistant . cp -rf musicassistant-master/mass.py . - rm -R /tmp/musicassistant-master - """ + rm -R musicassistant-master + """ % (base_dir, ) if subprocess.call(args, shell=True) == 0: logger.info("Update succesfull") else: -- 2.34.1