Пример #1
0
 def test_list_valid(self):
     l1 = snapshots.listSnapshots(self.cfg)
     self.assertListEqual(l1, ['20151219-040324-123',
                               '20151219-030324-123',
                               '20151219-020324-123',
                               '20151219-010324-123'])
     self.assertIsInstance(l1[0], snapshots.SID)
Пример #2
0
 def test_list_without_new_snapshot(self):
     os.makedirs(os.path.join(self.snapshotPath, 'new_snapshot', 'backup'))
     l5 = snapshots.listSnapshots(self.cfg, includeNewSnapshot = False)
     self.assertListEqual(l5, ['20151219-040324-123',
                               '20151219-030324-123',
                               '20151219-020324-123',
                               '20151219-010324-123'])
Пример #3
0
 def test_list_valid(self):
     l1 = snapshots.listSnapshots(self.cfg)
     self.assertListEqual(l1, [
         '20151219-040324-123', '20151219-030324-123',
         '20151219-020324-123', '20151219-010324-123'
     ])
     self.assertIsInstance(l1[0], snapshots.SID)
Пример #4
0
 def test_list_without_new_snapshot(self):
     os.makedirs(os.path.join(self.snapshotPath, 'new_snapshot', 'backup'))
     l5 = snapshots.listSnapshots(self.cfg, includeNewSnapshot=False)
     self.assertListEqual(l5, [
         '20151219-040324-123', '20151219-030324-123',
         '20151219-020324-123', '20151219-010324-123'
     ])
Пример #5
0
def snapshotsListPath(args):
    """
    Command for printing a list of all snapshots pathes in current profile.

    Args:
        args (argparse.Namespace):
                        previously parsed arguments

    Raises:
        SystemExit:     0
    """
    force_stdout = setQuiet(args)
    cfg = getConfig(args)
    _mount(cfg)

    if args.quiet:
        msg = '{}'
    else:
        msg = 'SnapshotPath: {}'
    no_sids = True
    #use snapshots.listSnapshots instead of iterSnapshots because of sorting
    for sid in snapshots.listSnapshots(cfg, reverse = False):
        print(msg.format(sid.path()), file=force_stdout)
        no_sids = False
    if no_sids:
        logger.error("There are no snapshots in '%s'" % cfg.profileName())
    if not args.keep_mount:
        _umount(cfg)
    sys.exit(RETURN_OK)
Пример #6
0
def snapshotsListPath(args):
    """
    Command for printing a list of all snapshots pathes in current profile.

    Args:
        args (argparse.Namespace):
                        previously parsed arguments

    Raises:
        SystemExit:     0
    """
    force_stdout = setQuiet(args)
    cfg = getConfig(args)
    _mount(cfg)

    if args.quiet:
        msg = '{}'
    else:
        msg = 'SnapshotPath: {}'
    no_sids = True
    #use snapshots.listSnapshots instead of iterSnapshots because of sorting
    for sid in snapshots.listSnapshots(cfg, reverse=False):
        print(msg.format(sid.path()), file=force_stdout)
        no_sids = False
    if no_sids:
        logger.error("There are no snapshots in '%s'" % cfg.profileName())
    if not args.keep_mount:
        _umount(cfg)
    sys.exit(RETURN_OK)
Пример #7
0
 def test_list_symlink_last_snapshot(self):
     os.symlink('./20151219-040324-123',
                os.path.join(self.snapshotPath, 'last_snapshot'))
     l6 = snapshots.listSnapshots(self.cfg)
     self.assertListEqual(l6, ['20151219-040324-123',
                               '20151219-030324-123',
                               '20151219-020324-123',
                               '20151219-010324-123'])
Пример #8
0
 def test_list_symlink_last_snapshot(self):
     os.symlink('./20151219-040324-123',
                os.path.join(self.snapshotPath, 'last_snapshot'))
     l6 = snapshots.listSnapshots(self.cfg)
     self.assertListEqual(l6, [
         '20151219-040324-123', '20151219-030324-123',
         '20151219-020324-123', '20151219-010324-123'
     ])
Пример #9
0
 def test_list_snapshot_without_backup(self):
     #new snapshot without backup folder shouldn't be added
     os.makedirs(os.path.join(self.snapshotPath, '20151219-050324-123'))
     l3 = snapshots.listSnapshots(self.cfg)
     self.assertListEqual(l3, ['20151219-040324-123',
                               '20151219-030324-123',
                               '20151219-020324-123',
                               '20151219-010324-123'])
Пример #10
0
 def test_list_snapshot_without_backup(self):
     #new snapshot without backup folder shouldn't be added
     os.makedirs(os.path.join(self.snapshotPath, '20151219-050324-123'))
     l3 = snapshots.listSnapshots(self.cfg)
     self.assertListEqual(l3, [
         '20151219-040324-123', '20151219-030324-123',
         '20151219-020324-123', '20151219-010324-123'
     ])
Пример #11
0
 def test_list_new_snapshot(self):
     os.makedirs(os.path.join(self.snapshotPath, 'new_snapshot', 'backup'))
     l2 = snapshots.listSnapshots(self.cfg, includeNewSnapshot=True)
     self.assertListEqual(l2, [
         'new_snapshot', '20151219-040324-123', '20151219-030324-123',
         '20151219-020324-123', '20151219-010324-123'
     ])
     self.assertIsInstance(l2[0], snapshots.NewSnapshot)
     self.assertIsInstance(l2[-1], snapshots.SID)
Пример #12
0
 def test_list_invalid_snapshot(self):
     #invalid snapshot shouldn't be added
     os.makedirs(
         os.path.join(self.snapshotPath, '20151219-000324-abc', 'backup'))
     l4 = snapshots.listSnapshots(self.cfg)
     self.assertListEqual(l4, [
         '20151219-040324-123', '20151219-030324-123',
         '20151219-020324-123', '20151219-010324-123'
     ])
Пример #13
0
 def test_list_new_snapshot(self):
     os.makedirs(os.path.join(self.snapshotPath, 'new_snapshot', 'backup'))
     l2 = snapshots.listSnapshots(self.cfg, includeNewSnapshot=True)
     self.assertListEqual(l2, [
         'new_snapshot', '20151219-040324-123', '20151219-030324-123',
         '20151219-020324-123', '20151219-010324-123'
     ])
     self.assertIsInstance(l2[0], snapshots.NewSnapshot)
     self.assertIsInstance(l2[-1], snapshots.SID)
Пример #14
0
 def test_list_invalid_snapshot(self):
     #invalid snapshot shouldn't be added
     os.makedirs(
         os.path.join(self.snapshotPath, '20151219-000324-abc', 'backup'))
     l4 = snapshots.listSnapshots(self.cfg)
     self.assertListEqual(l4, [
         '20151219-040324-123', '20151219-030324-123',
         '20151219-020324-123', '20151219-010324-123'
     ])
Пример #15
0
 def test_list_not_reverse(self):
     os.makedirs(os.path.join(self.snapshotPath, 'new_snapshot', 'backup'))
     l7 = snapshots.listSnapshots(
         self.cfg, includeNewSnapshot=True, reverse=False)
     self.assertListEqual(l7, [
         '20151219-010324-123', '20151219-020324-123',
         '20151219-030324-123', '20151219-040324-123', 'new_snapshot'
     ])
     self.assertIsInstance(l7[0], snapshots.SID)
     self.assertIsInstance(l7[-1], snapshots.NewSnapshot)
Пример #16
0
 def test_list_not_reverse(self):
     os.makedirs(os.path.join(self.snapshotPath, 'new_snapshot', 'backup'))
     l7 = snapshots.listSnapshots(self.cfg,
                                  includeNewSnapshot=True,
                                  reverse=False)
     self.assertListEqual(l7, [
         '20151219-010324-123', '20151219-020324-123',
         '20151219-030324-123', '20151219-040324-123', 'new_snapshot'
     ])
     self.assertIsInstance(l7[0], snapshots.SID)
     self.assertIsInstance(l7[-1], snapshots.NewSnapshot)
Пример #17
0
def remove(cfg, snapshot_ids = None, force = None):
    snapshots_list = snapshots.listSnapshots(cfg)
    if not snapshot_ids:
        snapshot_ids = (None,)
    sids = [selectSnapshot(snapshots_list, sid, 'SnapshotID to remove') for sid in snapshot_ids]

    if not force:
        print('Do you really want to remove this snapshots?')
        [print(sid.displayName) for sid in sids]
        if not 'yes' == input('(no/yes): '):
            return

    s = snapshots.Snapshots(cfg)
    [s.remove_snapshot(sid) for sid in sids]
Пример #18
0
def remove(cfg, snapshot_ids = None, force = None):
    snapshots_list = snapshots.listSnapshots(cfg)
    if not snapshot_ids:
        snapshot_ids = (None,)
    sids = [selectSnapshot(snapshots_list, cfg, sid, 'SnapshotID to remove') for sid in snapshot_ids]

    if not force:
        print('Do you really want to remove this snapshots?')
        [print(sid.displayName) for sid in sids]
        if not 'yes' == input('(no/yes): '):
            return

    s = snapshots.Snapshots(cfg)
    [s.remove_snapshot(sid) for sid in sids]
Пример #19
0
def restore(cfg, snapshot_id = None, what = None, where = None, **kwargs):
    if what is None:
        what = input('File to restore: ')
    what = tools.prepare_path(os.path.abspath(os.path.expanduser(what)))

    if where is None:
        where = input('Restore to (empty for original path): ')
    if where:
        where = tools.prepare_path(os.path.abspath(os.path.expanduser(where)))

    snapshots_list = snapshots.listSnapshots(cfg)

    sid = selectSnapshot(snapshots_list, snapshot_id, 'SnapshotID to restore')
    print('')
    RestoreDialog(cfg, sid, what, where, **kwargs).run()
Пример #20
0
def restore(cfg, snapshot_id = None, what = None, where = None, **kwargs):
    if what is None:
        what = input('File to restore: ')
    what = tools.prepare_path(os.path.abspath(os.path.expanduser(what)))

    if where is None:
        where = input('Restore to (empty for original path): ')
    if where:
        where = tools.prepare_path(os.path.abspath(os.path.expanduser(where)))

    snapshots_list = snapshots.listSnapshots(cfg)

    sid = selectSnapshot(snapshots_list, cfg, snapshot_id, 'SnapshotID to restore')
    print('')
    RestoreDialog(cfg, sid, what, where, **kwargs).run()
Пример #21
0
 def test_listSnapshots(self):
     self.assertEqual(snapshots.listSnapshots(self.cfg), [])
Пример #22
0
 def test_listSnapshots(self):
     self.assertEqual(snapshots.listSnapshots(self.cfg), [])