diff -r e24793fae424 -r 1b734faab67a cobalt.py --- a/cobalt.py Tue Aug 11 19:12:30 2015 +0300 +++ b/cobalt.py Sun Aug 16 10:59:22 2015 +0300 @@ -38,17 +38,21 @@ import hgpoll as HgPoll import bt as Bt import irc as Irc -import rest as Rest +import rest if __name__ != '__main__': raise ImportError ('cobalt may not be imported as a module') +if sys.version_info < (3, 0): + print ('''cobalt requires Python 3 to run''', file=sys.stderr) + quit (1) + g_BotActive = False # # Exception handling # -def handle_exception(excType, excValue, trace): +def handle_exception (excType, excValue, trace): excepterm (traceback.format_exception(excType, excValue, trace)) def excepterm (data): @@ -58,7 +62,7 @@ Irc.broadcast (line) for client in Irc.all_clients: - if len(data) > 0: + if data: client.exceptdie() else: client.quit_irc() @@ -78,12 +82,10 @@ g_BotActive = False try: - uid = os.geteuid() + if os.geteuid() == 0 and input ('Do you seriously want to run cobalt as root? [y/N] ') != 'y': + quit() except: - uid = -1 - - if uid == 0 and raw_input ('Do you seriously want to run cobalt as root? [y/N] ') != 'y': - quit() + pass ConfigFile.init() ModuleCore.init_data() @@ -104,10 +106,9 @@ break else: raise ValueError ('unknown autoconnect entry "%s"' % (aconn)) - - # Start the REST server + if Config.get_node ('rest').get_value ('active', True): - Rest.RESTServer() + rest.RestServer() g_BotActive = True asyncore.loop()