<commit_before>
import logging
import traceback

log = logging.getLogger("R.Update")

def getVersion():
    return _versionStringToTuple(open("arche/version.txt", "r").read())

def _versionStringToTuple(versionString):
    return tuple([int(i) for i in versionString.split(".")])

def getLatestVersion():
    url = "https://raw.githubusercontent.com/omegachysis/arche-engine/master/arche/version.txt"
    import urllib.request
    response = urllib.request.urlopen(url)
    versionString = str(response.read())[2:-1]
    return _versionStringToTuple(versionString)

def canUpdate():
    return getVersion()[0:2]!=getLatestVersion()[0:2]

def update():
    tagName = "v" + ".".join([str(i) for i in getLatestVersion()[0:2]])
    try:
        url = "https://github.com/omegachysis/arche-engine/archive/" + tagName + ".zip"
        log.info("Downloading release package %s"%(url))
        import urllib.request
        response = urllib.request.urlopen(url)
        file = open("release " + tagName + ".zip", "wb")
        file.write(response.read())
        file.close()
    except:
        log.warn("Downloading of release package %s failed!"%(tagName))
        log.warn("The engine reported the following download error: ")
        log.warn(traceback.format_exc())<commit_msg>Included bad update files<commit_after>
import logging
import traceback

log = logging.getLogger("R.Update")

def getVersion():
    return _versionStringToTuple(open("arche/version.txt", "r").read())

def _versionStringToTuple(versionString):
    return tuple([int(i) for i in versionString.split(".")])

def getLatestVersion():
    url = "https://raw.githubusercontent.com/omegachysis/arche-engine/master/arche/version.txt"
    import urllib.request
    response = urllib.request.urlopen(url)
    versionString = str(response.read())[2:-1]
    return _versionStringToTuple(versionString)

def canUpdate():
    return getVersion()[0:2]!=getLatestVersion()[0:2]

def update():
    tagName = "v" + ".".join([str(i) for i in getLatestVersion()[0:2]])
    try:
        url = "https://github.com/omegachysis/arche-engine/archive/" + tagName + ".zip"
        log.info("Downloading release package %s"%(url))
        import urllib.request
        response = urllib.request.urlopen(url)
        from os import mkdir
        from os import path
        if not path.exists("_updatePackages/"):
            mkdir("_updatePackages/")
        file = open("_updatePackages/" + updateFilename, "wb")
        file.write(response.read())
        file.close()
        log.info("Download complete!")
    except:
        log.error("Updating of release package %s failed!"%(tagName))
        log.error("The engine reported the following update error: ")
        log.error(traceback.format_exc())
##        import zipfile
##        log.info("Extracting release contents...")
##        with zipfile.ZipFile("_updatePackages/" + updateFilename, "r") as z:
##            z.extractall("_updatePackages/")
##        log.info("Extracted release contents!")
##        log.info("Backing up current installation...")
##        from shutil import copytree
##        from shutil import rmtree
##        rmtree("_updateBackup/", True)
##        copytree(".", "_updateBackup/")
##        log.info("Installing update...")
##        rmtree(".", True)
##        copytree("_updatePackages/{}/".format(releasePackageName), ".")
##        log.info("Update installed!")
##    except:
##        log.error("Updating of release package %s failed!"%(tagName))
##        log.error("The engine reported the following update error: ")
##        log.error(traceback.format_exc())
{'fraction_non_alphanumeric': 0.1522884882108183, 'fraction_numerical': 0.004438280166435506, 'mean_word_length': 3.3289315726290516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3548407', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1093, 'n_words': 228}