예제 #1
0
def main():
    # https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning
    # We don't want Insecure Platform Warning to pop up everytime HTTPS request is sent.
    urllib3.disable_warnings()

    log_command()

    args = parse_args()
    try:
        if args.verbose:
            set_verbose()
    except AttributeError:
        pass

    try:
        _load_armada_develop_vars()
    except Exception:
        print('Warning: Could not load armada develop vars.')
        if is_verbose():
            traceback.print_exc()

    try:
        args.func(args)
    except Exception as e:
        print('Command failed: {exception_class} - {exception}'.format(
            exception_class=type(e).__name__, exception=str(e)))
        if is_verbose():
            traceback.print_exc()
        sys.exit(1)
예제 #2
0
def post(api_function, arguments=None, ship_name=None):
    arguments = arguments or {}
    try:
        url = __get_armada_address(ship_name) + '/' + api_function
        result = requests.post(url, json=arguments)
        result.raise_for_status()
        return result.json()
    except Exception as e:
        if is_verbose():
            traceback.print_exc()
        return __exception_to_status(e)
예제 #3
0
def post(api_function, arguments=None, ship_name=None):
    arguments = arguments or {}
    try:
        url = __get_armada_address(ship_name) + '/' + api_function
        result = requests.post(url, json=arguments)
        result.raise_for_status()
        return result.json()
    except Exception as e:
        if is_verbose():
            traceback.print_exc()
        return __exception_to_status(e)
예제 #4
0
파일: armada.py 프로젝트: labuzm/armada
def main():
    # https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning
    # We don't want Insecure Platform Warning to pop up everytime HTTPS request is sent.
    urllib3.disable_warnings()

    log_command()

    args = parse_args()
    try:
        if args.verbose:
            set_verbose()
    except AttributeError:
        pass
    try:
        args.func(args)
    except Exception as e:
        print('Command failed: {exception_class} - {exception}'.format(
            exception_class=type(e).__name__,
            exception=str(e)))
        if is_verbose():
            traceback.print_exc()
        sys.exit(1)