if os.path.isfile(self.lockFile): raise Exception("error - lock file %s exists" % self.lockFile) sys.exit(-1) else: os.system('touch %s' % self.lockFile) if self.doUpdate: self.controller.loadPlugins(self) self.controller.update() os.unlink(self.lockFile) return self.insertor.run() self.cleanup() syslog.openlog('insert-ethers', syslog.LOG_PID, syslog.LOG_LOCAL0) app = App(sys.argv) app.parseArgs() try: app.run() except Exception as msg: app.cleanup() sys.stderr.write('error - ' + str(msg) + '\n') syslog.syslog(syslog.LOG_ERR, 'error - %s' % msg) syslog.syslog(syslog.LOG_ERR, traceback.format_exc()) sys.exit(1)
self.localport = self.defaultport self.remoteport = self.defaultport # Check ports to see which one is open. If ports are already bound # go to the next one to check. Whatever binds is successfully is used. self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) done = 0 while done == 0: try: self.s.bind(("localhost", self.localport)) done = 1 except socket.error, (errno, string): if errno == 98: done = 0 self.localport = self.localport + 1 # Connect to the secure tunnel and go... self.createSecureTunnel() if self.ekv == 1: self.ekvviewer() else: self.vncviewer() return app = App(sys.argv) app.parseArgs() app.run()
from stack import app if __name__ == "__main__": app.run(debug=True)