def tag2(tagid, begin_time, end_time, timestep, mode, utc, show, plot): """Parse user friendly tag query input and assemble wincc tag query""" if timestep and not end_time: end_time = datetime_to_str_without_ms(datetime.now()) query = tag_query_builder(tagid, begin_time, end_time, timestep, mode, utc) if show: print(query) return toc = tic() try: w = wincc(host_info.address, host_info.database) w.connect() w.execute(query) records = w.create_tag_records() print("Fetched data in {time}.".format(time=round(toc(), 3))) # print(tags) # tags.plot() for record in records: print(record) if plot: plot_tag_records(records) except Exception as e: print(e) print(traceback.format_exc()) finally: w.close()
def tag(tagid, begin_time, end_time, timestep, mode, utc, show): """Parse user friendly tag query and assemble userunfriendly wincc query""" query = tag_query_builder(tagid, begin_time, end_time, timestep, mode, utc) if show: print(query) return toc = tic() try: w = wincc(host_info.address, host_info.database) w.connect() w.execute(query) if w.rowcount(): print_tag_logging(w.fetchall()) # for rec in w.fetchall(): # print rec print("Fetched data in {time}.".format(time=round(toc(), 3))) except Exception as e: print(e) print(traceback.format_exc()) finally: w.close()
def tag(tagid, begin_time, end_time, timestep, mode, utc, show): """Parse user friendly tag query and assemble userunfriendly wincc query""" query = tag_query_builder(tagid, begin_time, end_time, timestep, mode, utc) if show: print(query) return toc = tic() try: w = wincc(host_info.address, host_info.database) w.connect() w.execute(query) if w.rowcount(): print_tag_logging(w.fetchall()) # for rec in w.fetchall(): # print rec print("Fetched data in {time}.".format(time=round(toc(), 3))) except Exception as e: print(e) print(traceback.format_exc()) finally: w.close()
def tag2(tagid, begin_time, end_time, timestep, mode, utc, show, plot): """Parse user friendly tag query input and assemble wincc tag query""" if timestep and not end_time: end_time = datetime_to_str_without_ms(datetime.now()) query = tag_query_builder(tagid, begin_time, end_time, timestep, mode, utc) if show: print(query) return toc = tic() try: w = wincc(host_info.address, host_info.database) w.connect() w.execute(query) records = w.create_tag_records() print("Fetched data in {time}.".format(time=round(toc(), 3))) # print(tags) # tags.plot() for record in records: print(record) if plot: plot_tag_records(records) except Exception as e: print(e) print(traceback.format_exc()) finally: w.close()
def tag2(tagid, begin_time, end_time, timestep, mode, utc, show, plot, outfile, outfile_col_name, outfile_time_zone): """Parse user friendly tag query input and assemble wincc tag query""" if timestep and not end_time: end_time = datetime_to_str_without_ms(datetime.now()) query = tag_query_builder(tagid, begin_time, end_time, timestep, mode, utc) if show: print(query) return toc = tic() try: w = wincc(host_info.address, host_info.database) w.connect() w.execute(query) records = w.create_tag_records(utc) print("Fetched data in {time}.".format(time=round(toc(), 3))) if records: if (outfile != ''): with open(outfile, "w") as f: # print(records.to_csv().encode("UTF-8")) for rec in records: f.write( rec.to_csv(name=outfile_col_name.encode("UTF-8"), tz=outfile_time_zone)) else: for record in records: print(record) if plot: plot_tag_records(records) else: logging.warning("No data returned.") except Exception as e: print(e) print(traceback.format_exc()) finally: w.close()