Script execution

This commit is contained in:
2019-04-02 14:55:13 +02:00
parent febd7a5b28
commit f32731e775

View File

@@ -69,23 +69,28 @@ def get_errors(command = "%", start = None, end = None):
return ret
def get_commands(commands =None, start = None, end = None):
sql = "SELECT * FROM . WHERE Command != ''"
sql = _add_sql_time(sql, start, end)
if (commands is not None) and (len(commands)>0):
sql = sql + " AND ("
first = True
for c in commands:
sql = sql + ("" if first else " OR")
sql = sql + "(Command LIKE '" + c + "')"
first = False
sql = sql + " )"
sql = sql + " GROUP BY Command"
results = stmt.executeQuery(sql)
ret = []
while results.next():
cmd = results.getString("Command")
if cmd : #"and not " " in cmd:
ret.append(cmd)
if (commands is None) or (len(commands)==0):
sql = "SELECT * FROM . WHERE Command != ''"
sql = _add_sql_time(sql, start, end)
#if (commands is not None) and (len(commands)>0):
# sql = sql + " AND ("
# first = True
# for c in commands:
# sql = sql + ("" if first else " OR")
# sql = sql + "(Command LIKE '" + c + "')"
# first = False
# sql = sql + " )"
sql = sql + " GROUP BY Command"
results = stmt.executeQuery(sql)
while results.next():
cmd = results.getString("Command")
if cmd and not " " in cmd:
ret.append(cmd)
else:
for cmd in commands:
if get_count(cmd, start, end) >0 :
ret.append(cmd)
return ret
def print_cmd_stats(command = "%", start = None, end = None):
@@ -119,6 +124,7 @@ def print_stats(commands = None, start = None, end = None):
"""
if __name__=='__main__':
conn = get_stats_connection()
start= "06/02/19" #"06/02/19 13:27:56.124"
@@ -129,4 +135,16 @@ if __name__=='__main__':
for cmd in cmds:
print_cmd_stats (cmd, start, end)
conn.close()
"""
cmds = ["mount%", "unmount%", "dry%", "recover%", "trash%", "robot_recover%", "scan%", "homing%"]
conn = get_stats_connection()
#print_stats()
#c=get_commands(cmds)
print_stats(cmds)
for cmd in cmds:
print_cmd_stats (cmd)
conn.close()