Esempio n. 1
0
    def test_profile_option_set(self):
        parser = CommandOptionParser(command_container=self.command_container, default_profile="default-profile")
        option = parser.get_option("--profile")

        self.assertEqual(parser.default_profile, "default-profile")
        self.assertEqual(option.get_opt_string(), "--profile")
        self.assertEqual(option.help, "specify profile (default: default-profile)")
Esempio n. 2
0
File: main.py Progetto: imcsk8/borga
def main(conf):
    container = BorgaCommandContainer(conf=conf)
    formatter = IndentedHelpFormatter(max_help_position=60, width=120)
    parser = CommandOptionParser(command_container=container,
                                 formatter=formatter,
                                 default_command='help')
    parser.run()
    sys.exit(0)
Esempio n. 3
0
def main():
    conf = PyConfigParser()
    conf.load_from_file(os.path.expanduser(CONF_PATH))
    container = BorgaCommandContainer(conf=conf)
    formatter = IndentedHelpFormatter(max_help_position=60, width=120)
    parser = CommandOptionParser(command_container=container,
                                 formatter=formatter,
                                 default_command='help')
    parser.run()
    sys.exit(0)
Esempio n. 4
0
    def test_configuration_directory_option_set(self):
        parser = CommandOptionParser(command_container=self.command_container, default_profile="default-profile",
                                     configuration_directory="/etc/client")

        configuration_file = os.path.join(parser.configuration_directory, '{0}.conf'.format(parser.default_profile))

        self.assertEqual(parser.configuration_directory, "/etc/client")
        self.assertEqual(configuration_file, "/etc/client/default-profile.conf")
Esempio n. 5
0
    def test_configuration_directory_option_unset(self):
        parser = CommandOptionParser(command_container=self.command_container, default_profile="default-profile")
        # CommandOptionParser() doesn't store the configuration_file path in an instance variable, instead it's
        # build in _load_profile() with the line below:
        configuration_file = os.path.join(parser.configuration_directory, '{0}.conf'.format(parser.default_profile))

        self.assertEqual(parser.configuration_directory, "/etc")
        self.assertEqual(configuration_file, "/etc/default-profile.conf")
Esempio n. 6
0
def main():
    global conf
    command_container = BeakerCommandContainer(conf=conf)

    option_list = [
        Option('--hub', metavar='URL',
            help='Connect to Beaker server at URL (overrides config file)'),
        Option('--username',
            help='Use USERNAME for password authentication (overrides config file)'),
        Option('--password',
            help='Use PASSWORD for password authentication (overrides config file)'),
    ]

    formatter = IndentedHelpFormatter(max_help_position=60, width=120)
    parser = CommandOptionParser(command_container=command_container, default_command="help", formatter=formatter)
    parser._populate_option_list(option_list, add_help=False)

    # This is parser.run(), but with more sensible error handling
    cmd, cmd_opts, cmd_args = parser.parse_args()
    try:
        return cmd.run(*cmd_args, **cmd_opts.__dict__)
    except xmlrpclib.Fault, e:
        sys.stderr.write('XML-RPC fault: %s\n' % e.faultString)
        return 1
Esempio n. 7
0
    def test_profile_option_unset(self):
        parser = CommandOptionParser(command_container=self.command_container)
        option = parser.get_option("--profile")

        self.assertEqual(parser.default_profile, "")
        self.assertEqual(option, None)