def configure_updates(): global AUTO_UPDATE global MYAPP AUTO_UPDATE = int(CFG['General']['auto_update']) version_checker = version_check.CheckVersion() # Check for updates via GitHUB if version_checker.check_for_new_version() and AUTO_UPDATE: logger.info('Auto-Updating nzbToMedia, Please wait ...') if version_checker.update(): # restart nzbToMedia try: del MYAPP except Exception: pass restart() else: logger.error( 'Update failed, not restarting. Check your log for more information.' ) # Set Current Version logger.info( 'nzbToMedia Version:{version} Branch:{branch} ({system} {release})'. format(version=NZBTOMEDIA_VERSION, branch=GIT_BRANCH, system=platform.system(), release=platform.release()))
def restart(): install_type = version_check.CheckVersion().install_type status = 0 popen_list = [] if install_type in ('git', 'source'): popen_list = [sys.executable, APP_FILENAME] if popen_list: popen_list += SYS_ARGV logger.log(u'Restarting nzbToMedia with {args}'.format(args=popen_list)) logger.close() p = subprocess.Popen(popen_list, cwd=os.getcwd()) p.wait() status = p.returncode os._exit(status)