From f32731e775afff5c5ad1ad51e2eee2e9bc876865 Mon Sep 17 00:00:00 2001 From: Alexandre Gobbo Date: Tue, 2 Apr 2019 14:55:13 +0200 Subject: [PATCH] Script execution --- script/statistics.py | 50 ++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/script/statistics.py b/script/statistics.py index 534e96b..ff063e6 100644 --- a/script/statistics.py +++ b/script/statistics.py @@ -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()