本文整理汇总了Python中barman.config.Config.load_configuration_files_directory方法的典型用法代码示例。如果您正苦于以下问题:Python Config.load_configuration_files_directory方法的具体用法?Python Config.load_configuration_files_directory怎么用?Python Config.load_configuration_files_directory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类barman.config.Config
的用法示例。
在下文中一共展示了Config.load_configuration_files_directory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import load_configuration_files_directory [as 别名]
def main():
parser = argparse.ArgumentParser(description="Barman plugin for NRPE.")
parser.add_argument("-s", "--server", dest="server",
help="server to check")
parser.add_argument('-w', '--warning', type=int, dest="warning",
metavar="W", help="warning threshold.")
parser.add_argument('-c', '--critical', type=int, dest="critical",
metavar="C", help="critical threshold.")
parser.add_argument('-u' '--user', dest='user', metavar='U',
help="user needed to run this script. If the "
"current user is not this one, the script will try " +
"to rerun itself using sudo.")
subparsers = parser.add_subparsers()
for key, value in ACTIONS.items():
(action, help) = value
subparser = subparsers.add_parser(key, help=help)
subparser.set_defaults(action=action)
parser.error = unknown
args = parser.parse_args()
user = pwd.getpwuid(os.getuid())[0]
if args.user and user != args.user:
import subprocess
retval = subprocess.call(["/usr/bin/sudo", "-u", args.user] + sys.argv)
raise SystemExit(retval)
from barman.config import Config
from barman.server import Server
config = Config()
config.load_configuration_files_directory()
server = Server(config.get_server(args.server))
try:
args.action(server, args)
except KeyError:
unknown("The action %s does not exist." % args.action)