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


Python Client.Client类代码示例

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


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

示例1: setUp

    def setUp(self):
        self.done = False
        self.cFactory = pb.PBClientFactory()
        self.realm = WBRealm()
        self.realm.server = WbServer()
        self.wbServer = self.realm.server
        self.p = portal.Portal(self.realm)
        self.c = WBChecker()
        self.p.registerChecker(self.c)
        self.sFactory = pb.PBServerFactory(self.p)
        self.sFactory.protocol = WBBroker
        self.server = reactor.listenTCP(28789, self.sFactory)

        self.myClient = Client()
        self.myClient2 = Client()
        self.client = reactor.connectTCP("localhost", 28789, self.cFactory)
        self.client2 = reactor.connectTCP("localhost", 28789, self.cFactory)
        def1 = self.cFactory.login(credentials.UsernamePassword("Waldo","waldo"), client=self.myClient.cc)
        def1.addCallback(self.getRoot, 1)
        def1.addErrback(self.failure, "Error al conectarse el cliente1")
        deferredResult(def1)

        def2 = self.cFactory.login(credentials.UsernamePassword("Matias","matias"), client=self.myClient2.cc)
        def2.addCallback(self.getRoot, 2)
        def2.addErrback(self.failure, "Error al conectarse el cliente2")
        deferredResult(def2)
开发者ID:mgaitan,项目名称:beppo,代码行数:26,代码来源:testClientConnection.py

示例2: Client

 def test_connect_from_server_if_encrypted_message_cannot_be_decrypted_to_two_elements_will_return_error_signal(
         self):
     client = Client(client_id=None, client_key=3197, server=None, server_id=None)
     random_value_from_server = 11
     encrypted_message = encrypt('{0}:{1}'.format('nonce', 'session-key'), self.client_key)
     response = client.process_message_from_server((random_value_from_server, encrypted_message))
     self.assertEqual(response, client.error_signal)
开发者ID:jan-osch,项目名称:Otway-Rees-BSK,代码行数:7,代码来源:test_client.py

示例3: run_client

def run_client(host, port):
    selfClient = Client(host, int(port))
    selfClient._connect()
    input.append(selfClient.clientSocket)
    input.append(sys.stdin)
    running = True
    print "Connection established. Please set your name with /name to start chatting."   

 
    while running is True: 
        inready,outready,exready = select.select(input,[],[]) 

        for s in inready:
            # Receiving information from the other user (the server).
            if s == selfClient.clientSocket:
                data = s.recv(SIZE)
                if data:
                    print data
                else:
                    s.close()
                    print ERROR_MSG['conClosed']
                    running = False
                    break
            # Sending information to the other users via the server.
            if s == sys.stdin: 
                userText = sys.stdin.readline() 
                line = userText.rstrip("\r\n")
                selfClient.clientSocket.send(line)

    selfClient._close()
开发者ID:elizabethnguyen,项目名称:chat-client,代码行数:30,代码来源:chat-client.py

示例4: App

class App(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.ui.connect_button.clicked.connect(self.start)
        self.ui.send_button.clicked.connect(self.send_msg)

        self.client = None

    def start(self):
        server = self.ui.server_text.text()
        username = self.ui.user_text.text()


        self.client = Client(username, server)
        self.client.new_message.connect(self.print_msg)

        self.ui.chat_text.setEnabled(True)
        self.ui.message_text.setEnabled(True)
        self.ui.send_button.setEnabled(True)

    def send_msg(self):
        message = self.ui.message_text.text()
        self.ui.message_text.clear()
        self.client.send(message)

    def print_msg(self, message):
        self.ui.chat_text.append(message)
开发者ID:carlgonz,项目名称:zmq_examples,代码行数:31,代码来源:main_client.py

示例5: __init__

 def __init__(self, connectID,server):
     try:
         Client.__init__(self, connectID,server)
         self.__initData()
     except BaseException,e:
         print "Player Init Error"
         print e
开发者ID:kelvict,项目名称:Online-GoBang-Center,代码行数:7,代码来源:Player.py

示例6: submitParsingRequest

	def submitParsingRequest(self,
							parsingRequest):

		gearmanClient = Client(ClientManager.JOB_SERVER_ADDRESS_LIST,
								parsingRequest)
		gearmanClient.run()
		gearmanClient = None
开发者ID:chuongnn,项目名称:ClientManager,代码行数:7,代码来源:ClientManager.py

示例7: main

def main():

    # Establish the server cluster
    s1 = Server()
    s2 = Server()
    s3 = Server()
    s4 = Server()
    s5 = Server()

    s1.setNeighbors([s2, s3, s4, s5])
    s2.setNeighbors([s1, s3, s4, s5])
    s3.setNeighbors([s2, s1, s4, s5])
    s4.setNeighbors([s2, s3, s1, s5])
    s5.setNeighbors([s2, s3, s4, s1])

    t1 = Thread(target=s1.electionTimeout)
    t1.start()
    time.sleep(5)
    t2 = Thread(target=s2.electionTimeout)
    t2.start()
    t3 = Thread(target=s3.electionTimeout)
    t3.start()
    t4 = Thread(target=s4.electionTimeout)
    t4.start()
    t5 = Thread(target=s5.electionTimeout)
    t5.start()

    # Connect the client to the cluster leader
    c1 = Client()
    c1.connectClientToLeader(s2.neighbors)

    # Use the command line
    c1.waitForCommands()
开发者ID:gddmkr42171822,项目名称:csci5673,代码行数:33,代码来源:Main.py

示例8: SharedirsSet

class SharedirsSet(object):
    def do_set(self, sharedirs, callback):
        sharedirs_element = Element('sharedirs')
        #TODO : gérer l'utf-8 (é) ...
        for sharedir in sharedirs:
           sharedir_element = SubElement(sharedirs_element, 'sharedir', {'name':sharedir.name, 'path':sharedir.path})
        self.client = Client(sharedirs_element, AnalyseSharedirs(callback))
        self.client.start()
开发者ID:MaximeCheramy,项目名称:pyrex,代码行数:8,代码来源:sharedirs.py

示例9: run_http_post

def run_http_post():
    #initialize a progressbar
    p = Progressbar(flow)
    client = Client(p)
    #run the wanted client method
    if args.endurance == None:
        client.send_http_post(ip, httpport, flow, delay, size)
    else:
        client.send_http_post_time(ip, httpport, endurance, delay, size)
开发者ID:Darot,项目名称:ZEUS-FH,代码行数:9,代码来源:cli.py

示例10: __init__

    def __init__(self):
        self.Alice = Client()
        self.Alice.open_connection()

        self.Bob = Client()
        self.Bob.open_connection()

        self.Eve = Client()
        self.Eve.open_connection()

        self.alice_stolen_password = ""
开发者ID:aryeko,项目名称:MITM,代码行数:11,代码来源:Eve.py

示例11: run_zmq_sub

def run_zmq_sub():
    #initialize a progressbar
    p = Progressbar(flow)
    time.sleep(6)
    client = Client(p)
    #run the wanted client method
    if args.endurance == None:
        client.subscriber(flow, ip, port)
    else:
        client.subscriber_time(endurance, ip, port)
    print "Transmission complete!"
开发者ID:Darot,项目名称:ZEUS-FH,代码行数:11,代码来源:cli.py

示例12: Search

class Search(object):
    def __init__(self, query):
        self.query = query
        
    def do_search(self, callback):
        search_element = Element('search', 
                        {'ttl': '3', 'id': str(randint(1, 10000000))})
        query_element = SubElement(search_element, 'query')
        query_element.text = self.query
    
        self.client = Client(search_element, AnalyseResults(callback))
        self.client.start()
开发者ID:Jerk31,项目名称:pyrex,代码行数:12,代码来源:search.py

示例13: run_req

def run_req():
    #initialize a progressbar
    p = Progressbar(flow)
    time.sleep(6)
    #new Client instanz
    client = Client(p)
    #run the wanted client method
    if args.endurance == None:
        client.sendAsync(flow, size, delay, ip, port)
    else:
        client.sendAsync_time(endurance, size, delay, ip, port)
    print "Transmission complete!"
开发者ID:Darot,项目名称:ZEUS-FH,代码行数:12,代码来源:cli.py

示例14: StatisticsGet

class StatisticsGet(object):
    def __init__(self, callback, hostname=Configuration.ip_daemon):
        self.hostname = hostname
        self.callback = callback

    def do_get(self):
        search_element = Element('statistics', {'type': 'get'})
        self.client = Client(search_element, AnalyseStatistics(self.callback), self.hostname)
        self.client.start()

    def cancel(self):
        self.client.cancel()
开发者ID:MaximeCheramy,项目名称:pyrex,代码行数:12,代码来源:stats.py

示例15: mkDevice

def mkDevice(screen, x, y, id):
    if id.isdigit():
        subnet = Subnet(screen, x, y)
        subnet.IP = IP(int(id))
        return subnet
    elif id == "N":
        dns = DNS(screen, x, y)
        dns.IP = str(ord(list(id)[0]))
        return dns
    elif id.isupper():
        router = Router(screen, x, y)
        router.IP = str(ord(list(id)[0]))
        router.selected = router.IP == "66"
        return router
    elif id.islower():
        if id == "h":
            host = Client(screen, x, y)
            host.name = "Alice"
            host.corespondent = "Bob"
        elif id == "x":
            host = Client(screen, x, y)
            host.name = "Bob"
            host.corespondent = "Alice"
        else:
            host = Host(screen, x ,y)
        host.IP = str(ord(list(id)[0]))
        return host
    else:
        print "Unrecognized unique identifier in sprite map"
        return None
开发者ID:mgold,项目名称:Packets,代码行数:30,代码来源:main.py


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