8 modules
['q'] = (__import__('modules.q', globals(), locals(), ['Pseudo'], 0)).Pseudo()
14 'address': '127.0.0.1',
17 'password': 'password',
18 'vhost': '', #bind to this ip - empty string '' for auto-select
24 if words
[1] == "G" or words
[1] == "PING":
26 uplink
.send("Z %(numeric)s :%(id)s" % {'numeric': config.numeric, 'id': config.uplink['name']}
)
29 def __init__(self
, numeric
, name
):
31 self
.numeric
= numeric
34 def send(self
, line
, source
=None, **kwargs
):
36 source
= config
.numeric
37 uplink
._transmit
(source
+" "+(line
% kwargs
))
40 def __init__(self
, *args
, **kwargs
):
42 super(Uplink
, self
).__init
__(*args
, **kwargs
)
47 self
.sock
= socket
.socket()
48 self
.sock
.bind((config
.uplink
['vhost'], 0))
49 self
.sock
.connect((config
.uplink
['address'], config
.uplink
['port']))
51 self
._transmit
("PASS %s" % (config
.uplink
['password']))
52 self
._transmit
("SERVER %(name)s 1 %(time)s %(time)s J10 %(numeric)s]]] +s :PyP10 Services" % {'name': config.name, 'time': time.time(), 'numeric': config.numeric}
)
54 self
._transmit
("]S G services.p10 test.p10") #todo
56 def _transmit(self
, line
):
58 self
.sock
.sendall(line
+"\r\n")
60 self
.data
+= self
.sock
.recv(4096)
61 while "\n" in self
.data
:
62 pieces
= self
.data
.split("\n", 1)
63 line
= pieces
[0].strip()
71 keepgoing
= self
._receive
()
74 class Account(object):
80 uplink
= Uplink(-1, '')