11#!/usr/bin/env python
2-
32import sys
4-
5- sys .dont_write_bytecode = True
6-
73import glob
84import yaml
95import os
106import time
117import logging
8+
129from argparse import ArgumentParser
1310
1411from slackclient import SlackClient
1512
13+ sys .dont_write_bytecode = True
14+
1615
1716def dbg (debug_string ):
1817 if debug :
@@ -66,14 +65,14 @@ def output(self):
6665 if limiter :
6766 time .sleep (.1 )
6867 limiter = False
69- message = output [1 ].encode ('ascii' ,'ignore' )
68+ message = output [1 ].encode ('ascii' , 'ignore' )
7069 channel .send_message ("{}" .format (message ))
71- limiter = True # TODO: check goal: no sleep for 1st channel, sleep of all after ?
70+ limiter = True
71+ # TODO: check goal: no sleep for 1st channel, sleep of all after ?
7272 # TODO: find out how to safely encode stuff if needed :(
7373 # message = output[1].encode('utf-8','ignore')
7474 channel .send_message (output [1 ]) # message
7575
76-
7776 def crons (self ):
7877 for plugin in self .bot_plugins :
7978 plugin .do_jobs ()
@@ -82,18 +81,21 @@ def load_plugins(self):
8281 for plugin in glob .glob (directory + '/plugins/*' ):
8382 sys .path .insert (0 , plugin )
8483 sys .path .insert (0 , directory + '/plugins/' )
85- for plugin in glob .glob (directory + '/plugins/*.py' ) + glob .glob (directory + '/plugins/*/*.py' ):
84+ for plugin in glob .glob (directory + '/plugins/*.py' ) + \
85+ glob .glob (directory + '/plugins/*/*.py' ):
8686 logging .info (plugin )
8787 name = plugin .split ('/' )[- 1 ][:- 3 ]
8888 # try:
8989 self .bot_plugins .append (Plugin (name ))
9090 # except:
9191 # print "error loading plugin %s" % name
9292
93+
9394class Plugin (object ):
95+
9496 def __init__ (self , name , plugin_config = None ):
9597 if plugin_config is None :
96- plugin_config = {} # TODO: is this necessary?
98+ plugin_config = {} # TODO: is this necessary?
9799 self .name = name
98100 self .jobs = []
99101 self .module = __import__ (name )
@@ -179,7 +181,11 @@ class UnknownChannel(Exception):
179181
180182def main_loop ():
181183 if "LOGFILE" in config :
182- logging .basicConfig (filename = config ["LOGFILE" ], level = logging .INFO , format = '%(asctime)s %(message)s' )
184+ logging .basicConfig (
185+ filename = config ["LOGFILE" ],
186+ level = logging .INFO ,
187+ format = '%(asctime)s %(message)s'
188+ )
183189 logging .info (directory )
184190 try :
185191 bot .start ()
@@ -215,7 +221,7 @@ def parse_args():
215221 files_currently_downloading = []
216222 job_hash = {}
217223
218- if config . has_key ( " DAEMON" ) :
224+ if ' DAEMON' in config :
219225 if config ["DAEMON" ]:
220226 import daemon
221227
0 commit comments