def Main(ctx, silent, test, allfs, scrub, filesystems, debug):
'''
perform btrfs filesystem maintenace for one, many or [-a]ll filesystems.
'''
global DEBUG, _log
DEBUG=debug
_log = logging.getLogger(LOGROOT)
_log.setLevel(logging.INFO)
sysh = SysLogHandler(address="/dev/log")
outh = logging.StreamHandler(sys.stdout)
if debug:
logfmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
sysh.setLevel(logging.DEBUG)
outh.setLevel(logging.DEBUG)
click.echo("arg allfs: %s" % str(allfs))
click.echo("arg debug: %s" % str(debug))
click.echo("arg silent: %s" % str(silent))
click.echo("arg test: %s" % str(test))
else:
logfmt = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
sysh.setLevel(logging.INFO)
outh.setLevel(logging.INFO)
sysh.setFormatter(logfmt)
outh.setFormatter(logfmt)
if len(filesystems) == 0 and not allfs:
click.echo("You must either use '-a' or specify a filesystem.")
click.echo("")
click.echo(ctx.get_help())
exit()
if test:
run = TestRun
click.echo("Run is set to Test")
_log.addHandler(sysh)
_log.addHandler(outh)
elif silent:
run = LoggerRun
_log.addHandler(sysh)
click.echo("Run is set to Logger")
else:
run = InteractiveRun
click.echo("Run is set to Interactive")
_log.addHandler(sysh)
_log.addHandler(outh)
if allfs:
filesystems = locateBtrfs()
_log.debug("arg filesystems: %s" % str(filesystems))
for fs in filesystems:
Maintain(fs, run, scrub)
continue
return True
评论列表
文章目录