Sat, 21 Jun 2014 17:11:58 +0300
- don't run as root without asking first, added more startup messages
cobalt.py | file | annotate | diff | comparison | revisions |
--- 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