def test_case_utils_miss_arg_verbose(self): """Tests the utils._handleVerbosityArgs with an invalid value as input""" theResult = False try: from piaplib import pku as pku if pku.__name__ is None: raise ImportError("Failed to import pku") from pku import utils as utils if utils.__name__ is None: raise ImportError("Failed to import utils") test_error = str( """__init__() missing 1 required positional argument: 'message'""" ) with self.assertLogs('piaplib') as cm: with self.assertRaises(RuntimeError): utils._handleVerbosityArgs(argParser=None, default=True) self.assertIsNotNone(cm.output, str("""No Error Message Logged""")) test_mesg = str(cm.output) self.assertIn( test_error, test_mesg, str("""Wrong Error Messages (missing test case error)""")) theResult = True except Exception as err: print(str("")) print(str(type(err))) print(str(err)) print(str((err.args))) print(str("")) err = None del err theResult = False self.assertTrue(theResult)
def generateParser(calling_parser_group): """Parses the CLI arguments.""" if calling_parser_group is None: parser = argparse.ArgumentParser( prog=__prog__, description=__description__, epilog=__epilog__ ) else: parser = calling_parser_group.add_parser( str(__prog__).split(".")[-1], help=__description__ ) parser.add_argument('-u', '--user', default=None, help='The user to show.') parser.add_argument( '-l', '--list', default=False, action='store_true', help='List current users.' ) parser.add_argument( '--html', dest='output_html', default=False, action='store_true', help='output HTML.' ) parser.add_argument( '-a', '--all', dest='show_all', default=False, action='store_true', help='show all users.' ) parser = utils._handleVerbosityArgs(parser, default=False) parser = utils._handleVersionArgs(parser) if calling_parser_group is None: calling_parser_group = parser return calling_parser_group
def generateParser(calling_parser_group): """Parses the CLI arguments.""" if calling_parser_group is None: parser = argparse.ArgumentParser(prog=__prog__, description=__description__, epilog=__epilog__) else: parser = calling_parser_group.add_parser(str(__prog__).split(".")[-1], help=__description__) parser.add_argument('-i', '--interface', default=interfaces.INTERFACE_CHOICES[0], choices=interfaces.INTERFACE_CHOICES, help='The interface to show.') parser.add_argument('-l', '--list', default=False, action='store_true', help='List current interfaces.') parser.add_argument('--html', dest='output_html', default=False, action='store_true', help='output html.') parser.add_argument('-a', '--all', dest='show_all', default=False, action='store_true', help='show all interfaces.') parser = utils._handleVerbosityArgs(parser, default=False) parser = utils._handleVersionArgs(parser) if calling_parser_group is None: calling_parser_group = parser return calling_parser_group
def generateParser(calling_parser_group): """Parses the CLI arguments.""" if calling_parser_group is None: parser = argparse.ArgumentParser( prog=__prog__, description=u'Run an untrusted plugin or command.', epilog=u'This is for all the dirty work. So unpoetic.') else: parser = calling_parser_group.add_parser( str(__prog__).split(".")[-1], help='Run an untrusted plugin or command.') parser.add_argument('-u', '--uid', default=os.geteuid(), type=int, required=False, help='the uid to use.') parser.add_argument('-g', '--gid', default=os.getegid(), type=int, required=False, help='the gid to use.') parser.add_argument('--chroot', dest='chroot_path', default=None, type=str, required=False, help='the sandbox to play in.') parser = utils._handleVerbosityArgs(parser, default=False) parser.add_argument('-c', '--cmd', dest='unsafe_input', action='append', help='The command.') parser.add_argument('-a', '--args', dest='unsafe_input', action='append', help='The command arguments.') parser.add_argument('-o', '--out', dest='unsafe_output', default=False, action='store_true', help='Return the command output.') parser = utils._handleVersionArgs(parser) if calling_parser_group is None: calling_parser_group = parser return calling_parser_group