import datetime import configobj import pkgutil import os import sys import argparse import wimcollect.httpddu as httpddu import wimcollect.sshdmc as sshdmc import wimcollect.logger as logger import wimcollect.quickviz as quickviz def main(): # Configuration file pkgpath = os.path.dirname(pkgutil.get_loader("wimcollect").path) conf_file_path = os.path.join(pkgpath, "config", "settings.ini") if not os.path.exists(conf_file_path): sys.stderr.write("Configuration file not found in [" + conf_file_path + "]") return config_parser = configobj.ConfigObj(conf_file_path) # Logger log = logger.Logger(config_parser) log.write(instrument="", message="------------------------------------------------------------------") log.write(instrument="", message=" ".join(sys.argv)) log.write(instrument='', message="------------------------------------------------------------------") yesterday = datetime.datetime.now() - datetime.timedelta(1) httpddu_col = httpddu.Collector(config_parser, log) httpddu_col.download_picarro(yesterday) sshdmc_col = sshdmc.Collector(config_parser, log) sshdmc_col.download_picarro(yesterday) vizual = quickviz.Visualizator(config_parser, log) vizual.create_data_source_file("DDU", "HIDS2189", yesterday) vizual.create_data_source_file("DMC", "HIDS2319", yesterday) # # # Parse CLI arguments # parser = argparse.ArgumentParser(description='Launch a push.') # parser.add_argument('-i', '--instruments', # nargs='+', # default="picarro", # choices=["picarro", "hobo"]) # parser.add_argument('-a', '--actions', # nargs='+', # default=["compress", "send"], # choices=["compress", "send"]) # parser.add_argument('-fd', '--firstday', default=None, type=format_date, # help="First day (in ISO format YYYY-MM-DD) of the desired timeframe to be compressed.") # parser.add_argument('-ld', '--lastday', default=None, type=format_date, # help="Last day (in ISO format YYYY-MM-DD) of the desired timeframe to be compressed.") # parser.add_argument('-d', '--day', default=None, type=format_date, # help="Day (in ISO format YYYY-MM-DD) whose Picarro data whould be compressed. " # "Note: single-day selection is not applicable for Hobo, used --firstday instead.") # args = parser.parse_args() # # # Compress # if "compress" in args.actions: # # Picarro # if "picarro" in args.instruments: # pic_comp = ftpcea.Compressor(config_parser, log) # if args.firstday is not None: # pic_comp.compress_timeframe(first_day=args.firstday, last_day=args.lastday) # elif args.day is not None: # pic_comp.compress_single_day(day=args.day) # else: # pic_comp.compress_changed() # # # Hobo # if "hobo" in args.instruments: # hobo_comp = hobo.Compressor(config_parser, log) # if args.firstday is not None: # hobo_comp.compress_timeframe(first_day=args.firstday, last_day=args.lastday) # elif args.day is not None: # sys.stderr.write("Parameter 'day' is not useable with Hobo. Use '--firstday' instead.") # else: # hobo_comp.compress_changed() # # # Send # if "send" in args.actions: # sender = ftpsender.FtpSender(config_parser, log) # sender.send_all() def quickviz_antarctica(): # Configuration file pkgpath = os.path.dirname(pkgutil.get_loader("wimcollect").path) conf_file_path = os.path.join(pkgpath, "config", "settings.ini") if not os.path.exists(conf_file_path): sys.stderr.write("Configuration file not found in [" + conf_file_path + "]") return config_parser = configobj.ConfigObj(conf_file_path) # Logger log = logger.Logger(config_parser) yesterday = datetime.datetime.now() - datetime.timedelta(1) # Parse CLI arguments parser = argparse.ArgumentParser(description='Generate data for PIcarro\' s quick calibration visualization.') parser.add_argument('-d', '--day', default=yesterday, type=format_date, help="Day (in ISO format YYYY-MM-DD) which should be processed.") args = parser.parse_args() httpddu_col = httpddu.Collector(config_parser, log) try: httpddu_col.download_picarro(args.day) except: pass sshdmc_col = sshdmc.Collector(config_parser, log) try: sshdmc_col.download_picarro(args.day) except: pass vizual = quickviz.Visualizator(config_parser, log) try: vizual.create_data_source_file("DDU", "HIDS2189", args.day) except: pass try: vizual.create_data_source_file("DMC", "HIDS2319", args.day) except: pass def format_date(string: str) -> datetime.date: return datetime.datetime.strptime(string, "%Y-%m-%d").date() if __name__ == "__main__": main()