예제 #1
0
파일: gui.py 프로젝트: mdomlop/snapman
    def createModel(self):
        model = QStandardItemModel(0, 7)
        model.setHeaderData(0, Qt.Horizontal, self.path_title)
        model.setHeaderData(1, Qt.Horizontal, self.sect_title)
        model.setHeaderData(2, Qt.Horizontal, self.subv_title)
        model.setHeaderData(3, Qt.Horizontal, self.wday_title)
        model.setHeaderData(4, Qt.Horizontal, self.date_title)
        model.setHeaderData(5, Qt.Horizontal, self.time_title)
        model.setHeaderData(6, Qt.Horizontal, self.ts_title)

        n = 0
        for i in mainWindow.sectionTable.selected:
            x = Section(settings.config[i])
            for j in x.snapshot_paths:
                snap = x.snapshot_info(j, printout=False)
                model.insertRow(n)
                model.setData(model.index(n, 0), j)
                model.setData(model.index(n, 1), x.name)
                model.setData(model.index(n, 2), x.subvolume)
                model.setData(model.index(n, 3), snap.wday)
                model.setData(model.index(n, 4), snap.date)
                model.setData(model.index(n, 5), snap.time)
                model.setData(model.index(n, 6), snap.ts)
            n = +1
        return model
예제 #2
0
def snapshots():
    for s in settings.sections:
        x = Section(settings.config[s])
        if args.verbose:
            for i in x.snapshot_paths:
                print(i, 'from', x.subvolume)
        else:
            x.print_snapshots()
예제 #3
0
def section_snapshots():
    s = args.section_snapshots.rstrip('/')
    x = Section(settings.config[s])
    if args.verbose:
        for i in x.snapshot_paths:
            print(i, 'from', x.subvolume)
    else:
        x.print_snapshots()
예제 #4
0
def section_snapshots():
    for i in Snapman.args.targets:
        s = i.rstrip('/')
        x = Section(settings.config[s])
        if Snapman.args.verbose:
            for i in x.snapshot_paths:
                print(i, 'from', x.subvolume)
        else:
            x.print_snapshots()
예제 #5
0
def run_once():
    if not check_root():
        clean_exit(
'''You need to have root privileges to execute this script.
Please try again, this time using "sudo". Exiting.''', BADPERM)

    for i in settings.sections:
        x = Section(settings.config[i])
        x.makesnapshot()
예제 #6
0
def daemon():
    if not check_root():
        clean_exit(
'''You need to have root privileges to execute this script in daemon mode.
Please try again, this time using "sudo". Exiting.''', BADPERM)

    for i in settings.sections:
        x = Section(settings.config[i])
        x.daemonize()
예제 #7
0
def sections():
    if not args.verbose:
        for i in settings.sections:
            print(i)
    else:
        for i in settings.sections:
            x = Section(settings.config[i])
            r = 'readonly' if x.readonly else 'writable'
            print(x.name + ':',
                  str(x.snapshot_count()) + '/' + str(x.quota),
                  r, 'from', x.subvolume)
예제 #8
0
def subvolume_clean():
    sub = args.subvolume_clean
    if sub != '/':  # Prevent strip filesystem root.
        sub = sub.rstrip('/')

    found = False
    for i in settings.sections:
        if sub == settings.config[i]['subvolume']:
            found = True
            x = Section(settings.config[i])
            x.snapshot_clean()
    if not found:
        clean_exit('No section manages the subvolume: ' + sub, BADSUB)
예제 #9
0
def snapshot_info():
    snap = args.snapshot_info
    if snap != '/':  # Prevent strip filesystem root.
        snap = snap.rstrip('/')
    else:
        clean_exit("Root directory can't be a snapshot!", BADSNAP)
    found = 0
    for i in settings.sections:
        x = Section(settings.config[i])
        if x.snapshot_info(snap):
            found =+ 1
    if not found:
        clean_exit('No section manages the snapshot: ' + snap, BADSNAP)
예제 #10
0
def subvolume_info():
    sub = args.subvolume_info
    if sub != '/':  # Prevent strip filesystem root.
        sub = sub.rstrip('/')

    found = False
    snap = []
    sect = []
    for i in settings.sections:
        if sub == settings.config[i]['subvolume']:
            found = True
            x = Section(settings.config[i])
            snap += x.snapshot_paths
            sect.append(x.name)

    if not found:
        clean_exit('No section manages the subvolume: ' + sub, BADSUB)
    if snap:
        sort_snaps = sorted(snap)
        newer = sort_snaps[0]
        older = sort_snaps[-1]
    else:
        newer = ''
        older = ''
    if args.verbose:
        print('Subvolume:', sub)
    print('Snapshots:', len(snap),
          '\nSections:', len(sect),
          '\nNewer:', newer,
          '\nOlder:', older)
예제 #11
0
def subvolume_sections():
    sub = args.subvolume_sections
    if sub != '/':  # Prevent strip filesystem root.
        sub = sub.rstrip('/')

    found = False
    for i in settings.sections:
        if sub == settings.config[i]['subvolume']:
            found = True
            x = Section(settings.config[i])
            if not args.verbose:
                print(x.name)
            else:
                print(x.name + ':', x.snapshot_count())
    if not found:
        clean_exit('No section manages the subvolume: ' + sub, BADSUB)
예제 #12
0
def subvolume_snapshots():
    sub = args.subvolume_snapshots
    if sub != '/':  # Prevent strip filesystem root.
        sub = sub.rstrip('/')

    found = False
    for i in settings.sections:
        if sub == settings.config[i]['subvolume']:
            found = True
            x = Section(settings.config[i])
            if not args.verbose:
                x.print_snapshots()
            else:
                for s in x.snapshot_paths:
                    print(s, 'from', x.subvolume)
    if not found:
        clean_exit('Currently there is no snapshot for the subvolume: ' +
                   sub, BADSUB)
예제 #13
0
파일: gui.py 프로젝트: mdomlop/snapman
    def delete(self):
        failed = []
        ok = False
        for s in self.selected:
            x = Section(settings.config[s])
            if x.snapshot_clean():
                ok = True
            else:
                failed.append(s)

        if failed:
            text = 'Failed to clean sections: \n\n' + '\n'.join(failed) + '\
            \n\nMaybe are not you root?'

            title = 'Operation failed'
            self.mbox.warning(self, title, text, self.mbox.Ok)

        if ok:  # Only update table if some were deleted
            self.reloadTable()
예제 #14
0
파일: gui.py 프로젝트: mdomlop/snapman
    def delete(self):
        failed = []
        ok = False
        for snap in self.selected:
            sect = self.selected[snap]
            x = Section(settings.config[sect])
            if x.delete(snap):
                ok = True
            else:
                failed.append(snap)

        if failed:
            text = 'Failed to delete snapshots: \n\n' + '\n'.join(failed) + '\
            \n\nMaybe are not you root?'

            title = 'Operation failed'
            self.mbox.warning(self, title, text, self.mbox.Ok)

        if ok:  # Only update table if some were deleted
            mainWindow.sectionTable.reloadTable()
예제 #15
0
파일: gui.py 프로젝트: mdomlop/snapman
    def new_snapshot(self):
        failed = []
        ok = False
        for s in self.selected:
            x = Section(settings.config[s])
            if x.makesnapshot(force=True):
                ok = True
            else:
                failed.append(s)

        if failed:
            text = 'Failed to create new snapshots for the sections: \n\n' + \
                '\n'.join(failed) + '\
            \n\nMaybe are not you root?'

            title = 'Operation failed'
            self.mbox.warning(self, title, text, self.mbox.Ok)

        if ok:  # Only update table if some change happened
            self.reloadTable()
예제 #16
0
def section_properties():
    s = args.section_properties.rstrip('/')
    x = Section(settings.config[s])
    if args.verbose:
        x.print_properties()
    else:
        x.print_properties()
예제 #17
0
파일: gui.py 프로젝트: mdomlop/snapman
    def createModel(self):
        # Column indices:
        PATH, SUBV, NSNAP, QUOTA, FREQUENCY, ENABLED = range(6)

        model = QStandardItemModel(0, 6)
        model.setHeaderData(PATH, Qt.Horizontal, self.sect_title)
        model.setHeaderData(SUBV, Qt.Horizontal, self.subv_title)
        model.setHeaderData(NSNAP, Qt.Horizontal, self.count_title)
        model.setHeaderData(QUOTA, Qt.Horizontal, self.quota_title)
        model.setHeaderData(FREQUENCY, Qt.Horizontal, self.freq_title)
        model.setHeaderData(ENABLED, Qt.Horizontal, self.enabled_title)

        for i in settings.sections:
            x = Section(settings.config[i])
            model.insertRow(0)
            model.setData(model.index(0, PATH), x.name)
            model.setData(model.index(0, SUBV), x.subvolume)
            model.setData(model.index(0, NSNAP), x.count)
            model.setData(model.index(0, QUOTA), x.percent)
            model.setData(model.index(0, FREQUENCY), x.frequency)
            model.setData(model.index(0, ENABLED), x.enabled)
        return model
예제 #18
0
def section_properties():
    for i in Snapman.args.targets:
        s = i.rstrip('/')
        x = Section(settings.config[s])
        x.print_properties()
        print()
예제 #19
0
def section_newsnapshot():
    for i in Snapman.args.targets:
        s = i.rstrip('/')
        x = Section(settings.config[s])
        x.makesnapshot(True)
예제 #20
0
def section_clean():
    for i in Snapman.args.targets:
        s = i.rstrip('/')
        x = Section(settings.config[s])
        x.snapshot_clean()
예제 #21
0
def section_info():
    for i in Snapman.args.targets:
        s = i.rstrip('/')
        x = Section(settings.config[s])
        x.info()
        print()
예제 #22
0
def section_info():
    s = args.section_info.rstrip('/')
    x = Section(settings.config[s])
    x.info()
예제 #23
0
def section_clean():
    s = args.section_clean.rstrip('/')
    x = Section(settings.config[s])
    x.snapshot_clean()
예제 #24
0
def section_newsnapshot():
    s = args.section_newsnapshot.rstrip('/')
    x = Section(settings.config[s])
    x.makesnapshot(True)
예제 #25
0
def daemon():
    for i in settings.sections:
        x = Section(settings.config[i])
        x.daemonize()
예제 #26
0
def run_once():
    for i in settings.sections:
        x = Section(settings.config[i])
        x.makesnapshot()