def signal_handler(signal, frame): # This is where we clean up the server. log('Cleaning up the world...') WORLD._cleanup() # The cleanup function runs a web of cleanup functions to secure all information before shutting down. SERVER.poll() log('Shutdown complete.') sys.exit(0)
def broadcast(self, key, modifiers): # Broadcast a message to all users of the MUD. if (self.PLAYERS[key].ROLE > 1): # Restrict this command to mods and admins. if (len(modifiers) > 0): # They specified a message to broadcast. message = ' '.join( modifiers) # Compile the list back into a string. for key in self.PLAYERS.keys(): # Send the message to each user. self.PLAYERS[key].send(message) log( '%s broadcast message: %s' % (key, message), '!' ) # Log about it, since this isn't something to take lightly. self.PLAYERS[key].set_tick_delay( 3 ) # Force a 3-tick delay before the next command, to avoid spam. else: # They didn't include a message! self.PLAYERS[key].send( 'You must specify a message to broadcast!') else: # This person isn't an admin or mod. self.PLAYERS[key].send( 'You must be a moderator or admin to broadcast messages.')
def save(self): # Save the zone to its .nfo file. if(self.SETTINGS == []): # If there are no settings, save 'none'. settings = 'none' else: # Otherwise, link 'em up. settings = ','.join(self.SETTINGS) lines = [ # The lines we'll be writing to the save file. '# Zone settings.', 'settings:%s' % (settings), '', "# A description of the zone. Ends with '---'.", 'description:', '%s' % (self.DESC), '---' ] # Now that we've formatted our lines, let's write the file. zone_name = '%s.%s' % (self.ID, self.NAME) file_name = '%s.nfo' % (zone_name) path = 'world/zones/%s/%s' % (zone_name, file_name) nfo_file = open(path,'w') # Open the file. for line in lines: # Write each line. nfo_file.write('%s\n' % (line)) nfo_file.close() # Close the file. log('Zone saved: %s.%s' % (self.ID, self.NAME), '<')
def _loop(self): # This happens repeatedly, at an increment designated by self.TICK_LENGTH. self._kick_idle() # First, get rid of idle players. for key in self.PLAYERS.keys(): # Now we need to check for newly authenticated users. if self.PLAYERS[key].STATE == "authenticated": # This player has completed login and needs to be placed in their beginning room. self._move(key, self.PLAYERS[key].ROOM) # Move the player. self.PLAYERS[key].state_change("live") # Make them live. log("%s logged in as %s." % (key, self.PLAYERS[key].NAME)) # Log about it. for key in self.PLAYERS.keys(): # Now, update every player and get their latest action, if applicable. update = self.PLAYERS[key].process_input() if update != "": # If they returned a legitimate action, append it to the list of updates for processing. self.UPDATES.append((key, update)) # Next we need to process all updates from all ticks executed thus far. self._update() # Get 'er dunn. # Finally, we need to see if it's time for another tick. now = time.time() # Get the time. if now > self.NEXT_TICK: # We're ready. self._tick()
def load(self): # Load the room from save-file. shortname = '%s.%s.room' % (self.ID, self.NAME) # Get the filename. longname = 'world/zones/%s/rooms/%s' % (self.ZONE, shortname) # Get the entire file path. lines = open(longname, 'r').read().split('\n') # Read the lines from the file. self.EXITS = {} # Reset the exit list. while(len(lines) > 0): # Process each line. line = lines.pop(0) # Grab a line. if(line.split(':')[0] == 'settings'): # Read the settings line. settings = line.split(':')[1] if(settings == ['none']): self.SETTINGS = [] else: self.SETTINGS = settings.split(',') elif(line.split(':')[0] == 'description'): # Get the room description. desc = lines.pop(0) # Set the description. line = lines.pop(0) # Get the next line. while(line != '---'): # Continue adding lines until we're through. desc = '%s\n%s' % (desc, line) # Append the next line. line = lines.pop(0) # Then grab another. self.DESC = desc elif(line.split(':')[0][:4] == 'exit'): # We've got an exit. exit_name = line.split(':')[0][5:] # Get the name of the exit. exit_room = line.split(':')[1] # Get the room to which the exit leads. self.EXITS[exit_name] = exit_room # Add the exit information to our list. if(LOG_FILE_ACCESS): log('Room loaded: %s.%s' % (self.ID, self.NAME), '>')
def _loop(self): # This happens repeatedly, at an increment designated by self.TICK_LENGTH. self._kick_idle() # First, get rid of idle players. for key in self.PLAYERS.keys(): # Now we need to check for newly authenticated users. if (self.PLAYERS[key].STATE == 'authenticated'): # This player has completed login and needs to be placed in their beginning room. self._move(key, self.PLAYERS[key].ROOM) # Move the player. self.PLAYERS[key].state_change('live') # Make them live. log('%s logged in as %s.' % (key, self.PLAYERS[key].NAME)) # Log about it. for key in self.PLAYERS.keys(): # Now, update every player and get their latest action, if applicable. update = self.PLAYERS[key].process_input() if (update != ''): # If they returned a legitimate action, append it to the list of updates for processing. self.UPDATES.append((key, update)) # Next we need to process all updates from all ticks executed thus far. self._update() # Get 'er dunn. # Finally, we need to see if it's time for another tick. now = time.time() # Get the time. if (now > self.NEXT_TICK): # We're ready. self._tick()
def post(self): """function:处理post请求""" try: log("[CheckPortHandler][post]start process...") f_data = {"code":0,"msg":"OK","details":[]} r_data = self.request.body r_data = json.loads(r_data) #step-1:check params r_result,r_msg = self.check_params(r_data) if not r_result: f_data["code"] = 1 f_data["msg"] = r_msg else: chk_obj = CheckPort() #step-2:check port f_details = [] r_info_device = r_data.get("body",{}).get("data",{}).get("info_list",[]) for index, item in enumerate(r_info_device): rc_result = chk_obj.check_telnet(item.get("ip"),item.get("port")) rc_result = 1 if rc_result else 0 f_details.append({"ip":item.get("ip"),"port":item.get("port"),"result":rc_result}) f_data["details"] = f_details except Exception,e: print traceback.format_exc() code = 100 msg = str(e) f_data = {"code":code,"msg":msg}
def signal_handler(signal, frame): # This is where we clean up the server. log('Cleaning up the world...') WORLD._cleanup( ) # The cleanup function runs a web of cleanup functions to secure all information before shutting down. SERVER.poll() log('Shutdown complete.') sys.exit(0)
def _kick_idle(self): # Check for idle clients, then drop them. for key in self.PLAYERS.keys(): # For each player, if self.PLAYERS[key].CLIENT.idle() > 300: # If it's been idle for more than 5 minutes, self.PLAYERS[key].CLIENT.active = False # Set it as inactive, log("%s timed out." % self.PLAYERS[key].ID) # then log about it.
def _move(self, key, rm): # Move player or mob (key) to room designation (rm). # First, we determine where they are, and where they're going. current = self.PLAYERS[key].ROOM # Find out where they are. current_zone = current.split(".")[0] # Then get the zone current_room = current.split(".")[1] # and the room. target_zone = rm.split(".")[0] # Next, find out where they're going. Zone, target_room = rm.split(".")[1] # and room. try: # The following tests if the target is a valid room. If this crashes, the target is reset to 0.0. target = self.ZONES[target_zone].ROOMS[target_room].ID except: # Be sure to let the admins know that there was a problem. log( "%s (%s) attempted entry into invalid room %s." % (self.PLAYERS[key].ID, self.PLAYERS[key].NAME, rm), "!", ) # Then reset the target zone and room. target_zone = "0" target_room = "0" rm = "0.0" try: # Likewise, this performs a sanity check on the current room. If this crashes, the current room is reset to 0.0. target = self.ZONES[current_zone].ROOMS[current_room].ID except: # Let the admins know. log( "%s (%s) attempted to exit invalid room %s." % (self.PLAYERS[key].ID, self.PLAYERS[key].NAME, current), "!", ) # Then reset the current zone and room. current_zone = "0" current_room = "0" current = "0.0" removed = ( self.ZONES[current_zone].ROOMS[current_room].drop_player(key) ) # Remove the player from their current room. if removed: # This only happens if the player actually existed in the room they were dropped from. # Tell everyone in the room of that player's departure. exit_name = self._get_exit_name(current, rm) # Figure out the name of the exit the player took. for player in self.ZONES[current_zone].ROOMS[current_room].PLAYERS.keys(): # For every player still in the room, let them know of the player's movement. self.PLAYERS[player].send("%s departed to the %s." % (self._key2name(key), exit_name)) # Now, tell everyone in the new room of that player's arrival. for player in self.ZONES[target_zone].ROOMS[target_room].PLAYERS.keys(): # For every player in the new room, let them know of the player's arrival. self.PLAYERS[player].send("%s has arrived." % (self._key2name(key))) self.ZONES[target_zone].ROOMS[target_room].add_player( key, self._key2name(key) ) # Add the player to the new room. self.PLAYERS[key].ROOM = rm # Set their room to the room they moved to. self.look(key, []) # This will show the user their new surroundings.
def shutdown(self, key, modifiers): # The user hopes to shut down the server. if self.PLAYERS[key].ROLE == 2: # Restrict this command to admins. log("%s issued the command to shutdown." % key, "!") self._cleanup() else: # They're not allowed. self.PLAYERS[key].send("You must be an admin to shutdown the server.")
def _kick_idle(self): # Check for idle clients, then drop them. for key in self.PLAYERS.keys(): # For each player, if (self.PLAYERS[key].CLIENT.idle() > 300): # If it's been idle for more than 5 minutes, self.PLAYERS[key].CLIENT.active = False # Set it as inactive, log('%s timed out.' % self.PLAYERS[key].ID) # then log about it.
def __init__(self): # Create the world. self.COMMANDS = [] # This will become the list of commands. self.NEXT_TICK = time.time( ) # Set the time for the next tick. (In this case, immediately.) for item in dir(self): # Scan every item in the world class. if ((item[0] != '_') and hasattr(getattr(self, item), '__call__')): # Find all the public commands, then add them to a list. self.COMMANDS.append(item) # Load zones. self.ZONES = {} file_list = glob.glob( 'world/zones/*.*/') # Get a list of all zone folders. for item in file_list: # For each folder found, load that zone. z = zone.zone(item) self.ZONES[z.ID] = z # Append it to the list of zones. # Sanity check all rooms and exits. log('Performing sanity check...') rooms = [] exits = [] # Compile a list of all room designators and all exits from all rooms. for z in self.ZONES.keys(): for r in self.ZONES[z].ROOMS.keys(): # For each room in each zone, append that room's designator to the list of rooms. rooms.append('%s.%s' % (z, r)) for item in self.ZONES[z].ROOMS[r].exits(): des = self.ZONES[z].ROOMS[r].EXITS[item] if (des not in exits): exits.append(des) # then see if any exist in the exits that aren't in the rooms. failures = [] for item in exits: if (item not in rooms): failures.append(item) if (len(failures) > 0): log('Sanity check failed. Undefined rooms:', '!') log(' '.join(failures), '!') self.ALIVE = False else: log('Sanity check passed!') # Now load up our list of custom emotes. self.EMOTES = {} # Initialize the empty list. lines = open('world/text/emotes.txt', 'r').read().split( '\n') # Read the emotes file into lines. for line in lines: parts = line.split(':') if (len(parts) == 3): # The current line is an emotion definition. self.EMOTES[parts[0]] = ( parts[1], parts[2] ) # Parts[1] is the aimless emote, parts[2] is the targeted emote. log('%d emotes loaded.' % (len(self.EMOTES)), '>')
def reboot(self, key, modifiers): # The user wants to reboot the server. if self.PLAYERS[key].ROLE == 2: # Restrict this command to admins. log("%s issued the command to reboot." % key, "!") self.ALIVE = "reboot" self._cleanup() else: # They're not allowed. self.PLAYERS[key].send("You must be an admin to reboot the server.")
def shutdown(self, key, modifiers): # The user hopes to shut down the server. if (self.PLAYERS[key].ROLE == 2): # Restrict this command to admins. log('%s issued the command to shutdown.' % key, '!') self._cleanup() else: # They're not allowed. self.PLAYERS[key].send( 'You must be an admin to shutdown the server.')
def __init__(self): # Create the world. self.COMMANDS = [] # This will become the list of commands. self.NEXT_TICK = time.time() # Set the time for the next tick. (In this case, immediately.) for item in dir(self): # Scan every item in the world class. if (item[0] != "_") and hasattr(getattr(self, item), "__call__"): # Find all the public commands, then add them to a list. self.COMMANDS.append(item) # Load zones. self.ZONES = {} file_list = glob.glob("world/zones/*.*/") # Get a list of all zone folders. for item in file_list: # For each folder found, load that zone. z = zone.zone(item) self.ZONES[z.ID] = z # Append it to the list of zones. # Sanity check all rooms and exits. log("Performing sanity check...") rooms = [] exits = [] # Compile a list of all room designators and all exits from all rooms. for z in self.ZONES.keys(): for r in self.ZONES[z].ROOMS.keys(): # For each room in each zone, append that room's designator to the list of rooms. rooms.append("%s.%s" % (z, r)) for item in self.ZONES[z].ROOMS[r].exits(): des = self.ZONES[z].ROOMS[r].EXITS[item] if des not in exits: exits.append(des) # then see if any exist in the exits that aren't in the rooms. failures = [] for item in exits: if item not in rooms: failures.append(item) if len(failures) > 0: log("Sanity check failed. Undefined rooms:", "!") log(" ".join(failures), "!") self.ALIVE = False else: log("Sanity check passed!") # Now load up our list of custom emotes. self.EMOTES = {} # Initialize the empty list. lines = open("world/text/emotes.txt", "r").read().split("\n") # Read the emotes file into lines. for line in lines: parts = line.split(":") if len(parts) == 3: # The current line is an emotion definition. self.EMOTES[parts[0]] = ( parts[1], parts[2], ) # Parts[1] is the aimless emote, parts[2] is the targeted emote. log("%d emotes loaded." % (len(self.EMOTES)), ">")
def reboot(self, key, modifiers): # The user wants to reboot the server. if (self.PLAYERS[key].ROLE == 2): # Restrict this command to admins. log('%s issued the command to reboot.' % key, '!') self.ALIVE = 'reboot' self._cleanup() else: # They're not allowed. self.PLAYERS[key].send( 'You must be an admin to reboot the server.')
def _cleanup(self): # Clean up the server, then shut down. log("Saving characters...") # Log about it. doing = "shutting down temporarily" if self.ALIVE == "reboot": doing = "rebooting" else: self.ALIVE = False for key in self.PLAYERS.keys(): # Then tell each user, then clean them up. self.PLAYERS[key].send("The server is %s. Please come back soon!" % doing) self.PLAYERS[key].cleanup() for ID in self.ZONES.keys(): # Clean up the zones. self.ZONES[ID].cleanup()
def save(self): # Save this character to a file. filename = 'world/players/%s.plr' % (self.NAME) # Get the filename. save_file = open(filename,'w') # Open the save file. lines = [ 'name:%s' % (self.NAME), 'pass:%s' % (self.PASSWORD), 'role:%d' % (self.ROLE), 'sex:%s' % (self.SEX), 'room:%s' % (self.ROOM) ] for line in lines: # Write the lines to the file. save_file.write('%s\n' % (line)) save_file.close() # Close the file. log('Character saved (%s).' % (self.NAME), '<')
def _cleanup(self): # Clean up the server, then shut down. log('Saving characters...') # Log about it. doing = 'shutting down temporarily' if (self.ALIVE == 'reboot'): doing = 'rebooting' else: self.ALIVE = False for key in self.PLAYERS.keys( ): # Then tell each user, then clean them up. self.PLAYERS[key].send('The server is %s. Please come back soon!' % doing) self.PLAYERS[key].cleanup() for ID in self.ZONES.keys(): # Clean up the zones. self.ZONES[ID].cleanup()
def save(self): # Save this character to a file. filename = 'world/players/%s.plr' % (self.NAME) # Get the filename. save_file = open(filename, 'w') # Open the save file. lines = [ 'name:%s' % (self.NAME), 'pass:%s' % (self.PASSWORD), 'role:%d' % (self.ROLE), 'sex:%s' % (self.SEX), 'room:%s' % (self.ROOM) ] for line in lines: # Write the lines to the file. save_file.write('%s\n' % (line)) save_file.close() # Close the file. log('Character saved (%s).' % (self.NAME), '<')
def __init__(self, driver, baseurl, filename): #self.driver = driver self.driver = driver self.baseurl = baseurl self.B_DIR = os.path.dirname(os.path.dirname(__file__)) self.yaml_dict = readYaml(filename).readYaml() self.readXml = xmlUtils() self.log = log()
def broadcast(self, key, modifiers): # Broadcast a message to all users of the MUD. if self.PLAYERS[key].ROLE > 1: # Restrict this command to mods and admins. if len(modifiers) > 0: # They specified a message to broadcast. message = " ".join(modifiers) # Compile the list back into a string. for key in self.PLAYERS.keys(): # Send the message to each user. self.PLAYERS[key].send(message) log( "%s broadcast message: %s" % (key, message), "!" ) # Log about it, since this isn't something to take lightly. self.PLAYERS[key].set_tick_delay(3) # Force a 3-tick delay before the next command, to avoid spam. else: # They didn't include a message! self.PLAYERS[key].send("You must specify a message to broadcast!") else: # This person isn't an admin or mod. self.PLAYERS[key].send("You must be a moderator or admin to broadcast messages.")
def restore(self): # Load the character from a file. filename = 'world/players/%s.plr' % (self.NAME) # Get the filename. data = open(filename,'r').read().split('\n') # Read its lines into a list. for line in data: setting = line.split(':')[0] # This defines what is being set. if(setting == 'name'): # Load the name from the list. self.NAME = line.split(':')[1] elif(setting == 'pass'): # Load the password from the list. self.PASSWORD = line.split(':')[1] elif(setting == 'room'): # Load the room from the list. self.ROOM = line.split(':')[1] elif(setting == 'sex'): # Load the gender from the list. self.SEX = line.split(':')[1] elif(setting == 'role'): # Load the role from the list. self.ROLE = int(line.split(':')[1]) log('Character loaded (%s).' % (self.NAME), '>')
def restore(self): # Load the character from a file. filename = 'world/players/%s.plr' % (self.NAME) # Get the filename. data = open(filename, 'r').read().split('\n') # Read its lines into a list. for line in data: setting = line.split(':')[0] # This defines what is being set. if (setting == 'name'): # Load the name from the list. self.NAME = line.split(':')[1] elif (setting == 'pass'): # Load the password from the list. self.PASSWORD = line.split(':')[1] elif (setting == 'room'): # Load the room from the list. self.ROOM = line.split(':')[1] elif (setting == 'sex'): # Load the gender from the list. self.SEX = line.split(':')[1] elif (setting == 'role'): # Load the role from the list. self.ROLE = int(line.split(':')[1]) log('Character loaded (%s).' % (self.NAME), '>')
def save(self): # Save the room to its file. shortname = '%s.%s.room' % (self.ID, self.NAME) # Get the filename. longname = 'world/zones/%s/rooms/%s' % (self.ZONE, shortname) # Get the entire file path. if(self.SETTINGS == []): settings = 'none' else: settings = ','.join(self.SETTINGS) lines = [ # Define the lines of the save file. '# Settings', 'settings:%s' % (settings), '', "# A description of the room. Ends with '---'.", 'description:', '%s' % (self.DESC), '---', '', '# Room exits. (zone.room)' ] # Now let's add all the exits. for key in self.EXITS.keys(): exit_name = 'exit.%s' % (key) exit_room = self.EXITS[key] lines.append('%s:%s' % (exit_name, exit_room)) # Finally, let's write the file. room_file = open(longname, 'w') # Open the room file. for line in lines: # Write each line. room_file.write('%s\n' % (line)) room_file.close() # Close the room file. if(LOG_FILE_ACCESS): log('Room saved: %s.%s' % (self.ID, self.NAME), '<')
_video.release() Hooks.call('on_release', None) # Send noise to video server im = np.empty((720, 1080), np.uint8) ready_frame = cv2.randn(im, (0), (99)) if __name__ == '__main__': # Create env global ready_frame ready_frame = False Hooks = hooks() Log = log() Filters = filters() Request = requests_() # Init plugins uh(cv2, Hooks, Filters) # First hook Hooks.call('on_init', True) # Set config with open('config.json') as config_file: cfg = Filters.call('on_config', json.load(config_file)) Hooks.call('on_setup_cfg', cfg)
def on_disconnect(client): WORLD._drop_player(client) log('%s disconnected.' % client.addrport(), '-')
from libs import world import signal, sys, os PORT = 7000 # This is the port on which the server will run. new_log() # Start a fresh log. """ Let's display our tagline! """ tagline = [ '/------------------------\\', '| miniMUD v0.03 |', '| by Christopher Steffen |', '\\------------------------/' ] for line in tagline: log(line,':') """ Now we need to initialize the world. """ log('Initializing world...') WORLD = world.world() """ Initialize the server. """ def on_connect(client): WORLD._add_player(client) log('%s connected.' % client.addrport(),'+') def on_disconnect(client): WORLD._drop_player(client) log('%s disconnected.' % client.addrport(), '-')
def _move(self, key, rm): # Move player or mob (key) to room designation (rm). # First, we determine where they are, and where they're going. current = self.PLAYERS[key].ROOM # Find out where they are. current_zone = current.split('.')[0] # Then get the zone current_room = current.split('.')[1] # and the room. target_zone = rm.split('.')[ 0] # Next, find out where they're going. Zone, target_room = rm.split('.')[1] # and room. try: # The following tests if the target is a valid room. If this crashes, the target is reset to 0.0. target = self.ZONES[target_zone].ROOMS[target_room].ID except: # Be sure to let the admins know that there was a problem. log( '%s (%s) attempted entry into invalid room %s.' % (self.PLAYERS[key].ID, self.PLAYERS[key].NAME, rm), '!') # Then reset the target zone and room. target_zone = '0' target_room = '0' rm = '0.0' try: # Likewise, this performs a sanity check on the current room. If this crashes, the current room is reset to 0.0. target = self.ZONES[current_zone].ROOMS[current_room].ID except: # Let the admins know. log( '%s (%s) attempted to exit invalid room %s.' % (self.PLAYERS[key].ID, self.PLAYERS[key].NAME, current), '!') # Then reset the current zone and room. current_zone = '0' current_room = '0' current = '0.0' removed = self.ZONES[current_zone].ROOMS[current_room].drop_player( key) # Remove the player from their current room. if ( removed ): # This only happens if the player actually existed in the room they were dropped from. # Tell everyone in the room of that player's departure. exit_name = self._get_exit_name( current, rm) # Figure out the name of the exit the player took. for player in self.ZONES[current_zone].ROOMS[ current_room].PLAYERS.keys(): # For every player still in the room, let them know of the player's movement. self.PLAYERS[player].send('%s departed to the %s.' % (self._key2name(key), exit_name)) # Now, tell everyone in the new room of that player's arrival. for player in self.ZONES[target_zone].ROOMS[target_room].PLAYERS.keys( ): # For every player in the new room, let them know of the player's arrival. self.PLAYERS[player].send('%s has arrived.' % (self._key2name(key))) self.ZONES[target_zone].ROOMS[target_room].add_player( key, self._key2name(key)) # Add the player to the new room. self.PLAYERS[ key].ROOM = rm # Set their room to the room they moved to. self.look(key, []) # This will show the user their new surroundings.
def on_connect(client): WORLD._add_player(client) log('%s connected.' % client.addrport(), '+')
def load(self): # Load the zone. self.read_nfo() # Load the zone's nfo file. self.load_rooms() # Load the zone's rooms. log("Zone loaded: %s.%s" % (self.ID, self.NAME), '>')
def on_connect(client): WORLD._add_player(client) log('%s connected.' % client.addrport(),'+')
from miniboa import TelnetServer from libs.log import log, new_log from libs import world import signal, sys, os PORT = 7000 # This is the port on which the server will run. new_log() # Start a fresh log. """ Let's display our tagline! """ tagline = [ '/------------------------\\', '| miniMUD v0.03 |', '| by Christopher Steffen |', '\\------------------------/' ] for line in tagline: log(line, ':') """ Now we need to initialize the world. """ log('Initializing world...') WORLD = world.world() """ Initialize the server. """ def on_connect(client): WORLD._add_player(client) log('%s connected.' % client.addrport(), '+') def on_disconnect(client): WORLD._drop_player(client) log('%s disconnected.' % client.addrport(), '-')
"template_path":os.path.join(os.path.dirname(__file__),"templates"), "debug":True, "autoload":True } class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello, world") if __name__ == "__main__": """ @func:服务运行入口,支持命令行输入端口 """ try: options.parse_command_line() log("start server...") print "start server...." application = tornado.web.Application( [ (r"/", MainHandler), (r"/api/checkport",CheckPortHandler), (r"/api/cmd",CmdHandler), (r"/api/file",FileUploadHandler), #(r"/api",APIHandler), ],**settings) log("listen on port %s..."%(str(options.port))) print "port listen on %s..."%(str(options.port)) application.listen(options.port) tornado.ioloop.IOLoop.current().start() except KeyboardInterrupt,e: