def replaceWith(self, path): path = sp(path) app_dir = Env.get('app_dir') data_dir = Env.get('data_dir') # Get list of files we want to overwrite removePyc(app_dir) existing_files = [] for root, subfiles, filenames in os.walk(app_dir): for filename in filenames: existing_files.append(os.path.join(root, filename)) for root, subfiles, filenames in os.walk(path): for filename in filenames: fromfile = os.path.join(root, filename) tofile = os.path.join(app_dir, fromfile.replace(path + os.path.sep, '')) if not Env.get('dev'): try: if os.path.isfile(tofile): os.remove(tofile) dirname = os.path.dirname(tofile) if not os.path.isdir(dirname): self.makeDir(dirname) shutil.move(fromfile, tofile) try: existing_files.remove(tofile) except ValueError: pass except: log.error('Failed overwriting file "%s": %s', (tofile, traceback.format_exc())) return False for still_exists in existing_files: if data_dir in still_exists: continue try: os.remove(still_exists) except: log.error('Failed removing non-used file: %s', traceback.format_exc()) return True
def doShutdown(self, *args, **kwargs): if not Env.get('dev') and not Env.get('desktop'): removePyc(Env.get('app_dir'), show_logs = False) return super(Updater, self).doShutdown(*args, **kwargs)
def doShutdown(self, *args, **kwargs): if not Env.get('dev') and not Env.get('desktop'): removePyc(Env.get('app_dir'), show_logs=False) return super(Updater, self).doShutdown(*args, **kwargs)
import subprocess import sys import traceback # Root path base_path = dirname(os.path.abspath(__file__)) # Insert local directories into path sys.path.insert(0, os.path.join(base_path, 'libs')) from couchpotato.environment import Env from couchpotato.core.helpers.variable import getDataDir, removePyc # Remove pyc files before dynamic load (sees .pyc files regular .py modules) removePyc(base_path) class Loader(object): do_restart = False def __init__(self): # Get options via arg from couchpotato.runner import getOptions self.options = getOptions(sys.argv[1:]) # Load settings settings = Env.get('settings') settings.setFile(self.options.config_file)
import sys import traceback import time # Root path base_path = dirname(os.path.abspath(__file__)) # Insert local directories into path sys.path.insert(0, os.path.join(base_path, 'libs')) from couchpotato.environment import Env from couchpotato.core.helpers.variable import getDataDir, removePyc # Remove pyc files before dynamic load (sees .pyc files regular .py modules) removePyc(base_path) class Loader(object): do_restart = False def __init__(self): # Get options via arg from couchpotato.runner import getOptions self.options = getOptions(sys.argv[1:]) # Load settings settings = Env.get('settings') settings.setFile(self.options.config_file)