def start_service(self, widget, data=None): """ Look for an open port then start the webservice on that port. """ port = str(pscan()) if not hasattr(self, 'server_pid') or self.server_pid is None: if re.search(r"python(.exe)?$", sys.executable): self.server_process = subprocess.Popen([sys.executable, 'server.py', port]) else: if re.search(r".exe$", sys.executable): exe = 'server.exe' else: exe = 'server' #path = get_path(sys.executable) path = os.path.dirname(sys.executable) print "executable path %r" % path os.chdir(path) path = os.path.join(path, exe) self.server_process = subprocess.Popen([path, port]) self.server_pid = self.server_process.pid self.server_host = DOMAIN self.server_port = port # let's open the browser time.sleep(2) webbrowser.open("http://%s:%s" % (DOMAIN, self.server_port))
def start_service(self): """ Look for an open port then start the webservice on that port. """ port = str(pscan()) if not hasattr(self, 'server_pid') or self.server_pid is None: start_server(self, port) # let's open the browser time.sleep(2) webbrowser.open("http://%s:%s" % (HOST, self.server_port))
def restart_service(self, widget, data=None): """ Look for an open port then start the webservice on that port. """ if hasattr(self, 'server_pid') and self.server_pid: try: try: urllib2.urlopen("http://%s:%s/stop" % ("127.0.0.1", self.server_port), timeout=1) except Exception, e: pass self.server_process.wait() self.server_pid = None except IOError, e: print "ignoring IOError %r" % e port = str(pscan()) from settings import HOST as DOMAIN if not is_online(): DOMAIN = "127.0.0.1" if not hasattr(self, 'server_pid') or self.server_pid is None: if re.search(r"python(.exe)?$", sys.executable): self.server_process = subprocess.Popen([sys.executable, 'server.py', port]) else: if re.search(r".exe$", sys.executable): exe = 'server.exe' else: exe = 'server' #path = get_path(sys.executable) path = os.path.dirname(sys.executable) os.chdir(path)
objc.classAddMethod(systrayosx.Backup, "withUpdateDialog:", withUpdateDialog_) objc.classAddMethod(systrayosx.Backup, "withoutUpdateDialog:", withoutUpdateDialog_) app = NSApplication.sharedApplication() menus = [ (('Open Dashboard', 'openDashboard:', ''), openDashboard_), (('Start', 'startService:', ''), startService_), #(('Stop', 'stopService:', ''), stopService_), (('Check for updates', 'checkUpdates:', ''), checkUpdates_), (('Quit', 'quitServices:', ''), quitServices_) #(('Open at Login', 'toggleOpenAtLogin:'******''), toggleOpenAtLogin_), #(('Reset Password', 'resetPassword:'******''), resetPassword_) ] delegate = systrayosx.Backup.alloc().initWithMenus(menus) delegate.disabled_menuitems = ['Open Dashboard'] delegate.server_port = str(pscan()) delegate.startService_("") NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( 3, delegate, "restartCallback:", None, YES) NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( 10, delegate, "updateMonitor:", None, NO) delegate.updateTimer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( 3600, delegate, "updateMonitor:", None, YES) NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( 5, delegate, "openDashboard:", None, NO) app.setDelegate_(delegate) AppHelper.runEventLoop()