当前位置: 首页>>代码示例>>Python>>正文


Python proxy.Proxy类代码示例

本文整理汇总了Python中proxy.Proxy的典型用法代码示例。如果您正苦于以下问题:Python Proxy类的具体用法?Python Proxy怎么用?Python Proxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Proxy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

def start():
	from Project import Project
	import Record

	project = Project()
	record = Record.Record()

	Proxy.begin_catch(
			#callback = record.add_hit,
			callback = callback,
			filter = lambda x: True,
			hittype = HitData,
			)
	proxy = Proxy.thread_start()

	while True:
		c = raw_input('Enter stop to stop > ')
		if c == 'stop':
			break

	Proxy.stop()
	proxy.join()

	print 'Recording finished'
	print
开发者ID:iambus,项目名称:PyLoad,代码行数:25,代码来源:TrafficMonitor.py

示例2: send_result

 def send_result(self, response):
     proxy = Proxy()
     proxy.update_result(
             response['submissionId'], response['status'],
             response['run_time'], response['run_memory'], response['extra_message'],
             '', '', '', time.strftime('%Y-%m-%d %X', time.localtime(time.time()))
             )
开发者ID:Zozoz,项目名称:OnlineJudgeSite,代码行数:7,代码来源:m6connector.py

示例3: remote_radmin_proxy

 def remote_radmin_proxy(self,service_uuid, command, params):
     if self.services.has_option(service_uuid, 'radmin_pw'):
         host = self.services.get(service_uuid, 'radmin_host')
         params['password'] = self.services.get(service_uuid, 'radmin_pw')
     else: defer.returnValue('nocredentials') 
     #modify the Regions.ini. We could do this later properly in RemoteController.cs
     if command == 'admin_create_region' or command == 'admin_restart' or command== 'admin_shutdown':
         if params.has_key('region_id'):
             params['regionID'] = params['region_id']
         params['listen_ip'] = '0.0.0.0'
         params['listen_port'] = self.get_free_port()
         params['external_address'] = self.config.get('client','wan_ip')
         testresponse = self.update_region_ini(service_uuid, params,'add')
     elif command == 'admin_delete_region':
         self.update_region_ini(service_uuid, params,'del')
     proxy = Proxy(host)
     try:
         response = yield proxy.callRemote(command, params)
         if 'success' in response:
             if response['success']:
                 defer.returnValue(response)
         if 'error' in response:
             response = {'status': {'code':'RADMIN_FAILED','feedback':response['error']}}
             if command == 'admin_create_region':
                 self.update_region_ini(service_uuid, params,'del')
     except Error:
         if command == 'admin_create_region':
             self.update_region_ini(service_uuid, params,'del')
         response = {'status': {'code':'RADMIN_FAILED'}}
     defer.returnValue(response)
开发者ID:jvanveen,项目名称:teknon,代码行数:30,代码来源:client.py

示例4: test_operations

def test_operations():
    print "Objects".center(80, '=')

    ty = ('Array', [('t', 'int')])

    p = Proxy(ty)
    print p

    print "Tests".center(80, '=')
    assert p.typeof == ty

    b = p.add(2.0)
    c = b.add(2.0)
    d = c.add(2.0)

    print d
    print b.sqrt()
    print p > p
    print (p+p)+p

    print reduce(add, [p,p,p]*50)

    f = p > p
    f = p - p
    print f
开发者ID:help-lazybones,项目名称:blaze-core,代码行数:25,代码来源:test_simple.py

示例5: api_proxy

def api_proxy():
    user = request.args['user'] if 'user' in request.args else None
    pkey = os.path.join(cfg.get("ipyno", "sshdir"), cfg.get('nova-admin', "vm_key")+'.pem')
    pcfg = dict(cfg.items('proxy'))
    try_ipydb = get_ipydb(request, False)
    if try_ipydb['status'] != 200:
        return return_json(None, try_ipydb['error'], try_ipydb['status'])
    ipydb = try_ipydb['data']
    proxy = Proxy(pcfg, pkey)
    response = return_json(None, 'Method Not Allowed (%s): %s'%(request.method, request.url), 405)
    # return list of server objs from proxy (nova-admin auth)
    if request.method == 'GET':
        try_nova = get_nova(request, 'nova-admin')
        if try_nova['status'] != 200:
            response = return_json(None, try_nova['error'], try_nova['status'])
        elif not user:
            response = return_json(None, "Bad Request: missing user", 400)
        else:
            data = proxy.get_server(user)
            response = return_json(data['data']) if data['status'] == 200 else return_json(None, data['error'], data['status'])
    # return server obj from proxy for user - if does not exist create it (add user to proxy and db)
    # NOTE: this is the only API call that uses OAuth and is accessable by a normal user and not an admin
    elif request.method == 'POST':
        auth = check_auth(request.headers)
        if auth['error']:
            return return_json(None, auth['error'], 401)
        res = ipydb.get('user', auth['username'])
        # user already has a proxy
        if res:
            data = proxy.get_server(auth['username'])
            return return_json(data['data']) if data['status'] == 200 else return_json(None, data['error'], data['status'])
        # set proxy for user - get free port, add to db, add to nginx config
        vm = ipydb.reserve()
        port = ipydb.next_port(int(pcfg["pstart"]), int(pcfg["pend"]))
        if vm and port:
            vm = ipydb.update(vm['id'], user=auth['username'], port=port)
            data = proxy.add_server(auth['username'], vm['ip'], port)
            response = return_json(data['data']) if data['status'] == 200 else return_json(None, data['error'], data['status'])
        else:
            response = return_json(None, 'Service Unavailable: no free ipython servers available', 503)
    # delete vm from proxy based on user, remove proxy/user info from db (nova auth)
    elif request.method == 'DELETE':
        try_nova = get_nova(request, 'nova-admin')
        if try_nova['status'] != 200:
            response = return_json(None, try_nova['error'], try_nova['status'])
        elif not user:
            response = return_json(None, "Bad Request: missing user", 400)
        else:
            vm = ipydb.get('user', user)
            # user in DB and vaild auth - now we delete
            if vm:
                ipydb.drop_user(vm['id'])
                res = proxy.remove_server(user)
                # TODO: stop ipython on vm
                response = return_json("user '%s' removed"%user) if res['status'] == 200 else return_json(None, res['error'], res['status'])
            else:
                response = return_json(None, "Bad Request: invalid user %s"%user, 400)
    ipydb.exit()
    return response
开发者ID:teharrison,项目名称:ipy-nbo,代码行数:59,代码来源:ipyAPI.py

示例6: OnStop

	def OnStop(self, event):
		self.toolbar.EnableTool(self.toolStart.GetId(), 1)
		self.toolbar.EnableTool(self.toolStop.GetId(), 0)
		menu = self.GetMenuBar().GetMenu(1)
		menu.FindItemByPosition(0).Enable(True)
		menu.FindItemByPosition(1).Enable(False)

		Proxy.end_catch()
开发者ID:iambus,项目名称:PyLoad,代码行数:8,代码来源:Main.py

示例7: test_dict_proxy

 def test_dict_proxy(self):
     d = {"key1": "val1", "key2": "val2"}
     p = Proxy(d)
     self.assertEqual(p["key1"], "val1")
     self.assertEqual(len(p.keys()), len(d.keys()))
     self.assertEqual(p, d)
     self.assertTrue(p == d)
     self.assertNotEqual(id(p), id(d))
     del p["key1"]
开发者ID:sjb9774,项目名称:python-patterns,代码行数:9,代码来源:tests.py

示例8: spot_proxy

 def spot_proxy(self, ip, port, country):
     if country:
         country=country.decode('utf-8')
     p = Proxy(ip=ip, port=port, country=country)
     if self.proxy_pool.has_proxy(p.proxy_url()):
         logger.debug_class_fun(ProxyPoolHandler.__name__, "proxy exists, proxy_url = %s", p.proxy_url())
     else:
         logger.debug_class_fun(ProxyPoolHandler.__name__,"new proxy, proxy_url = %s", p.proxy_url())
         self.proxy_pool.add_proxy(p)
开发者ID:breakhearts,项目名称:proxymaid,代码行数:9,代码来源:proxypoolservice.py

示例9: online

 def online(self):
     config.logger.info("尝试上线。。。。")
     try:
         proxy = Proxy()
         response = proxy.online()
         self.is_online = True
         config.logger.info("上线成功,节点ID:%s" % response['siteId'])
     except Exception, msg:
         config.logger.error("上线失败,错误信息:%s" % msg)
开发者ID:Zozoz,项目名称:OnlineJudgeSite,代码行数:9,代码来源:m6connector.py

示例10: add_proxy

    def add_proxy(self, pt):
        print "selected lo:", self.get_selected_layer_object()
        p = Proxy(self.get_selected_layer_object(), position=pt)
        p.name = str(self.last_id)
        p.id = self.last_id
        print "new proxy id:", p.id
        self.proxy_dct[self.last_id] = p
        if self.layer_type == LayerType.meta:
            print "adding meta"
            self.adjacency_dct[self.last_id] = []            
        self.resort_all_proxys()

        self.last_id += 1
开发者ID:snegovick,项目名称:map_editor,代码行数:13,代码来源:layer.py

示例11: splice

 def splice(self, start, stop, data):
     which = self.which
     if which in ('string', 'buffer'):
         immutable = self.struct[self.index]
         removed = immutable[start:stop]
         self.struct[self.index] = immutable[:start] + data + immutable[stop:]
     elif which == 'list':
         removed = self.struct[self.index][start:stop]
         self.struct[self.index][start:stop] = data
     else:
         raise Exception("Cannot splice %s" % which)
     Proxy.reproxy(self.struct.proxy, self.index, self.struct[self.index])
     return removed
开发者ID:cheery,项目名称:essence,代码行数:13,代码来源:mutator.py

示例12: get_submission

    def get_submission(self):
        response = None
        is_valid = False
        while not is_valid:
            try:
                proxy = Proxy()
                response = proxy.get_submission()
		# config.logger.debug(response)
            except Exception, e:
                config.logger.error(e)
                self.is_online = False
                self.on_load()
            if response['valid'] == 'true':
                is_valid = True
开发者ID:Zozoz,项目名称:OnlineJudgeSite,代码行数:14,代码来源:m6connector.py

示例13: main

	def main(self):
		proxy = Proxy();
		task = TaskPool();
		try:
			proxy.load_proxy(config.proxyfile);
			proxy.load_agent(config.agentfile);
			task.load_task(config.taskfile);
			pid = 0;
			while pid < config.pidnum:
				cr = Crawle(proxy,task);
				cr.start();
				pid += 1;
		except Exception as e:
			info = traceback.print_exc();
			logger.error(format(e));
			raise e;
开发者ID:dujinle,项目名称:WebDataCrawling,代码行数:16,代码来源:crawlemager.py

示例14: save

    def save(self, proxy_list, proxy_type='socks5', file_name="data/proxies.db"):
        """Save list of proxies in to the file
        """

        with open(file_name, 'a') as f:
            for proxy in proxy_list:
                f.write(Proxy.get_data() + '\n')
开发者ID:EvilDmitri,项目名称:ProxyAccumulator,代码行数:7,代码来源:keeper.py

示例15: query_proxies

def query_proxies():
    """
    查询已存可使用的proxies
    :return: set
    """
    query = Proxy.select().where(~(Proxy.status_code >> None))
    return set([proxy.proxy for proxy in query])
开发者ID:YieldNull,项目名称:avmoo,代码行数:7,代码来源:avmoo.py


注:本文中的proxy.Proxy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。