# HG changeset patch # User Santeri Piippo # Date 1403359918 -10800 # Node ID 2603faf5f91b584cac867816da707b47a96a8329 # Parent ca618214fd0767b3c0338aced9cac4fa7c13d4f9 - don't run as root without asking first, added more startup messages diff -r ca618214fd07 -r 2603faf5f91b cobalt.py --- a/cobalt.py Sat Jun 21 16:42:03 2014 +0300 +++ b/cobalt.py Sat Jun 21 17:11:58 2014 +0300 @@ -41,6 +41,15 @@ import suds try: + uid = os.geteuid() +except: + uid = -1 + +if uid == 0 and raw_input ('Do you seriously want to run cobalt as root? [y/N] ') != 'y': + quit() + +print 'Loading configuration...' +try: with open ('cobalt.json', 'r') as fp: g_config = json.loads (fp.read()) except IOError as e: @@ -58,10 +67,12 @@ suds_active = False try: + print 'Initializing MantisBT connection...' suds_import = suds.xsd.doctor.Import ('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/') suds_client = suds.client.Client ('https://zandronum.com/tracker/api/soap/mantisconnect.php?wsdl', plugins=[suds.xsd.doctor.ImportDoctor (suds_import)]) suds_active = True -except Exception: +except Exception as e: + print 'Failed to establish MantisBT connection: ' + `e` pass btannounce_active = False @@ -89,10 +100,11 @@ if suds_active: try: + sys.stdout.write ('Retrieving latest tracker ticket... ') btannounce_id = suds_client.service.mc_issue_get_biggest_id (g_config['trackeruser'], g_config ['trackerpassword'], 0) btannounce_active = True bt_updatechecktimeout() - print "Latest ticket on tracker: %d" % btannounce_id + print btannounce_id except Exception as e: pass