Skip to content
Snippets Groups Projects
Commit a70a697b authored by BRONES Romain's avatar BRONES Romain
Browse files

[ArchiveExtractor] Ajoute la fonctionnalité filemode

* Permet de préciser l'option --filemode
* Dans ce cas, lit dans un fichier la liste des attributs
parent daa5982c
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment