3
# copy this script to the botdir,edit and run it
4
# example: dcctest.py 10 0 .. this starts 10 test clients and sleep 0 sec
7
__copyright__ = 'this file is in the public domain'
13
listenip = '127.0.0.1'
18
from gozerbot.generic import handle_exception, rlog, enable_logging, setdefenc
19
from gozerbot.config import config
21
rlog(100, 'dcctest', 'starting...')
22
config['loglevel'] = 10
23
from gozerbot.plugins import plugins
24
from gozerbot.examples import examples
25
import gozerbot.generic
28
import sys, time, socket, thread, struct, os, random, signal
32
starttime = time.time()
34
if not len(sys.argv) == 4:
35
print 'i need three arguments: 1) nrloops 2) nrclients 3) timetosleep'
38
nrloops = int(sys.argv[1])
39
nrbots = int(sys.argv[2])
40
timetosleep = float(sys.argv[3])
43
print str(commandsdone/(time.time()-starttime)) + " commands per second"
44
gozerbot.generic.die()
46
# register SIGTERM handler to stop
47
signal.signal(signal.SIGTERM, stop)
48
signal.signal(signal.SIGINT, stop)
54
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
55
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
56
s.bind((listenip, int(port)))
66
insocket, addr = s.accept()
70
thread.start_new_thread(serve, (insocket, ))
72
thread.start_new_thread(dodcctest, ('test' + str(teller), \
78
f = insocket.makefile()
84
rlog(100, 'DCC', r.strip())
90
donot = ['reboot', 'cycle', 'loglevel', 'quit', 'email', 'meet', 'nick', \
91
'part', 'cc', 'chat', 'join', ' nick', 'update', 'install', \
92
'reconnect', 'jump', 'nonfree', 'relay', 'rss', 'fleet', 'sendraw', \
93
'upgrade', 'alarm', 'remind', 'intro', 'host', 'ip', 'alarm', 'tests', \
94
'unload', 'delete', 'dfwiki', 'dig', 'silent', 'reconnect', 'switch', 'op',
95
'dict', 'slashdot', 'films', 'latest', 'weather', 'coll', 'web', 'mail', \
96
'markov', 'probe', 'sc', 'log', 'validate']
98
def dodcctest(name, insocket, nrloop):
99
a = examples.getexamples()
115
rlog(100, '%s %s-%s' % (name, nrloop, teller), 'sending ' \
117
insocket.send('!' + str(z) + ' chan ' + channel + '\n')
120
thread.start_new_thread(listen, ())
123
testnick = mynick + str(nr)
124
#i = gozerbot.bot.Bot('test@test', 'test')
125
i = gozerbot.irc.Irc()
127
i.connect(testnick, server, 6667)
130
ipip2 = socket.inet_aton(listenip)
131
ipip = struct.unpack('>L', ipip2)[0]
132
zz = 'DCC CHAT CHAT %s %s' % (ipip, port)
135
for i in range(nrbots):
136
thread.start_new_thread(startirc, (i, ))
137
time.sleep(timetosleep)