python类client()的实例源码

socket_server.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def sspi_client():
    c = http.client.HTTPConnection("localhost", options.port)
    c.connect()
    # Do the auth dance.
    ca = sspi.ClientAuth(options.package, targetspn=options.target_spn)
    data = None
    while 1:
        err, out_buf = ca.authorize(data)
        _send_msg(c.sock, out_buf[0].Buffer)
        if err==0:
            break
        data = _get_msg(c.sock)
    print("Auth dance complete - sending a few encryted messages")
    # Assume out data is sensitive - encrypt the message.
    for data in "Hello from the client".split():
        blob, key = ca.encrypt(data)
        _send_msg(c.sock, blob)
        _send_msg(c.sock, key)
    c.sock.close()
    print("Client completed.")
operators.py 文件源码 项目:blender-addons 作者: scorpion81 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def execute(self, context):
        scene = context.scene
        netsettings = scene.network_render

        try:
            conn = clientConnection(netsettings, report = self.report)

            if conn:
                # Sending file
                client.sendJobBaking(conn, scene)
                conn.close()
                self.report({'INFO'}, "Job sent to master")
        except Exception as err:
            self.report({'ERROR'}, str(err))

        return {'FINISHED'}
operators.py 文件源码 项目:blender-addons 作者: scorpion81 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def execute(self, context):
        scene = context.scene
        netsettings = scene.network_render

        try:
            conn = clientConnection(netsettings, report = self.report)

            if conn:
                # Sending file
                scene.network_render.job_id = client.sendJob(conn, scene, True)
                conn.close()
                self.report({'INFO'}, "Job sent to master")
        except Exception as err:
            self.report({'ERROR'}, str(err))


        return {'FINISHED'}
operators.py 文件源码 项目:blender-addons 作者: scorpion81 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def execute(self, context):
        scene = context.scene
        netsettings = scene.network_render

        try:
            conn = clientConnection(netsettings, report = self.report)

            if conn:
                # Sending file
                scene.network_render.job_id = client.sendJob(conn, scene, False)
                conn.close()
                self.report({'INFO'}, "Job sent to master")
        except Exception as err:
            self.report({'ERROR'}, str(err))


        return {'FINISHED'}
utils.py 文件源码 项目:blender-addons 作者: scorpion81 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def clientVerifyVersion(conn, timeout):
    with ConnectionContext(timeout):
        conn.request("GET", "/version")
    response = conn.getresponse()

    if response.status != http.client.OK:
        conn.close()
        return False

    server_version = response.read()

    if server_version != VERSION:
        print("Incorrect server version!")
        print("expected", str(VERSION, encoding='utf8'), "received", str(server_version, encoding='utf8'))
        return False

    return True
server.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def handle_expect_100(self):
        """Decide what to do with an "Expect: 100-continue" header.

        If the client is expecting a 100 Continue response, we must
        respond with either a 100 Continue or a final response before
        waiting for the request body. The default is to always respond
        with a 100 Continue. You can behave differently (for example,
        reject unauthorized requests) by overriding this method.

        This method should either return True (possibly after sending
        a 100 Continue response) or send an error response and return
        False.

        """
        self.send_response_only(100)
        self.end_headers()
        return True
server.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def log_message(self, format, *args):
        """Log an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        """

        sys.stderr.write("%s - - [%s] %s\n" %
                         (self.address_string(),
                          self.log_date_time_string(),
                          format%args))
request.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def getproxies_environment():
    """Return a dictionary of scheme -> proxy server URL mappings.

    Scan the environment for variables named <scheme>_proxy;
    this seems to be the standard convention.  If you need a
    different way, you can pass a proxies dictionary to the
    [Fancy]URLopener constructor.

    """
    proxies = {}
    for name, value in os.environ.items():
        name = name.lower()
        if value and name[-6:] == '_proxy':
            proxies[name[:-6]] = value

    # CVE-2016-1000110 - If we are running as CGI script, forget HTTP_PROXY
    # (non-all-lowercase) as it may be set from the web server by a "Proxy:"
    # header from the client
    if 'REQUEST_METHOD' in os.environ:
        proxies.pop('http', None)

    return proxies
configuration.py 文件源码 项目:python-k8sclient 作者: mward29 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def debug(self, value):
        """
        Sets the debug status.

        :param value: The debug status, True or False.
        :type: bool
        """
        self.__debug = value
        if self.__debug:
            # if debug status is True, turn on debug logging
            for _, logger in iteritems(self.logger):
                logger.setLevel(logging.DEBUG)
            # turn on httplib debug
            httplib.HTTPConnection.debuglevel = 1
        else:
            # if debug status is False, turn off debug logging,
            # setting log level to default `logging.WARNING`
            for _, logger in iteritems(self.logger):
                logger.setLevel(logging.WARNING)
            # turn off httplib debug
            httplib.HTTPConnection.debuglevel = 0
server.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def handle_expect_100(self):
        """Decide what to do with an "Expect: 100-continue" header.

        If the client is expecting a 100 Continue response, we must
        respond with either a 100 Continue or a final response before
        waiting for the request body. The default is to always respond
        with a 100 Continue. You can behave differently (for example,
        reject unauthorized requests) by overriding this method.

        This method should either return True (possibly after sending
        a 100 Continue response) or send an error response and return
        False.

        """
        self.send_response_only(100)
        self.end_headers()
        return True
server.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def log_message(self, format, *args):
        """Log an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        """

        sys.stderr.write("%s - - [%s] %s\n" %
                         (self.address_string(),
                          self.log_date_time_string(),
                          format%args))
configuration.py 文件源码 项目:isilon_sdk_8_0_python 作者: Isilon 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def debug(self, value):
        """
        Sets the debug status.

        :param value: The debug status, True or False.
        :type: bool
        """
        self.__debug = value
        if self.__debug:
            # if debug status is True, turn on debug logging
            for _, logger in iteritems(self.logger):
                logger.setLevel(logging.DEBUG)
            # turn on httplib debug
            httplib.HTTPConnection.debuglevel = 1
        else:
            # if debug status is False, turn off debug logging,
            # setting log level to default `logging.WARNING`
            for _, logger in iteritems(self.logger):
                logger.setLevel(logging.WARNING)
            # turn off httplib debug
            httplib.HTTPConnection.debuglevel = 0
cli.py 文件源码 项目:clickhouse-cli 作者: hatarist 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, host, port, user, password, database,
                 settings, format, format_stdin, multiline, stacktrace):
        self.config = None

        self.host = host
        self.port = port
        self.user = user
        self.password = password
        self.database = database
        self.settings = {k: v[0] for k, v in parse_qs(settings).items()}
        self.format = format
        self.format_stdin = format_stdin
        self.multiline = multiline
        self.stacktrace = stacktrace
        self.server_version = None

        self.query_ids = []
        self.client = None
        self.echo = Echo(verbose=True, colors=True)
        self.progress = None

        self.metadata = {}
test_views.py 文件源码 项目:Kiwi 作者: kiwitcms 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_get_a_run(self):
        url = reverse('testruns-get', args=[self.test_run.pk])
        response = self.client.get(url)

        self.assertEqual(http.client.OK, response.status_code)

        for i, case_run in enumerate(
                (self.case_run_1, self.case_run_2, self.case_run_3), 1):
            self.assertContains(
                response,
                '<a href="#caserun_{0}">#{0}</a>'.format(case_run.pk),
                html=True)
            self.assertContains(
                response,
                '<a id="link_{0}" href="#caserun_{1}" title="Expand test case">'
                '{2}</a>'.format(i, case_run.pk, case_run.case.summary),
                html=True)
test_views.py 文件源码 项目:Kiwi 作者: kiwitcms 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_show_create_new_run_page(self):
        self.client.login(username=self.tester.username, password='password')

        response = self.client.post(self.url, {
            'from_plan': self.plan.pk,
            'case': [self.case_1.pk, self.case_2.pk, self.case_3.pk]
        })

        # Assert listed cases
        for i, case in enumerate((self.case_1, self.case_2, self.case_3), 1):
            self.assertContains(
                response,
                '<a href="/case/{0}/">{0}</a>'.format(case.pk),
                html=True)
            self.assertContains(
                response,
                '<a id="link_{0}" class="blind_title_link js-case-summary" '
                'data-param="{0}">{1}</a>'.format(i, case.summary),
                html=True)
test_views.py 文件源码 项目:Kiwi 作者: kiwitcms 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_add_env_value_to_runs(self):
        self.login_tester()

        self.client.get(self.env_value_url, {
            'a': 'add',
            'env_value_id': self.value_bsd.pk,
            'run_id': [self.test_run.pk, self.test_run_1.pk]
        })

        rel = TCMSEnvRunValueMap.objects.filter(run=self.test_run,
                                                value=self.value_bsd)
        self.assertTrue(rel.exists())

        rel = TCMSEnvRunValueMap.objects.filter(run=self.test_run_1,
                                                value=self.value_bsd)
        self.assertTrue(rel.exists())
test_views.py 文件源码 项目:Kiwi 作者: kiwitcms 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_delete_env_value_from_runs(self):
        self.login_tester()

        self.client.get(self.env_value_url, {
            'a': 'remove',
            'env_value_id': self.value_linux.pk,
            'run_id': [self.test_run.pk, self.test_run_1.pk],
        })

        rel = TCMSEnvRunValueMap.objects.filter(run=self.test_run,
                                                value=self.value_linux)
        self.assertFalse(rel.exists())

        rel = TCMSEnvRunValueMap.objects.filter(run=self.test_run_1,
                                                value=self.value_linux)
        self.assertFalse(rel.exists())
test_views.py 文件源码 项目:Kiwi 作者: kiwitcms 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_refuse_if_action_is_unknown(self):
        self.login_tester()

        post_data = {
            'a': 'unknown action',
            'case_run': self.case_run_1.pk,
            'case': self.case_run_1.case.pk,
            'bug_system_id': TestCaseBugSystem.objects.get(name='Bugzilla').pk,
            'bug_id': '123456',
        }

        response = self.client.get(self.case_run_bug_url, post_data)

        self.assertJsonResponse(
            response,
            {'rc': 1, 'response': 'Unrecognizable actions'})
test_views.py 文件源码 项目:Kiwi 作者: kiwitcms 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_remove_bug_from_case_run(self):
        self.login_tester()

        post_data = {
            'a': 'remove',
            'case_run': self.case_run_1.pk,
            'bug_id': self.bug_12345,
        }

        response = self.client.get(self.case_run_bug_url, post_data)

        bug_exists = TestCaseBug.objects.filter(
            bug_id=self.bug_12345,
            case=self.case_run_1.case,
            case_run=self.case_run_1).exists()
        self.assertFalse(bug_exists)

        self.assertJsonResponse(
            response,
            {'rc': 0, 'response': 'ok', 'run_bug_count': 1})


问题


面经


文章

微信
公众号

扫码关注公众号