本文整理匯總了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)