Beispiel #1
0
def data_paths(request):
    def clean_dirs():
        shutil.rmtree('/tmp/data1')
        os.unlink('/tmp/data2')

    try:
        clean_dirs()
    except Exception:
        ...

    now = datetime.datetime.now()

    for year_offset in [-1, 0, 1]:
        make_dir_tree(now.year + year_offset, base_path='/tmp/data1')

    os.symlink('/tmp/data1', '/tmp/data2')
    request.addfinalizer(clean_dirs)
Beispiel #2
0
def data_paths(request):
    def clean_dirs():
        shutil.rmtree('/tmp/data1')
        os.unlink('/tmp/data2')

    try:
        clean_dirs()
    except Exception:
        ...

    now = datetime.datetime.now()

    for year_offset in [-1, 0, 1]:
        make_dir_tree(now.year + year_offset,
                      base_path='/tmp/data1')

    os.symlink('/tmp/data1', '/tmp/data2')
    request.addfinalizer(clean_dirs)
def main(args):
    base_path = args[1]  # e.g. "/tmp/data"
    now = datetime.datetime.now()
    # Make YYYY/MM/DD/ directories for last year, this year, next year.
    for offset in (-1, 0, 1):
        make_dir_tree(now.year + offset, base_path=base_path)