def __init__(self): self.HOME = self.__class__.HOME DATE = self.__class__.DATE self.CONFIGFILE = self.__class__.CONFIGFILE self.CONF = self.__class__.CONF self.qflag = self.__class__.qflag self.DATE = '%04d-%02d-%02d-%02d' % (DATE.tm_year, DATE.tm_mon, DATE.tm_mday, DATE.tm_hour) self.bbc = bbcolor(quiet=True) self.msgpre = bbc.format('+', fg=21, style='normal') if os.getuid() != 0: self.COLOR_DEFAULT = None self.bbc.set_fg(self.COLOR_DEFAULT) else: self.COLOR_DEFAULT = None self.bbc.set_fg(self.COLOR_DEFAULT) self.bbc.set_style('bold') return
def cmd_unmount(self, mountpoint): '''Unmount a device''' if not os.path.ismount(mountpoint): raise Exception('%s is not a mount point' % mountpoint) returncode = subprocess.call(('umount', mountpoint)) if returncode != 0: raise Exception('Failed to unmount %s' % mountpoint) return if __name__ == '__main__': bbc = bbcolor(quiet=True) msgpre = bbc.format('+', fg=21, style='normal') if os.getuid() == 0: bbc.set_style('bold') # This is just a good idea os.umask(0o77) try: prog = btrfs_backup() prog.parseargs(sys.argv[1:]) # Set our own qflag qflag = prog.qflag prog.turn_root(sys.argv[:])