@@ -437,25 +437,30 @@ def option_list(taskid):
437437@post ("/option/<taskid>/get" )
438438def option_get (taskid ):
439439 """
440- Get the value of an option (command line switch ) for a certain task ID
440+ Get value of option(s ) for a certain task ID
441441 """
442442 if taskid not in DataStore .tasks :
443443 logger .warning ("[%s] Invalid task ID provided to option_get()" % taskid )
444444 return jsonize ({"success" : False , "message" : "Invalid task ID" })
445445
446- option = request .json .get ("option" , "" )
446+ options = request .json or []
447+ results = {}
447448
448- if option in DataStore .tasks [taskid ].options :
449- logger .debug ("[%s] Retrieved value for option %s" % (taskid , option ))
450- return jsonize ({"success" : True , option : DataStore .tasks [taskid ].get_option (option )})
451- else :
452- logger .debug ("[%s] Requested value for unknown option %s" % (taskid , option ))
453- return jsonize ({"success" : False , "message" : "Unknown option" , option : "not set" })
449+ for option in options :
450+ if option in DataStore .tasks [taskid ].options :
451+ results [option ] = DataStore .tasks [taskid ].options [option ]
452+ else :
453+ logger .debug ("[%s] Requested value for unknown option '%s'" % (taskid , option ))
454+ return jsonize ({"success" : False , "message" : "Unknown option '%s'" % option })
455+
456+ logger .debug ("[%s] Retrieved values for option(s) '%s'" % (taskid , "," .join (options )))
457+
458+ return jsonize ({"success" : True , "options" : results })
454459
455460@post ("/option/<taskid>/set" )
456461def option_set (taskid ):
457462 """
458- Set an option (command line switch ) for a certain task ID
463+ Set value of option(s ) for a certain task ID
459464 """
460465
461466 if taskid not in DataStore .tasks :
@@ -775,11 +780,11 @@ def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=Non
775780 logger .error ("No task ID in use" )
776781 continue
777782 try :
778- command , option = command .split (" " )
783+ command , option = command .split (" " , 1 )
779784 except ValueError :
780785 raw = _client ("%s/option/%s/list" % (addr , taskid ))
781786 else :
782- options = { "option" : option }
787+ options = re . split ( r"\s*,\s*" , option . strip ())
783788 raw = _client ("%s/option/%s/get" % (addr , taskid ), options )
784789 res = dejsonize (raw )
785790 if not res ["success" ]:
0 commit comments