from solar import * import subprocess def stat (day): sids = [194, 195] sids = [202, 203, 204] sids = [208, 209, 210] pattern = "|".join ([str(sid) for sid in sids]) cmd = f'STATS -s {day} | egrep -w "194|195"' cmd = f'STATS -s {day} | egrep -w "{pattern}"' r = subprocess.run (cmd, shell = True, stdout = subprocess.PIPE) output = r.stdout.decode() res = {} for line in output.strip().split("\n"): try: sid, count = (int(item) for item in line.split()[:2]) res [sid] = count except: return print (day, [res [s] for s in sids]) if __name__ == "__main__": from sys import argv start = str_to_date (argv [1]) stop = str_to_date (argv [2]) for day in periode (start, stop): stat (day)