Пример #1
0
def reload_previous_repodb():
    dirname = os.path.dirname(cst.repos)
    for _file in os.listdir(dirname):
        if _file.startswith("repositorydb") and _file.count(".") == 2:
            shelltools.copy(os.path.join(dirname, _file), cst.repositorydb_path)
            from datetime import datetime
            timestamp = _file.split(".")[-1]
            previous_date = datetime.fromtimestamp(float(timestamp)).strftime('%Y-%m-%d %H:%M:%S')
            out.normal("loading previous database copy: %s" %
                    out.color(previous_date, "red"))
            return
    out.error("no repodb backup found.")
Пример #2
0
def db_backup():
    import time
    from lpms.shelltools import copy, remove_file

    # remove previous database backup
    dirname = os.path.join(cst.root, cst.db_path)
    for _file in os.listdir(dirname):
        if _file.startswith("repositorydb") and _file.count(".") == 2:
            remove_file(os.path.join(dirname, _file))

    # create a backup with UNIX timestamp
    timestamp = int(time.time())
    repositorydb = os.path.join(cst.root, cst.db_path, cst.repositorydb)+cst.db_prefix
    copy(repositorydb, repositorydb+".%s" % timestamp)
Пример #3
0
def reload_previous_repodb():
    dirname = os.path.dirname(cst.repos)
    for _file in os.listdir(dirname):
        if _file.startswith("repositorydb") and _file.count(".") == 2:
            shelltools.copy(os.path.join(dirname, _file),
                            cst.repositorydb_path)
            from datetime import datetime
            timestamp = _file.split(".")[-1]
            previous_date = datetime.fromtimestamp(
                float(timestamp)).strftime('%Y-%m-%d %H:%M:%S')
            out.normal("loading previous database copy: %s" %
                       out.color(previous_date, "red"))
            return
    out.error("no repodb backup found.")
Пример #4
0
def db_backup():
    import time
    from lpms.shelltools import copy, remove_file

    # remove previous database backup
    dirname = os.path.join(cst.root, cst.db_path)
    for _file in os.listdir(dirname):
        if _file.startswith("repositorydb") and _file.count(".") == 2:
            remove_file(os.path.join(dirname, _file))

    # create a backup with UNIX timestamp
    timestamp = int(time.time())
    repositorydb = os.path.join(cst.root, cst.db_path,
                                cst.repositorydb) + cst.db_prefix
    copy(repositorydb, repositorydb + ".%s" % timestamp)
Пример #5
0
def copy(source, target, sym=True):
    source = fix_source_path(source, allowed_paths=[filesdir, src_cache])
    shelltools.copy(source, fix_target_path(target), sym)