wrap bot.py in a main() function to be import-safe
This commit is contained in:
parent
62fbe6e237
commit
921b986683
12
bot.py
12
bot.py
|
@ -6,10 +6,6 @@ import sys
|
||||||
import traceback
|
import traceback
|
||||||
import time
|
import time
|
||||||
|
|
||||||
sys.path += ['plugins'] # so 'import hook' works without duplication
|
|
||||||
sys.path += ['lib']
|
|
||||||
os.chdir(sys.path[0] or '.') # do stuff relative to the install directory
|
|
||||||
|
|
||||||
|
|
||||||
class Bot(object):
|
class Bot(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -18,6 +14,11 @@ class Bot(object):
|
||||||
if not os.path.exists(self.persist_dir):
|
if not os.path.exists(self.persist_dir):
|
||||||
os.mkdir(self.persist_dir)
|
os.mkdir(self.persist_dir)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
sys.path += ['plugins'] # so 'import hook' works without duplication
|
||||||
|
sys.path += ['lib']
|
||||||
|
os.chdir(sys.path[0] or '.') # do stuff relative to the install directory
|
||||||
|
|
||||||
bot = Bot()
|
bot = Bot()
|
||||||
|
|
||||||
print 'Loading plugins'
|
print 'Loading plugins'
|
||||||
|
@ -52,3 +53,6 @@ while True:
|
||||||
pass
|
pass
|
||||||
while all(conn.out.empty() for conn in bot.conns.itervalues()):
|
while all(conn.out.empty() for conn in bot.conns.itervalues()):
|
||||||
time.sleep(.1)
|
time.sleep(.1)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in New Issue