コード例 #1
0
def test_decider(testcase, em):
    """
	Adds a new backup every day of 2015, checks list of backups
	2nd of each month.
	"""
    decider = Decider(em, {
        'monthly': 2,
        'weekly': 3,
        'daily': 5,
    })
    d = date(2015, 1, 1)
    while True:
        #print('-->', d)
        # add entry
        stamp = 'daily'
        if d.isoweekday() == 1: stamp = 'weekly'
        if d.day == 1: stamp = 'monthly'
        stamp = str(d.year) + str(d.month).zfill(2) + str(
            d.day).zfill(2) + '-2330-' + stamp
        em._add(stamp)
        decider.execute()

        # if we're on checkpoint, compare
        if d.day == 2:
            testcase.assertEqual(em.list(), expected_results[d.month])

        # ok, go next
        d += timedelta(days=1)
        if d > date(2015, 12, 31):
            break
コード例 #2
0
ファイル: main.py プロジェクト: m1kc/plasma-backup
def main():
    print("Plasma 1.0")
    print("- written by m1kc")
    print("- https://github.com/m1kc/plasma-backup")
    print("- licensed under GNU GPL v3")
    print("")
    print("THIS SOFTWARE IS STILL EXPERIMENTAL.")
    print("USE AT YOUR OWN RISK.")
    print("")

    path = sys.argv[1]

    print("Rotating entries in:", path)

    config = load_json(os.path.join(path, FILENAME))
    em = EntryManagerFilesystem(path)
    d = Decider(em, config['policy'])

    print("Entries exist:", len(em.list()))
    d.execute()

    print("Everything's fine, exiting.")