示例#1
0
def main():
    parsed_args = _parse_args(sys.argv[1:])

    if parsed_args.verbose:
        logger = logging.getLogger()
        logger.setLevel(logging.DEBUG)
        logger.addHandler(logging.StreamHandler())

    if parsed_args.format == 'json':
        formatter = JSONFormatter()
    elif parsed_args.format == 'pprint':
        formatter = PprintFormatter()
    elif parsed_args.format == 'python':
        formatter = PythonFormatter()
    else:
        print >> sys.stderr, 'Unknown format %r' % parsed_args.format
        sys.exit(1)

    http_client = HTTPClient(parsed_args.hostname, parsed_args.username, parsed_args.password,
                             xdebug_eclipse=parsed_args.xdebug_eclipse)
    if parsed_args.verbose:
        http_client = TimingHTTPClientDecorator(http_client)
        http_client = DebugHTTPClientDecorator(http_client)

    ws_client = WebServiceClient(http_client)

    xivo_ws = BaseXivoServer(ws_client)

    loop(xivo_ws, formatter)
示例#2
0
 def _new_ws_client(self, host, username, password):
     http_client = HTTPClient(host, username, password)
     http_client = DebugHTTPClientDecorator(http_client)
     ws_client = WebServiceClient(http_client)
     return ws_client
示例#3
0
 def _new_ws_client(self, host, username, password):
     http_client = HTTPClient(host, username, password)
     ws_client = WebServiceClient(http_client)
     return ws_client
示例#4
0
 def test_constructor_doesnt_crash_on_username_and_password(self):
     HTTPClient(u'example.org', u'foo', u'bar')
示例#5
0
    def test_scheme_is_https_when_host_is_not_localhost(self):
        http_client = HTTPClient(u'example.org')

        self.assertTrue(http_client._scheme_and_host.startswith(u'https://'))
示例#6
0
    def test_scheme_is_http_when_host_is_127_0_0_1(self):
        http_client = HTTPClient(u'127.0.0.1')

        self.assertTrue(http_client._scheme_and_host.startswith(u'http://'))
示例#7
0
    def test_scheme_is_http_when_host_is_localhost(self):
        http_client = HTTPClient(u'localhost')

        self.assertTrue(http_client._scheme_and_host.startswith(u'http://'))
示例#8
0
 def _new_http_client_with_mocked_opener(self, host):
     http_client = HTTPClient(host)
     http_client._opener = MagicMock()
     return http_client