fix a lot of things
* force means re-setup db * print empty if no tasks yet * add --agent for start command
This commit is contained in:
parent
7ab052f76f
commit
f56b99c950
@ -6,6 +6,9 @@ from scalpels.db import api as db_api
|
||||
def run(config):
|
||||
print "command report: %s" % config
|
||||
last_task = db_api.task_get_last()
|
||||
if not last_task:
|
||||
print "no task yet."
|
||||
return
|
||||
print "task: <%s>" % last_task.uuid
|
||||
results = []
|
||||
for ret_uuid in last_task.results:
|
||||
|
@ -7,5 +7,6 @@ def run(config):
|
||||
print "command setup: %s" % config
|
||||
if config["force"]:
|
||||
db_api.db_drop()
|
||||
db_api.db_create()
|
||||
else:
|
||||
db_api.db_create()
|
||||
|
@ -4,7 +4,18 @@
|
||||
|
||||
from scalpels.db import api as db_api
|
||||
|
||||
def _parse_agent_from_config(config):
|
||||
if config.get("agent") is None:
|
||||
return config
|
||||
parsed_agents = []
|
||||
for ag in config.get("agent"):
|
||||
parsed_agents.extend(ag.split(","))
|
||||
config.update({"agent":parsed_agents})
|
||||
return config
|
||||
|
||||
|
||||
def run(config):
|
||||
config = _parse_agent_from_config(config)
|
||||
print "command start: %s" % config
|
||||
data = [config]
|
||||
rets = []
|
||||
|
@ -23,7 +23,8 @@ def main():
|
||||
|
||||
# setup start actions
|
||||
start = subparsers.add_parser("start")
|
||||
start.add_argument("--file", action="store", dest="file", help="config file for this task", required=True)
|
||||
start.add_argument("-f", "--file", action="store", dest="file", help="config file for this task", required=False)
|
||||
start.add_argument("-a", "--agent", action="append", dest="agent", help="agent(s) to run", required=False)
|
||||
|
||||
# setup report actions
|
||||
report = subparsers.add_parser("report")
|
||||
|
@ -66,5 +66,7 @@ def result_get(result_uuid):
|
||||
return ret
|
||||
|
||||
def task_get_last():
|
||||
tasks = model_query(models.Task)
|
||||
return tasks[-1]
|
||||
tasks = model_query(models.Task).all()
|
||||
if len(tasks) > 0:
|
||||
return tasks[-1]
|
||||
return None
|
||||
|
Loading…
x
Reference in New Issue
Block a user