def SvcDoRun(self):
        import servicemanager      
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,servicemanager.PYS_SERVICE_STARTED,(self._svc_name_, '')) 

        #self.timeout = 640000    #640 seconds / 10 minutes (value is in milliseconds)
        self.timeout = 120000     #120 seconds / 2 minutes
        # This is how long the service will wait to run / refresh itself (see script below)

        while 1:
            # Wait for service stop signal, if I timeout, loop again
            rc = win32event.WaitForSingleObject(self.hWaitStop, self.timeout)
            # Check to see if self.hWaitStop happened
            if rc == win32event.WAIT_OBJECT_0:
                # Stop signal encountered
                if not self._server_:
                    self._server_ = make_server()
                stop_server(self._server_)
                servicemanager.LogInfoMsg(self._svc_name_ + " - STOPPED!")  #For Event Log
                break
            else:
                try:
                    servicemanager.LogInfoMsg(self._svc_name_ + " - STARTING!")
                    # if not self._server_:
                        # self._server_ = make_server()
                    # start_server(self._server_)
                    file_path = self._path_ + "\server.py"
                    exec(open(file_path).read())             #Execute the script
                except:
                    pass
Пример #2
0
 def handler(signum, frame):
     global anim
     print('[signal handler]: calling server.stop_server')
     server.stop_server()
     print('[signal handler]: server stopped')
     presentation.start_presentation_server()
     # anim.event_source.stop()
     # plt.close()
     sys.exit()
Пример #3
0
    def start(self):
        # set up the gui layout
        self.layout()

        # open the main window
        self.root.mainloop()
        self.root.destroy()
        # stop the server
        server.stop_server()
Пример #4
0
def close():
    '''
    ()-->None
    allow using python connect to CMD and run the sh script to close the django
    server
    '''
    config = server.configuration()['server']
    server.stop_server(config['port'])
    showinfo("Notice", "Server off!")
Пример #5
0
 def deactivate(self, shell):
     '''Deactivate the plugin.
     
     Deactivate the server. This includes stopping the server and disposing
     the shell. This method must be overwritten, as it is indicated by the
     Rhythmbox documentation.
     '''
     print "Deactivating for shell", shell
     server.stop_server()
     server.PLUGIN = None        
     self.shell = None
Пример #6
0
def main():
    """
    Entry point to start the MetaShop server application.
    This function starts the client servicing thread and then
    uses this current thread to allow super users to issue commands.
    """

    # Kickoff servicing server
    server_thread = threading.Thread(target=enter_server_loop)
    server_thread.start()

    enter_command_loop()  # Handle commands until user exit
    #testmain()

    stop_server()  # Start stopping if not already
    server_thread.join()
Пример #7
0
def main():
    parser = argparse.ArgumentParser()
    for arg in ARGS:
        parser.add_argument(arg, **ARGS[arg])
    options = parser.parse_args()
    os.chdir(options.working)
    check_cache()
    if options.last:
        with open(os.path.join(CACHE_DIR, 'last.txt'), 'w') as lastfile:
            for key, value in json.load(lastfile).iteritems():
                setattr(options, key, value)
        os.chdir(options.working)
    else:
        with open(os.path.join(CACHE_DIR, 'last.txt'), 'w') as lastfile:
            json.dump(vars(options), lastfile)
    if not os.path.exists(options.jar):
        print "Can't find minecraft_server.jar."
        res = raw_input('Download now? [y/N] ')
        if res.startswith('y') or res.startswith('Y'):
            download_server(options.jar)
        else:
            print 'fatal: no minecraft_server.jar.'
            return 1
    options.cachedir = CACHE_DIR
    dataname = os.path.join(options.cachedir, 'data.p')
    data = datafunc.get_data()
    if os.path.exists(dataname):
        with open(dataname) as datafile:
            data.update(pickle.load(datafile))
    datafunc.set_options(options)
    disp = ui.get_disp(options)
    server.start_server(disp)
    disp.wait()
    instances.Instance.stop_all()
    server.stop_server()
    with open(dataname, 'w') as datafile:
        pickle.dump(datafunc.get_data(), datafile)
    print
    sys.exit(0)
Пример #8
0
def main():
    parser = argparse.ArgumentParser()
    for arg in ARGS:
        parser.add_argument(arg, **ARGS[arg])
    options = parser.parse_args()
    os.chdir(options.working)
    check_cache()
    if options.last:
        with open(os.path.join(CACHE_DIR, 'last.txt'), 'w') as lastfile:
            for key, value in json.load(lastfile).iteritems():
                setattr(options, key, value)
        os.chdir(options.working)
    else:
        with open(os.path.join(CACHE_DIR, 'last.txt'), 'w') as lastfile:
            json.dump(vars(options), lastfile)
    if not os.path.exists(options.jar):
        print "Can't find minecraft_server.jar."
        res = raw_input('Download now? [y/N] ')
        if res.startswith('y') or res.startswith('Y'):
            download_server(options.jar)
        else:
            print 'fatal: no minecraft_server.jar.'
            return 1
    options.cachedir = CACHE_DIR
    dataname = os.path.join(options.cachedir, 'data.p')
    data = datafunc.get_data()
    if os.path.exists(dataname):
        with open(dataname) as datafile:
            data.update(pickle.load(datafile))
    datafunc.set_options(options)
    disp = ui.get_disp(options)
    server.start_server(disp)
    disp.wait()
    instances.Instance.stop_all()
    server.stop_server()
    with open(dataname, 'w') as datafile:
        pickle.dump(datafunc.get_data(), datafile)
    print
    sys.exit(0)
Пример #9
0
def command(x):

    if x == "stop":
        stop = True
        server.stop_server()
        IRC.stop()
        sys.exit()
    elif x == "nick load":
        Nick.load()
    elif x == "follow load":
        Follow.get_follow()
    elif x == "setting load":
        cos.load()
    elif x == "ping":
        print 'ping call'
        r = IRC.send('PING :103\n')
        if not r:
            print 'limit'
    else:
        r = IRC.send(x + '\n')
        if not r:
            print 'limit'
Пример #10
0
def command(x):
  
  if x == "stop":
    stop = True
    server.stop_server()
    IRC.stop()
    sys.exit()
  elif x == "nick load":
    Nick.load()
  elif x == "follow load":
    Follow.get_follow()
  elif x == "setting load":
    cos.load()
  elif x == "ping":
    print 'ping call'
    r = IRC.send('PING :103\n')
    if not r:
      print 'limit'
  else:
    r = IRC.send(x + '\n')
    if not r:
      print 'limit'
Пример #11
0
def test_durability(repeat):
    server_log_base = server.log_dir + "dur_server_%d.log" % repeat
    client_log_base = server.log_dir + "dur_client_%d.log" % repeat
    server.start_server(extra_args=server_args, log=server_log_base+".1")
    try:
        lsn = 0

        client = Client(server.addr, server.port, log=client_log_base+".1")
        repeat_deposit(client, repeat, 100)
        lsn += repeat + 1
        saved = server.save_db()

        repeat_deposit(client, repeat, 100)
        lsn += repeat
        client.log.close()

        client = Client(server.addr, server.port, log=client_log_base+".1")
        repeat_deposit(client, repeat, 200)
        lsn += repeat + 1
        client.log.close()

        server.stop_server()
        server.restore_db(saved)
        server.start_server(extra_args=server_args, log=server_log_base+".2", remove_old=False)

        client = Client(server.addr, server.port, log=client_log_base+".2", auto_open=False)
        client.id = 1
        _, _, new = client.deposit(0)
        assert new == repeat * 200
        client.id = 2
        _, _, new = client.deposit(0)
        assert new == repeat * 200
        lsn += 2

        client.log.close()
        data.assert_lsn_id(lsn, 2)
    finally:
        server.stop_server()
Пример #12
0
 def execute_server_backend(self, platform_name, subid, action, row):
     '''
     后台执行server操作
     '''
     operation_result = False
     name = self.get_select_apikey_name()
     if action == 'start':
         operation_result = server.start_server(platform_name, name, subid)
     elif action == 'stop':
         operation_result = server.stop_server(platform_name, name, subid)
     elif action == 'restart':
         operation_result = server.reboot_server(platform_name, name, subid)
     wx.CallAfter(self.callback_execute_server, action, operation_result,
                  row)
 def SvcStop(self):
     self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
     win32event.SetEvent(self.hWaitStop)
     if not self._server_:
         self._server_ = make_server()
     stop_server(self._server_)
Пример #14
0
import server as tcpServer

if __name__ == '__main__':
    print("Starting TCP Server ...")
    while True:
        print('<Menu>')
        print('   1. Start Server')
        print('   2. Stop Server')
        print('   99. Finish')

        menu = input('Input the menu: ')

        # print('   --> Your input is {}'.format(menu))

        if menu == '1':
            tcpServer.start_server()
        elif menu == '2':
            tcpServer.stop_server()
        elif menu == '99':
            print("Exit !!!")
            tcpServer.stop_server()
            break
Пример #15
0
def stop_processes(stop_event):

	server.stop_server()
Пример #16
0
def exit_application():
    server.stop_server()
Пример #17
0
def close_server():
    disable_buttons()
    server.stop_server()
    button_connect['text'] = 'Open server'
    button_connect['command'] = launch_server
Пример #18
0
	# --- debug logging ---
	if len(all_times[0]) > 0:
		print()
		print("mean obs compute time :", np.mean(all_times[0]))
		print("median obs compute time :", np.median(all_times[0]))
		print("mean network compute time :", np.mean(all_times[1]))
		print("mean execution time :", np.mean(all_times[2]))
		print("median loop time :", np.median(all_times[3]))
		
	# --- save recorder data ---
	recorder.save ()
	
	if move_motors:
		input("Enter to put the dog to rest")
		end_phases = np.asarray([0, 0, 0, 0])
		
		motors.set_strong_pid()
		exec_timed_action(zero_act, end_phases, dt=1, fetch=True)
		time.sleep(1)
		
		motors.goto_rest ()
		input("Enter to stop the dog")
		
		motors.disengage ()
	
	"""
	"""
	server.stop_server()
	time.sleep(1)
	
Пример #19
0
 def close(self, *args):
     stop_server(self._port)
     self.destroy()