本文整理汇总了Python中Client.Client.start方法的典型用法代码示例。如果您正苦于以下问题:Python Client.start方法的具体用法?Python Client.start怎么用?Python Client.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client.Client
的用法示例。
在下文中一共展示了Client.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SharedirsSet
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
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()
示例2: Search
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
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()
示例3: StatisticsGet
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
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()
示例4: ConfDaemon
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
class ConfDaemon(object):
def __init__(self, callback, nickname=None, time_between_scan=None, nb_ips_scan_lan=None, ip_range=None, ips_remote_control=None, ftp_enabled=None, ftp_port=None, ftp_maxlogins=None, ftp_show_downloads=None):
self.callback = callback
self.nickname = nickname
self.time_between_scan = time_between_scan
self.nb_ips_scan_lan = nb_ips_scan_lan
self.ip_range = ip_range
self.ips_remote_control = ips_remote_control
self.ftp_enabled = ftp_enabled
self.ftp_port = ftp_port
self.ftp_maxlogins = ftp_maxlogins
self.ftp_show_downloads = ftp_show_downloads
def set_conf(self):
set_conf_element = Element('conf', {'type':'set'})
# Nickname
nickname_element = SubElement(set_conf_element, 'nickname')
nickname_element.text = self.nickname
# Time between scan
time_between_scan_element = SubElement(set_conf_element, 'time_between_scan')
time_between_scan_element.text = str(self.time_between_scan)
# Nb IP à scanner
nb_ips_scan_lan_element = SubElement(set_conf_element, 'nb_ips_scan_lan')
nb_ips_scan_lan_element.text = str(self.nb_ips_scan_lan)
# Plage IP
ip_range_element = SubElement(set_conf_element, 'ip_range')
ip_range_element.text = self.ip_range
# IP config daemon
ips_remote_control_element = SubElement(set_conf_element, 'ips_remote_control')
ips_remote_control_element.text = self.ips_remote_control
# FTP activé
ftp_enabled_element = SubElement(set_conf_element, 'ftp_enabled')
ftp_enabled_element.text = self.ftp_enabled and "true" or "false"
# Port FTP
ftp_port_element = SubElement(set_conf_element, 'ftp_port')
ftp_port_element.text = str(self.ftp_port)
# Max Connex simultanées FTP
ftp_maxlogins_element = SubElement(set_conf_element, 'ftp_maxlogins')
ftp_maxlogins_element.text = str(self.ftp_maxlogins)
# Afficher dwl FTP
ftp_show_downloads_element = SubElement(set_conf_element, 'ftp_show_downloads')
ftp_show_downloads_element.text = self.ftp_show_downloads and "true" or "false"
# On envoie au client
self.client = Client(set_conf_element, AnalyseConfDaemon(self.callback))
self.client.start()
def get_conf(self):
get_conf_element = Element('conf', {'type':'get'})
self.client = Client(get_conf_element, AnalyseConfDaemon(self.callback))
self.client.start()
示例5: d_mf
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
def d_mf(comm, wk_comm, local_data, local_P, k, steps=500, alpha=0.0002, beta=0.02):
zeros = numpy.zeros(k)
client = Client(comm, wk_comm)
client.start()
my_rank = comm.Get_rank()
for row in local_data:
client.inc(my_rank, row[1] - 1, zeros)
local_Q = dict()
e = 0
for step in range(steps):
print('rank %d, iter=%d' % (my_rank, step))
client.clock(my_rank, e)
local_Q.clear()
for row in local_data:
# 需要减去偏移值
ii = int(row[0] - local_data[0][0])
jj = int(row[1] - 1)
value = float(row[2])
q = local_Q.get(jj)
if q is None:
q = local_Q[jj] = client.pull(my_rank, jj)
log('%d %d %f %s' % (ii, jj, value, str(q)))
eij = value - numpy.dot(local_P[ii], q)
local_P[ii] += alpha * (2 * eij * q - beta * local_P[ii])
for row in local_data:
ii = int(row[0] - local_data[0][0])
jj = int(row[1] - 1)
value = float(row[2])
q = local_Q.get(jj)
eij = value - numpy.dot(local_P[ii], q)
client.inc(my_rank, jj, alpha * (2 * eij * local_P[ii] - beta * q))
e = 0.0
for row in local_data:
ii = row[0] - local_data[0][0]
jj = row[1] - 1
value = row[2]
if abs(value - 0.0) > 0.000001:
e += pow(numpy.dot(local_P[ii], local_Q[jj]) - value, 2)
client.stop(my_rank)
MPI.Finalize()
return
示例6: main
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
def main(topic):
util.initLogs()
client1 = Client(event_delay=1, topics=[topic], name='Stranger 1')
client2 = Client(event_delay=1, topics=[topic], name='Stranger 2')
client1.register_other_client(client2)
client2.register_other_client(client1)
client1.start()
util.waitForClient(client1, topic)
client2.start()
while client1.isAlive() or client2.isAlive():
try:
client1.join(0.1)
client2.join(0.1)
except KeyboardInterrupt:
break
util.logPrint( 'Disconnecting... ')
client1.stop()
client2.stop()
示例7: Search
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
class Search(object):
def __init__(self, query, protocol=None, type_share=None, extensions="", sizeinf=None, sizesup=None, dateinf=None, datesup=None):
self.query = query
self.protocol = protocol
self.type_share = type_share
self.extensions = extensions
self.sizeinf = sizeinf
self.sizesup = sizesup
self.dateinf = dateinf
self.datesup = datesup
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
if self.protocol:
protocol_element = SubElement(search_element, 'protocol')
protocol_element.text = self.protocol
elif self.type_share:
type_share_element = SubElement(search_element, 'type')
type_share_element.text = self.type_share
elif self.extensions:
extensions_element = SubElement(search_element, 'extensions')
extensions_element.text = self.extensions
elif self.sizeinf:
sizeinf_element = SubElement(search_element, 'sizeinf')
sizeinf_element.text = str(self.sizeinf)
elif self.sizesup:
sizesup_element = SubElement(search_element, 'sizesup')
sizesup_element.text = str(self.sizesup)
elif self.dateinf:
dateinf_element = SubElement(search_element, 'dateinf')
dateinf_element.text = self.dateinf
elif self.datesup:
datesup_element = SubElement(search_element, 'datesup')
datesup_element.text = self.datesup
self.client = Client(search_element, AnalyseResults(callback))
self.client.start()
示例8: VersionGet
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
class VersionGet(object):
def do_get(self, callback):
search_element = Element('version', {'type': 'get'})
self.client = Client(search_element, AnalyseVersion(callback))
self.client.start()
示例9: StatisticsGet
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
class StatisticsGet(object):
def do_get(self, callback):
search_element = Element('statistics', {'type': 'get'})
self.client = Client(search_element, AnalyseStatistics(callback))
self.client.start()
示例10: threadCode
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
def threadCode(values):
for variable in conf["values"]:
conf[conf["variable"]] = variable
# you always need one database instance for every experiment
database = instancesRetriever.createDatabase(conf["databaseType"])
numberOfClientInstances = conf["clientInstances"][0]
clientType = conf["clientInstances"][1]
clientIPs = []
clients = []
for i in range(0, numberOfClientInstances):
inst = instancesRetriever.createClient(clientType)
clients.append(inst)
clientIPs.append((inst.ip_address, inst.private_ip_address, inst.instance_type))
numberOfMiddlewareInstances = conf["middlewareInstances"][0]
middlewareType = conf["middlewareInstances"][1]
middlewareIPs = []
middlewares = []
for i in range(0, numberOfMiddlewareInstances):
inst = instancesRetriever.createMiddleware(middlewareType)
middlewares.append(inst)
middlewareIPs.append((inst.ip_address, inst.private_ip_address, inst.instance_type))
databaseIP = (database.ip_address, database.private_ip_address)
print "IPs of machines that are going to be used"
print "Database"
print databaseIP[0] + ": " + databaseIP[1] + ":" + database.instance_type
print "Clients"
for client in clientIPs:
print client[0] + ": " + client[2]
print "Middlewares"
for middleware in middlewareIPs:
print middleware[0] + ": " + middleware[2]
# clean database
auxiliaryFunctionsFilePath = "../../src/main/resources/auxiliary_functions.sql"
basicFunctionsFilePath = "../../src/main/resources/read_committed_basic_functions.sql"
print ">>> Going to clean and initialize database"
db = Database(databaseIP[0], conf["databasePortNumber"], conf["databaseName"], conf["databaseUsername"],
conf["databasePassword"])
db.recreateDatabase()
db.initializeDatabase(conf["totalClients"], conf["totalQueues"],
[auxiliaryFunctionsFilePath, basicFunctionsFilePath])
print ">>> Database was cleaned and initialized!"
print ">>> Starting CPU, memory and network utilization logging in database"
db.startLogging(conf["username"]) # start logging CPU, memory and network utilization
print ">>> Database logging started"
# transfer the JAR to the clients & middlewares
print ">>> transferring executable JAR to clients & middlewares"
for client in clientIPs:
scpTo(jarFile, "", conf["username"], client[0])
print "JAR moved to client with IP: " + client[0]
for middleware in middlewareIPs:
scpTo(jarFile, "", conf["username"], middleware[0])
print "JAR moved to middleware with IP: " + middleware[0]
print ">>> executable JAR was transferred to the clients & middlewares"
middlewareInstances = []
for middlewareIP in middlewareIPs:
middleware = Middleware(conf["username"], middlewareIP[0], databaseIP[1], conf["databasePortNumber"],
conf["databaseUsername"], conf["databasePassword"], conf["databaseName"],
str(conf["threadPoolSize"]), str(conf["connectionPoolSize"]),
str(conf["middlewarePortNumber"]))
print middleware
middlewareInstances.append(middleware)
clientInstances = []
i = 0
for mapping in conf["mappings"]:
privateIPOfCorrespondingMiddleware = middlewareIPs[mapping[1]][1]
client = Client(conf["username"], clientIPs[mapping[0]][0], privateIPOfCorrespondingMiddleware,
str(conf["middlewarePortNumber"]), str(conf["clientsData"][i][0]),
str(conf["totalClients"]),
str(conf["totalQueues"]),
str(conf["messageSize"]),
str(conf["clientsData"][i][1]),
str(conf["runningTimeInSeconds"]))
clientInstances.append(client)
i += 1
# clean the clients & MW from old logs and get the ready for the current experiment
# assumes file exists "~/logs" in the corresponding machines
print ">>> going to clean clients ..."
for client in clientInstances:
client.clean()
client.getReady()
#.........这里部分代码省略.........
示例11: Client
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
secret=(3, 27))
charlie = Client(server_input_queue=server_input_queue,
server_output_queue=server_output_queue,
name='charlie',
h_0='5478',
K=50,
key='5678',
secret=(7, 21))
assert alice.successfully_finished is None
assert bob.successfully_finished is None
assert charlie.successfully_finished is None
server.start()
alice.start()
bob.start()
charlie.start()
killed = False
alice.join(timeout=30)
bob.join(timeout=30)
charlie.join(timeout=30)
server.finish()
server.join(timeout=30)
if active_count() > 1:
for t in enumerate():
if t != current_thread():
print t
t._Thread__stop()
示例12: SharedirsGet
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
class SharedirsGet(object):
def do_get(self, callback):
search_element = Element('sharedirs', {'type': 'get'})
self.client = Client(search_element, AnalyseSharedirs(callback))
self.client.start()
示例13: generate_random_key
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
import sys
id_for_alice = 'alice'
id_for_bob = 'bob'
key_for_alice = generate_random_key()
key_for_bob = generate_random_key()
trusted_server = TrustedServer(keys={id_for_alice: key_for_alice, id_for_bob: key_for_bob},max_connections=10)
trusted_server.start()
server = Server(server_id=id_for_bob, server_key=key_for_bob, max_connections=10, trusted_server=trusted_server)
server.start()
client = Client(client_id=id_for_alice, client_key=key_for_alice, server=server, server_id=id_for_bob)
client.start()
def clean():
client.join(120)
server.finish()
trusted_server.finish()
server.join(120)
trusted_server.join(120)
t = Thread(target=clean)
t.start()
t.join(360)
if active_count() > 1:
for t in enumerate():
print t
if t != current_thread():
示例14: ChatInterface
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
class ChatInterface(object):
def __init__(self, host, port, username):
'''
Sets up and initializes
'''
self.host = host
self.port = port
self.username = username
self.running = True
self.client = Client(self)
self.client.start(self.host, int(self.port))
self.lock = Lock()
self.NR_OF_MESSAGES_TO_DISPLAY = 15
self.stdscr = None
curses.wrapper(self.main)
def main(self, stdscr):
self.stdscr = stdscr
curses.echo()
self.client.login(self.username)
time.sleep(1) #delay, in case of poor connection
self.main_loop(stdscr)
def main_loop(self, stdscr):
while self.running:
if self.client.logged_in:
self.stdscr.clear()
with self.lock:
self.display_messages()
message = self.stdscr.getstr()
self.parse(message)
self.stdscr.refresh()
else:
self.stdscr.clear()
for i in xrange(len(self.client.messages)):
self.stdscr.addstr(i, 0, self.client.messages[i])
self.stdscr.addstr(self.NR_OF_MESSAGES_TO_DISPLAY, 0, '--> Please enter username to log in:')
self.stdscr.move(self.NR_OF_MESSAGES_TO_DISPLAY + 1, 0)
username = self.stdscr.getstr()
self.client.login(username)
self.stdscr.refresh()
time.sleep(1)
def display_messages(self):
if self.client.messages:
if len(self.client.messages) < self.NR_OF_MESSAGES_TO_DISPLAY:
for i in xrange(len(self.client.messages)):
self.stdscr.addstr(i, 0, self.client.messages[i])
else:
for i in xrange(self.NR_OF_MESSAGES_TO_DISPLAY):
self.stdscr.addstr(i, 0, self.client.messages[len(self.client.messages) - (self.NR_OF_MESSAGES_TO_DISPLAY) + i])
self.stdscr.addstr(self.NR_OF_MESSAGES_TO_DISPLAY, 0, '--> Enter a message:')
self.stdscr.move(self.NR_OF_MESSAGES_TO_DISPLAY + 1, 0)
self.stdscr.refresh()
def parse(self, message):
if message == 'logout':
self.client.logout()
else:
self.client.send_message(message)
示例15: Server
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import start [as 别名]
keys=keys,
server_id='bob')
bob = Server(name='bob',
g=g,
p=p,
input_queue=queue_to_server,
output_queue=queue_to_client,
rsa_obj=rsa_bob,
keys=keys,
client_id='alice')
assert alice.K is None
assert bob.K is None
assert alice.finished_successfully is None
assert bob.finished_successfully is None
alice.start()
bob.start()
alice.join(timeout=50)
bob.join(timeout=50)
killed = False
if alice.is_alive():
alice._Thread__stop()
killed = True
if bob.is_alive():
bob._Thread__stop()
killed = True
if killed:
sys.exit(1)
assert alice.finished_successfully is True
assert bob.finished_successfully is True
assert alice.K == bob.K