diff --git a/ArchiveExtractor.py b/ArchiveExtractor.py index 1e4fef8e6f391adc11fada4ed11da6f7a2765614..a87cb05de193fd083eef2ae4cc816eda07ec194e 100755 --- a/ArchiveExtractor.py +++ b/ArchiveExtractor.py @@ -291,11 +291,17 @@ if __name__ == "__main__": help="Extractor device number, default: %(default)s") parser.add_argument("--fileout", type=str, default="extracted_%s.npy"%datetime.datetime.now().strftime("%Y%m%d_%H%M%S"), - help="filename of the extraction destination. Default: %(default)s"), + help="filename of the extraction destination. Default: %(default)s"), parser.add_argument('--log', type=str, default="INFO", help="Log level. Default: %(default)s.") + + parser.add_argument('--filemode', action="store_true", + help="Set attribute to filemode."+ + " Instead of specifying attributes, put a path to a file containing a list of attributes."+ + " The file contains one attribute per line.") + parser.add_argument('attributes', type=str, nargs='+', help="List of attributes to extract. Full tango path.") @@ -316,6 +322,23 @@ if __name__ == "__main__": logger.debug("Parsed arguments: %s"%args) + ####################################################### + # Filemode or not + if args.filemode: + logger.info("Filemode, openning file %s"%args.attributes[0]) + # Read the file. Each line is an attribute + with open(args.attributes[0], "r") as fp: + attributes = fp.readlines() + + logger.debug("Read lines : %s"%attributes) + + # Clean end of line + for i_a in range(len(attributes)): + attributes[i_a] = attributes[i_a].rstrip() + + else: + attributes = args.attributes + ####################################################### # Select Extractor extractor = "archiving/%sDBExtractor/%d"%(args.DB, args.DBN) @@ -328,7 +351,7 @@ if __name__ == "__main__": # Extract from database logger.info("Extract from %s to %s."%(args.dateStart, args.dateStop)) - for attr in args.attributes: + for attr in attributes: logger.info("Extracting attribute %s..."%attr) try: