Example #1
0
def autoupdate():
    if not os.path.exists(HON_SETTINGS_PATH):
        mkdir_p(HON_SETTINGS_PATH)
    verpath = os.path.join(HON_SETTINGS_PATH, 'theli_launcher_version')
    try:
        import json
    except:
        print('You have too old python version, no autoupdate possible')
        return
    try:
        if os.path.exists(verpath):
            current_version = open(verpath).read()
        else:
            current_version = None
        latest_version = json.loads(
            urlopen(
                'https://api.github.com/repos/theli-ua/garenahon/commits?sha=master&per_page=1'
            ).read().decode('utf8'))[0]['sha']
    except:
        print('Failed to read current and latest versions')
        if hasattr(sys, 'exc_type'):
            debug(sys.exc_type, sys.exc_value)
            debug(sys.exc_traceback)
            debug(sys.exc_info())
        else:
            debug(sys.exc_info())
        return
    print('Current version\n\t')
    print(current_version)
    print('Latest version\n\t')
    print(latest_version)
    if current_version == latest_version:
        print('Already up to date, nothing to update')
        return
    print('Downloading latest version')
    try:
        import tarfile, shutil
        from cStringIO import StringIO
        launcher = StringIO(
            urlopen(
                'https://github.com/theli-ua/garenahon/archive/master.tar.gz').
            read())
        launcher = tarfile.open(fileobj=launcher, mode='r')
        launcher.extractall()
        for f in os.listdir('garenahon-master'):
            shutil.copy(os.path.join('garenahon-master', f), './')
        shutil.rmtree('garenahon-master')
    except:
        print('Failed to download and/or extract latest launcher version')
        return
    f = open(verpath, 'w')
    f.write(latest_version)
    f.close()
    print('Updated successfully\nPlease, restart!')
    show_message('Launcher Updated\nPlease, restart!')
    sys.exit(2)
Example #2
0
def autoupdate():
    if not os.path.exists(HON_SETTINGS_PATH):
        mkdir_p(HON_SETTINGS_PATH)
    verpath = os.path.join(HON_SETTINGS_PATH, "theli_launcher_version")
    try:
        import json
    except:
        print ("You have too old python version, no autoupdate possible")
        return
    try:
        if os.path.exists(verpath):
            current_version = open(verpath).read()
        else:
            current_version = None
        latest_version = json.loads(
            urlopen("https://api.github.com/repos/theli-ua/garenahon/commits?sha=master&per_page=1")
            .read()
            .decode("utf8")
        )[0]["sha"]
    except:
        print ("Failed to read current and latest versions")
        if hasattr(sys, "exc_type"):
            debug(sys.exc_type, sys.exc_value)
            debug(sys.exc_traceback)
            debug(sys.exc_info())
        else:
            debug(sys.exc_info())
        return
    print ("Current version\n\t")
    print (current_version)
    print ("Latest version\n\t")
    print (latest_version)
    if current_version == latest_version:
        print ("Already up to date, nothing to update")
        return
    print ("Downloading latest version")
    try:
        import tarfile, shutil
        from cStringIO import StringIO

        launcher = StringIO(urlopen("https://github.com/theli-ua/garenahon/archive/master.tar.gz").read())
        launcher = tarfile.open(fileobj=launcher, mode="r")
        launcher.extractall()
        for f in os.listdir("garenahon-master"):
            shutil.copy(os.path.join("garenahon-master", f), "./")
        shutil.rmtree("garenahon-master")
    except:
        print ("Failed to download and/or extract latest launcher version")
        return
    f = open(verpath, "w")
    f.write(latest_version)
    f.close()
    print ("Updated successfully\nPlease, restart!")
    show_message("Launcher Updated\nPlease, restart!")
    sys.exit(2)
Example #3
0
def autoupdate():
    if not os.path.exists(HON_SETTINGS_PATH):
        mkdir_p(HON_SETTINGS_PATH)
    verpath = os.path.join(HON_SETTINGS_PATH,'theli_launcher_version')
    try:import json
    except:
        print('You have too old python version, no autoupdate possible')
        return
    try:
        if os.path.exists(verpath):
            current_version = open(verpath).read()
        else:
            current_version = None
        latest_version = json.loads(urlopen('https://api.github.com/repos/theli-ua/garenahon/commits?sha=master&per_page=1').read().decode('utf8'))[0]['sha']
    except:
        print('Failed to read current and latest versions')
        if hasattr(sys, 'exc_type'):
            debug(sys.exc_type,sys.exc_value)
            debug(sys.exc_traceback)
            debug(sys.exc_info())
        else:
            debug(sys.exc_info())
        return
    print('Current version\n\t')
    print(current_version)
    print('Latest version\n\t')
    print(latest_version)
    if current_version == latest_version :
        print ('Already up to date, nothing to update')
        return
    print('Downloading latest version')
    try:
        import tarfile,shutil
        from cStringIO import StringIO
        launcher = StringIO(urlopen('https://github.com/theli-ua/garenahon/archive/master.tar.gz').read())
        launcher = tarfile.open(fileobj=launcher,mode='r')
        launcher.extractall()
        for f in os.listdir('garenahon-master'):
            shutil.copy(os.path.join('garenahon-master',f),'./')
        shutil.rmtree('garenahon-master')
    except:
        print('Failed to download and/or extract latest launcher version')
        return
    f = open(verpath,'w')
    f.write(latest_version)
    f.close()
    print('Updated successfully\nPlease, restart!')
    show_message('Launcher Updated\nPlease, restart!')
    sys.exit(2)