def main():
coloredlogs.install(fmt='%(message)s')
if os.geteuid() == 0:
logger.error("Do not run this as root")
sys.exit(1)
config = cfg.Config()
config.create()
config.read()
config.verify()
version = 'bridgy %s' % __version__
args = docopt(__doc__, version=version)
if not tmux.is_installed():
if args ['--tmux'] or config.dig('ssh', 'tmux'):
logger.warn("Tmux not installed. Cannot support split screen.")
args['--tmux'] = False
if args['-v']:
coloredlogs.install(fmt='%(message)s', level='DEBUG')
if args['-d']:
args['-v'] = True
coloredlogs.install(fmt='%(message)s', level='DEBUG')
logger.warn("Performing dry run, no actions will be taken.")
# why doesn't docopt pick up on this?
if args['-t']:
args['--tmux'] = True
if args['--version']:
logger.info(version)
sys.exit(0)
opts = {
'ssh': ssh_handler,
'mount': mount_handler,
'list-mounts': list_mounts_handler,
'list-inventory': list_inventory_handler,
'unmount': unmount_handler,
'update': update_handler,
'run': run_handler,
}
for opt, handler in list(opts.items()):
if args[opt]:
try:
handler(args, config)
except utils.UnsupportedPlatform as ex:
logger.error(ex.message)
sys.exit(1)
评论列表
文章目录