示例#1
0
 def test_get_function(self):
     """tests if the get_function method works"""
     command_string = "get filedatabla"
     # get a valid function
     self.assertEqual(get_function(command_string)[0], get_filedata)
     # get an invalid function
     self.assertEqual(get_function('invalid command'), None)
示例#2
0
def console():
    """function for inputting commands into mis directly."""
    print "Media Information System - Console"
    print "type help for help"
    value = True
    while (value):
        print ""
        text = raw_input('# ')
        argument = None
        if text == 'exit':
            command = None
            value = False
        elif text == 'batch':
            batch_update()
        else:
            command = get_function(text)
            if command is None:
                print "Invalid command: " + text
                continue
            (function, argument) = get_function(text)
            result = function(argument[1:])
            if result is not None:
                print(result)
        if text == 'help':  # add 'exit' to the list hack
            print 'exit: exit the program'
示例#3
0
文件: consoleinput.py 项目: nido/mis
def console():
    """function for inputting commands into mis directly."""
    print "Media Information System - Console"
    print "type help for help"
    value = True
    while(value):
        print ""
        text = raw_input('# ')
        argument = None
        if text == 'exit':
            command = None
            value = False
        elif text == 'batch':
            batch_update()
        else:
            command = get_function(text)
            if command is None:
                print "Invalid command: " + text
                continue
            (function, argument) = get_function(text)
            result = function(argument[1:])
            if result is not None:
                print(result)
        if text == 'help':  # add 'exit' to the list hack
            print 'exit: exit the program'
示例#4
0
文件: test_commands.py 项目: nido/mis
 def test_get_function(self):
     """tests if the get_function method works"""
     command_string = "get filedatabla"
     # get a valid function
     self.assertEqual(get_function(command_string)[0],
                      get_filedata)
     # get an invalid function
     self.assertEqual(get_function('invalid command'), None)
示例#5
0
 def rpc_listen(self):
     """The sister of the rpc call procedure. This receives the
     call, processes it, and returns the answer.
     NOTE: there is a serious lack of security in this function
     and the database in general. Right now, using this function
     basically means you serve any media file to anyone."""
     command = self._recv()
     cmd = get_function(command)
     print(cmd)
     if cmd is None:
         LOG.error("Received an invalid command: Aborting. ")
         LOG.error(command)
         return
     (function, arguments) = cmd
     LOG.info(command[:12] + " - " + str(function) + " - " + arguments)
     result = function(arguments)
     if result is None:
         LOG.error("Function returned nothing. something went wrong.")
         result = ""
     self._send(result)