def inthandler(signum, frame): """ Signal handler for ctrl-c """ import os from sensor import functions as f from sensor import dialog di = dialog.Dialog() logging.debug("SIGINT received") if f.managerStatus(str(os.getpid())): di.setBackgroundTitle('SURFids v3.0 sensor running on ' + f.system()) di.infobox("CTRL-C received, shutting down sensor...") # Shutting down the sensor try: f.sensorDown() except: logging.error("Could not shutdown the sensor during SIGINT") logging.debug("WATCHME inthandler cleanup phase") # Cleaning up temporary files f.cleanUp() # if os.path.exists(locations.OPENVPNPID): # os.unlink(locations.OPENVPNPID) os.system('clear') logging.warning("SURFids menu stopped (received ctrl-c)") sys.exit(1)
def inthandler(signum, frame): """ Signal handler for ctrl-c """ import os from sensor import functions as f from sensor import dialog di = dialog.Dialog() logging.debug("SIGINT received") logging.debug("WATCHMEEE INTHANDLER SIGINT received") if f.managerStatus(str(os.getpid())): di.setBackgroundTitle("SURFids v3.0 sensor running on " + f.system()) di.infobox("CTRL-C received, shutting down sensor...") # Shutting down the sensor try: logging.debug("WATCHMEEE INTHANDLER f.sensorDown") logging.debug("WATCHMEEE INTHANDLER tunnel status: %s" % str(f.tunnelStatus())) f.sensorDown() logging.debug("WATCHMEEE INTHANDLER tunnel status: %s" % str(f.tunnelStatus())) except: err = str(sys.exc_info()[1]) logging.debug("WATCHMEEE error: %s" % str(err)) logging.error("Could not shutdown the sensor during SIGINT") logging.debug("WATCHMEEE inthandler cleanup phase") # Cleaning up temporary files f.cleanUp() logging.debug("WATCHMEEE INTHANDLER tunnel status: %s" % str(f.tunnelStatus())) # if os.path.exists(locations.OPENVPNPID): # os.unlink(locations.OPENVPNPID) os.system("clear") logging.warning("SURFids menu stopped (received ctrl-c)") sys.exit(1)
def __init__(self): #self.d = dialog.Dialog(dialog="/usr/bin/Xdialog", compat="Xdialog") #self.d = dialog.Dialog(dialog="/usr/bin/zenity", compat="") logging.debugv("menu/__init__.py->__init__(self)", []) self.d = dialog.Dialog() self.d.setBackgroundTitle('SURFids sensor v3.0 running on ' + functions.system()) # c = config object self.c = c.Config()
logging.info("SURFids manager starting") try: f.networkUp() except excepts.ConfigException, msg: logging.warn(msg) except excepts.InterfaceException, msg: logging.warn(msg) except SystemExit: logging.info("Sensor manager exiting") except: self.handleException() if not f.tunnelStatus(): if self.c.getAutoStart() == "Enabled": logging.info("Sensor not active - Auto Starting") self.d.setBackgroundTitle('SURFids v3.0 running on ' + f.system()) self.d.infobox("Auto Starting sensor...") try: self.c.validNetConf() except excepts.ConfigException, err: self.d.infobox("Autostart Failed\n\nCONFIG ERROR: %s" % str(err)) else: try: f.sensorUp() except excepts.NetworkException, msg: msg = str(msg) self.d.msgbox("Autostart Failed\n\nNETWORK ERROR: " + msg) except excepts.ConfigException, msg: msg = str(msg)
logging.debugv("manager.py->run(self)", []) logging.info("SURFids manager starting") try: f.networkUp() except excepts.ConfigException, msg: logging.warn(msg) except excepts.InterfaceException, msg: logging.warn(msg) except SystemExit: logging.info("Sensor manager exiting") except: self.handleException() if not f.tunnelStatus(): if self.c.getAutoStart() == "Enabled": logging.info("Sensor not active - Auto Starting") self.d.setBackgroundTitle('SURFids v3.0 running on ' + f.system()) self.d.infobox("Auto Starting sensor...") try: self.c.validNetConf() except excepts.ConfigException, err: self.d.infobox("Autostart Failed\n\nCONFIG ERROR: %s" % str(err)) else: try: f.sensorUp() except excepts.NetworkException, msg: msg = str(msg) self.d.msgbox("Autostart Failed\n\nNETWORK ERROR: " + msg) except excepts.ConfigException, msg: msg = str(msg) self.d.msgbox("Autostart Failed\n\nCONFIG ERROR: " + msg) except excepts.InterfaceException, msg: