1- #!/usr/bin/env python
1+ #!/usr/bin/env python3
22
3+ from __future__ import print_function
34import os
4- import Queue
5+ import queue
56import sys
67import traceback
78import time
89
910
10- class Bot ( object ) :
11+ class Bot :
1112 def __init__ (self ):
1213 self .conns = {}
1314 self .persist_dir = os .path .abspath ('persist' )
@@ -21,38 +22,38 @@ def main():
2122 sys .path += ['lib' ]
2223 os .chdir (os .path .dirname (__file__ ) or '.' ) # do stuff relative to the install directory
2324
24- print 'Loading plugins'
25+ print ( 'Loading plugins' )
2526
2627 # bootstrap the reloader
27- eval (compile (open (os .path .join ('core' , 'reload.py' ), 'U ' ).read (),
28+ eval (compile (open (os .path .join ('core' , 'reload.py' ), 'r ' ).read (),
2829 os .path .join ('core' , 'reload.py' ), 'exec' ),
2930 globals ())
3031 reload (init = True )
3132
32- print 'Connecting to IRC'
33+ print ( 'Connecting to IRC' )
3334
3435 try :
3536 config ()
3637 if not hasattr (bot , 'config' ):
3738 exit ()
38- except Exception , e :
39- print 'ERROR: malformed config file:' , e
39+ except Exception as e :
40+ print ( 'ERROR: malformed config file:' , e )
4041 traceback .print_exc ()
4142 sys .exit ()
4243
43- print 'Running main loop'
44+ print ( 'Running main loop' )
4445
4546 while True :
4647 reload () # these functions only do things
4748 config () # if changes have occured
4849
49- for conn in bot .conns .itervalues ():
50+ for conn in bot .conns .values ():
5051 try :
5152 out = conn .out .get_nowait ()
5253 main (conn , out )
53- except Queue .Empty :
54+ except queue .Empty :
5455 pass
55- while all (conn .out .empty () for conn in bot .conns .itervalues ( )):
56+ while all (conn .out .empty () for conn in iter ( bot .conns .values () )):
5657 time .sleep (.1 )
5758
5859if __name__ == '__main__' :
0 commit comments