Python getopt.GetoptError() Examples

The following are 30 code examples of getopt.GetoptError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module getopt , or try the search function .
Example #1
Source File: ici.py    From ici with MIT License 7 votes vote down vote up
def main():
    try:
        options, args = getopt.getopt(sys.argv[1:], ["help"])
    except getopt.GetoptError as e:
        pass

    match = re.findall(r'[\w.]+', " ".join(args).lower())
    words = "_".join(match)
    response = get_response(words)
    if not response:
        return
    root = read_xml(response)
    show(root) 
Example #2
Source File: rid.py    From razzy-spinner with GNU General Public License v3.0 6 votes vote down vote up
def run(self, args):
    rid = RegressiveImageryDictionary()
    load_default_dict = True
    load_default_exc = True
    html_output = False
    title = "RID Analysis"

    try:
      optlist, args = getopt.getopt(sys.argv[1:], 'd:e:ht:',
                                    ['add-dict=', 'add-exc='])
      for (o, v) in optlist:
        if o == '-d':
          rid.load_dictionary_from_file(v)
          load_default_dict = False
        elif o == '-e':
          rid.load_exclusion_list_from_file(v)
          load_default_exc = False
        elif o == '--add-dict':
          rid.load_dictionary_from_file(v)
        elif o == '--add-exc':
          rid.load_exclusion_list_from_file(v)
        elif o == '-h':
          html_output = True
        elif o == '-t':
          title = v
        else:
          sys.stderr.write("%s: illegal option '%s'\n" % (args[0], o))
          self.usage(args)
    except getopt.GetoptError, e:
      sys.stderr.write("%s: %s\n" % (args[0], e.msg))
      self.usage(args)
      sys.exit(1) 
Example #3
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #4
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #5
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #6
Source File: generate_library.py    From dashboard-api-python with MIT License 5 votes vote down vote up
def main(inputs):
    api_key = os.environ.get('MERAKI_DASHBOARD_API_KEY')
    org_id = None

    try:
        opts, args = getopt.getopt(inputs, 'ho:k:')
    except getopt.GetoptError:
        print_help()
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print_help()
            sys.exit(2)
        elif opt == '-o':
            org_id = arg
        elif opt == '-k' and api_key is None:
            api_key = arg

    # Retrieve latest OpenAPI specification
    if org_id:
        if not api_key:
            print_help()
            sys.exit(2)
        else:
            response = requests.get(f'https://api-mp.meraki.com/api/v1/organizations/{org_id}/openapiSpec',
                                    headers={'Authorization': f'Bearer {api_key}'})
            if response.ok:
                spec = response.json()
            else:
                print_help()
                sys.exit(f'API key provided does not have access to org {org_id}')
    else:
        spec = requests.get('https://api.meraki.com/api/v1/openapiSpec').json()

    generate_library(spec) 
Example #7
Source File: filecmp.py    From meddle with MIT License 5 votes vote down vote up
def demo():
    import sys
    import getopt
    options, args = getopt.getopt(sys.argv[1:], 'r')
    if len(args) != 2:
        raise getopt.GetoptError('need exactly two args', None)
    dd = dircmp(args[0], args[1])
    if ('-r', '') in options:
        dd.report_full_closure()
    else:
        dd.report() 
Example #8
Source File: test_adjustments.py    From pledgeservice with Apache License 2.0 5 votes vote down vote up
def test_bad_param(self):
        import getopt
        self.assertRaises(getopt.GetoptError, self.parse, ['--no-host']) 
Example #9
Source File: filecmp.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def demo():
    import sys
    import getopt
    options, args = getopt.getopt(sys.argv[1:], 'r')
    if len(args) != 2:
        raise getopt.GetoptError('need exactly two args', None)
    dd = dircmp(args[0], args[1])
    if ('-r', '') in options:
        dd.report_full_closure()
    else:
        dd.report() 
Example #10
Source File: test_getopt.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def assertError(self, *args, **kwargs):
        self.assertRaises(getopt.GetoptError, *args, **kwargs) 
Example #11
Source File: test_getopt.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_issue4629(self):
        longopts, shortopts = getopt.getopt(['--help='], '', ['help='])
        self.assertEqual(longopts, [('--help', '')])
        longopts, shortopts = getopt.getopt(['--help=x'], '', ['help='])
        self.assertEqual(longopts, [('--help', 'x')])
        self.assertRaises(getopt.GetoptError, getopt.getopt, ['--help='], '', ['help']) 
Example #12
Source File: fm.py    From pysat with MIT License 5 votes vote down vote up
def parse_options():
    """
        Parses command-line option
    """

    try:
        opts, args = getopt.getopt(sys.argv[1:], 'hs:c:v', ['help','solver=','cardenc=','verbose'])
    except getopt.GetoptError as err:
        sys.stderr.write(str(err).capitalize())
        usage()
        sys.exit(1)

    solver = 'm22'
    cardenc = 'seqc'
    verbose = 1

    for opt, arg in opts:
        if opt in ('-c', '--cardenc'):
            cardenc = str(arg)
        elif opt in ('-h', '--help'):
            usage()
            sys.exit(0)
        elif opt in ('-s', '--solver'):
            solver = str(arg)
        elif opt in ('-v', '--verbose'):
            verbose += 1
        else:
            assert False, 'Unhandled option: {0} {1}'.format(opt, arg)

    cardenc = encmap[cardenc]

    # using minicard's native implementation of AtMost1 constraints
    if solver in SolverNames.minicard:
        cardenc = encmap['native']
    else:
        assert cardenc != encmap['native'], 'Only Minicard can handle cardinality constraints natively'

    return solver, cardenc, verbose, args


#============================================================================== 
Example #13
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #14
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #15
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #16
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #17
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #18
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #19
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #20
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #21
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #22
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #23
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #24
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #25
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #26
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #27
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #28
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #29
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_ 
Example #30
Source File: generate_mapping.py    From ovirt-ansible-disaster-recovery with Apache License 2.0 5 votes vote down vote up
def _init_vars(argv):
    url, username, password, ca, file_ = '', '', '', '', ''
    try:
        opts, args = \
            getopt.getopt(argv, "a:u:p:f:c:", ["a=", "u=", "p=", "f=", "c="])
    except getopt.GetoptError:
        print(
            '''
            -a <http://127.0.0.1:8080/ovirt-engine/api>\n
            -u <admin@portal>\n
            -p <password>\n
            -c </etc/pki/ovirt-engine/ca.pem>\n
            -f <disaster_recovery_vars.yml>
            ''')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print(
                '''
                generate_mapping.py
                -a <http://127.0.0.1:8080/ovirt-engine/api>\n
                -u <admin@portal>\n
                -p <password>\n
                -c </etc/pki/ovirt-engine/ca.pem>\n
                -f <disaster_recovery_vars.yml>
                ''')
            sys.exit()
        elif opt in ("-a", "--url"):
            url = arg
        elif opt in ("-u", "--username"):
            username = arg
        elif opt in ("-p", "--password"):
            password = arg
        elif opt in ("-c", "--ca"):
            ca = arg
        elif opt in ("-f", "--file"):
            file_ = arg
    return url, username, password, ca, file_