How to use cobra - 10 common examples

To help you get started, we’ve selected a few cobra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github niwinz / cobrascript / tests / test_basic.py View on Github external
def test_basic_op_mod():
    assert compile("3 // 2") == "Math.floor(3 / 2);"
github WhaleShark-Team / cobra / git_projects.py View on Github external
for i in range(10):
                thread = threading.Thread(target=get_git_urls, args=(url, private_token, q_pages, fi))
                thread.start()
                threads.append(thread)

            for thread in threads:
                thread.join()

            res = push_to_api(git_urls, cobra_ip, key, fi, format, output, rules, dels)

        else:
            res = False

        if res:
            logger.info("[GIT-PRO] Git push success")
            logger.info("[GIT-PRO] All projects have been pushed")
        else:
            logger.warning("[GIT-PRO] Git push fail")

        fi.close()

    except requests.exceptions.MissingSchema:
        logger.warning('[GIT-PRO] Please write gitlab_url and private_token in config file')

    except requests.exceptions.ConnectionError:
        logger.warning('[GIT-PRO] Please check the cobra_ip or gitlab_url is right')

    except requests.exceptions.InvalidSchema:
        logger.warning('[GIT-PRO] Please add http:// before the cobra_ip or gitlab_url')

    except Exception as e:
        logger.warning('[GIT-PRO] {}'.format(e.message))
github WhaleShark-Team / cobra / git_projects.py View on Github external
if res:
            logger.info("[GIT-PRO] Git push success")
            logger.info("[GIT-PRO] All projects have been pushed")
        else:
            logger.warning("[GIT-PRO] Git push fail")

        fi.close()

    except requests.exceptions.MissingSchema:
        logger.warning('[GIT-PRO] Please write gitlab_url and private_token in config file')

    except requests.exceptions.ConnectionError:
        logger.warning('[GIT-PRO] Please check the cobra_ip or gitlab_url is right')

    except requests.exceptions.InvalidSchema:
        logger.warning('[GIT-PRO] Please add http:// before the cobra_ip or gitlab_url')

    except Exception as e:
        logger.warning('[GIT-PRO] {}'.format(e.message))
github WhaleShark-Team / cobra / git_projects.py View on Github external
else:
            logger.warning("[GIT-PRO] Git push fail")

        fi.close()

    except requests.exceptions.MissingSchema:
        logger.warning('[GIT-PRO] Please write gitlab_url and private_token in config file')

    except requests.exceptions.ConnectionError:
        logger.warning('[GIT-PRO] Please check the cobra_ip or gitlab_url is right')

    except requests.exceptions.InvalidSchema:
        logger.warning('[GIT-PRO] Please add http:// before the cobra_ip or gitlab_url')

    except Exception as e:
        logger.warning('[GIT-PRO] {}'.format(e.message))
github WhaleShark-Team / cobra / git_projects.py View on Github external
else:
            res = False

        if res:
            logger.info("[GIT-PRO] Git push success")
            logger.info("[GIT-PRO] All projects have been pushed")
        else:
            logger.warning("[GIT-PRO] Git push fail")

        fi.close()

    except requests.exceptions.MissingSchema:
        logger.warning('[GIT-PRO] Please write gitlab_url and private_token in config file')

    except requests.exceptions.ConnectionError:
        logger.warning('[GIT-PRO] Please check the cobra_ip or gitlab_url is right')

    except requests.exceptions.InvalidSchema:
        logger.warning('[GIT-PRO] Please add http:// before the cobra_ip or gitlab_url')

    except Exception as e:
        logger.warning('[GIT-PRO] {}'.format(e.message))
github WhaleShark-Team / cobra / git_projects.py View on Github external
thread.start()
                threads.append(thread)

            for thread in threads:
                thread.join()

            res = push_to_api(git_urls, cobra_ip, key, fi, format, output, rules, dels)

        else:
            res = False

        if res:
            logger.info("[GIT-PRO] Git push success")
            logger.info("[GIT-PRO] All projects have been pushed")
        else:
            logger.warning("[GIT-PRO] Git push fail")

        fi.close()

    except requests.exceptions.MissingSchema:
        logger.warning('[GIT-PRO] Please write gitlab_url and private_token in config file')

    except requests.exceptions.ConnectionError:
        logger.warning('[GIT-PRO] Please check the cobra_ip or gitlab_url is right')

    except requests.exceptions.InvalidSchema:
        logger.warning('[GIT-PRO] Please add http:// before the cobra_ip or gitlab_url')

    except Exception as e:
        logger.warning('[GIT-PRO] {}'.format(e.message))
github niwinz / cobrascript / tests / test_basic.py View on Github external
def test_simple_decorator():
    input = """
    @decorator
    def test(x, y):
        console.log("test")
    """

    expected = """
    var test;
    test = function(x, y) {
        console.log("test");
    };
    test = decorator(test);
    """
    compiled = compile(input)
    assert compiled == norm(expected)
github niwinz / cobrascript / tests / test_basic.py View on Github external
def test_decorator_with_params():
    input = """
    @decorator("test-param")
    def test(x, y):
        console.log("test")
    """

    expected = """
    var test;
    test = function(x, y) {
        console.log("test");
    };
    test = decorator("test-param")(test);
    """
    compiled = compile(input)
    print(compiled)
    assert compiled == norm(expected)
github datacenter / cobra / tests / mit / test_session_CertSession.py View on Github external
def test_cleanup_user(self, apics, certobject, userobject):
        apic = apics[0]
        user = apics[2]
        password = apics[3]
        secure = False if apics[1] == 'False' else True
        userobject.aaaUser.delete()
        session = LoginSession(apic, user, password, secure=secure)
        moDir = MoDirectory(session)
        moDir.login()
        cr = ConfigRequest()
        cr.addMo(userobject.aaaUser)
        r = moDir.commit(cr)
        assert r.status_code == 200
github datacenter / cobra / tests / session / test_session.py View on Github external
        (LoginSession('http://2.2.2.2:7777', 'c', 'd'),
             'http://2.2.2.2:7777', 'c', 'd', False, 90, 'xml'), # Test expected default
        (LoginSession('http://1.1.1.1:80', 'a', 'b', True, 180, requestFormat='json'),
             'http://1.1.1.1:80', 'a', 'b', True, 180, 'json'),
        (LoginSession('http://1.1.1.1:80', 'a', 'b', True, 180, requestFormat='xml'),
            'http://1.1.1.1:80', 'a', 'b', True, 180, 'xml'),
    ])
    def test_LoginSession_init(self, session, url, user, password, secure,
                                   timeout, requestFormat):
       assert session.url == url
       assert session.user == user
       assert session.password == password
       assert session.secure == secure
       assert session.timeout == timeout
       assert session.formatStr == requestFormat