<commit_before>import ConfigParser
import os
import subprocess
import sys
import time

runningdir = os.path.split(os.path.abspath(os.path.realpath(sys.argv[0])))[0]


def restart():
    time.sleep(4)
    execfile(os.path.join(runningdir, 'premiumizer.py'), globals(), globals())


def update():
    del sys.argv[1:]
    time.sleep(2)
    subprocess.call(['git', '-C', os.path.join(runningdir, 'nzbtomedia'), 'pull'])
    subprocess.call(['git', '-C', runningdir, 'pull'])

    prem_config = ConfigParser.RawConfigParser()
    default_config = ConfigParser.RawConfigParser()
    prem_config.read(os.path.join(runningdir, 'settings.cfg'))
    default_config.read(os.path.join(runningdir, 'settings.cfg.tpl'))

    prem_config.set('update', 'updated', '1')
    with open(os.path.join(runningdir, 'settings.cfg'), 'w') as configfile:
        prem_config.write(configfile)
    if prem_config.getfloat('update', 'req_version') < default_config.getfloat('update', 'req_version'):
        import pip
        pip.main(['install', '-r', os.path.join(runningdir, 'requirements.txt')])
        prem_config.set('update', 'req_version', (default_config.getfloat('update', 'req_version')))
        with open(os.path.join(runningdir, 'settings.cfg'), 'w') as configfile:
            prem_config.write(configfile)
    if prem_config.getfloat('update', 'config_version') < default_config.getfloat('update', 'config_version'):<commit_msg>add basic logger to utils.py output > update.log<commit_after>import ConfigParser
import logging
import os
import subprocess
import sys
import time

# logging
log_format = '%(asctime)-20s %(name)-41s: %(levelname)-8s : %(message)s'
logging.basicConfig(filename='update.log', level=logging.DEBUG, format=log_format, datefmt='%m-%d %H:%M:%S')


def uncaught_exception(exc_type, exc_value, exc_traceback):
    if issubclass(exc_type, (SystemExit, KeyboardInterrupt)):
        return
    logging.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback))
    pass


sys.excepthook = uncaught_exception

runningdir = os.path.split(os.path.abspath(os.path.realpath(sys.argv[0])))[0]
logging.debug('runningdir = %s', runningdir)


def restart():
    time.sleep(4)
    execfile(os.path.join(runningdir, 'premiumizer.py'), globals(), globals())


def update():
    del sys.argv[1:]
    time.sleep(2)
    subprocess.call(['git', '-C', os.path.join(runningdir, 'nzbtomedia'), 'pull'])
    subprocess.call(['git', '-C', runningdir, 'pull'])

    prem_config = ConfigParser.RawConfigParser()
    default_config = ConfigParser.RawConfigParser()
    prem_config.read(os.path.join(runningdir, 'settings.cfg'))
    default_config.read(os.path.join(runningdir, 'settings.cfg.tpl'))

    prem_config.set('update', 'updated', '1')
    with open(os.path.join(runningdir, 'settings.cfg'), 'w') as configfile:
        prem_config.write(configfile)
    if prem_config.getfloat('update', 'req_version') < default_config.getfloat('update', 'req_version'):
        import pip
        pip.main(['install', '-r', os.path.join(runningdir, 'requirements.txt')])
        prem_config.set('update', 'req_version', (default_config.getfloat('update', 'req_version')))
        with open(os.path.join(runningdir, 'settings.cfg'), 'w') as configfile:
            prem_config.write(configfile)
    if prem_config.getfloat('update', 'config_version') < default_config.getfloat('update', 'config_version'):
{'fraction_non_alphanumeric': 0.16563695204471904, 'fraction_numerical': 0.005001471020888497, 'mean_word_length': 4.892547660311958, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6656171', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1109, 'n_words': 194}