def lastSnapshotPath(args): """ Command for printing the path of the very last snapshot in current profile. Args: args (argparse.Namespace): previously parsed arguments Raises: SystemExit: 0 """ force_stdout = setQuiet(args) cfg = getConfig(args) _mount(cfg) sid = snapshots.lastSnapshot(cfg) if sid: if args.quiet: msg = '{}' else: msg = 'SnapshotPath: {}' print(msg.format(sid.path()), file=force_stdout) else: logger.error("There are no snapshots in '%s'" % cfg.profileName()) if not args.keep_mount: _umount(cfg) sys.exit(RETURN_OK)
def lastSnapshot(args): """ Command for printing the very last snapshot in current profile. args: argparse.ArgumentParser instance """ force_stdout = setQuiet(args) cfg = getConfig(args) _mount(cfg) sid = snapshots.lastSnapshot(cfg) if sid: print('SnapshotID: %s' % sid, file=force_stdout) else: logger.error("There are no snapshots in '%s'" % cfg.get_profile_name()) _umount(cfg) sys.exit(RETURN_OK)
global qapp qapp = qttools.createQApplication(cfg.APP_NAME) translator = qttools.translator() qapp.installTranslator(translator) ######################### ### Snapshot Log View ### ######################### cmd = ['../backintime/common/backintime', '--config', cfgFile, 'backup'] proc = subprocess.Popen(cmd) proc.communicate() mainWindow = app.MainWindow(cfg, appInstance, qapp) log = LogViewDialog(mainWindow, snapshots.lastSnapshot(cfg)) setScreenshotTimer(log, '_images/snapshot_log_view.png') ##################### ### Last Log View ### ##################### log = LogViewDialog(mainWindow) setScreenshotTimer(log, '_images/last_log_view.png') sn.remove(snapshots.lastSnapshot(cfg)) ############################# ### create fake snapshots ### #############################
def test_lastSnapshots(self): self.assertIsNone(snapshots.lastSnapshot(self.cfg))
def test_lastSnapshot(self): self.assertEqual(snapshots.lastSnapshot(self.cfg), '20151219-040324-123')