@@ -26,17 +26,17 @@ class MyFormatter(argparse.RawTextHelpFormatter,
2626 pass
2727
2828
29- def _get_product_from_detail (detail , product , contents , folder ,
29+ def _get_product_from_detail (detail , tproduct , contents , folder ,
3030 version , source , list_only = False ):
31- if not detail .hasProduct (product ):
31+ if not detail .hasProduct (tproduct ):
3232 return False
3333
3434 try :
3535 products = detail .getProducts (
36- product , source = source , version = version )
36+ tproduct , source = source , version = version )
3737 except ProductNotFoundError :
3838 print ('No %s product found for event %s and source %s. Skipping.' %
39- (product , detail .id , source ))
39+ (tproduct , detail .id , source ))
4040 return False
4141
4242 ic = len (products )
@@ -59,9 +59,10 @@ def _get_product_from_detail(detail, product, contents, folder,
5959 filename = os .path .join (eventfolder , fname )
6060 try :
6161 product .getContent (content_name , filename = filename )
62- except Exception as e :
63- print ('Could not download %s from event %s. Continuing...' % (
64- content_name , detail .id ))
62+ except Exception :
63+ fmt = 'Could not download %s from event %s. Continuing...'
64+ tpl = (content_name , detail .id )
65+ print (fmt % tpl )
6566 continue
6667 logging .info ('Downloaded %s %s to %s\n ' %
6768 (eventid , content , filename ))
@@ -212,8 +213,13 @@ def main():
212213
213214 setup_logger (args .logfile , args .loglevel )
214215
216+ get_superseded = False
217+ if args .version in ['all' , 'first' ]:
218+ get_superseded = True
219+
215220 if args .eventid :
216- detail = get_event_by_id (args .eventid , includesuperseded = True ,
221+ detail = get_event_by_id (args .eventid ,
222+ includesuperseded = get_superseded ,
217223 scenario = args .scenario )
218224 _get_product_from_detail (detail , args .product , args .contents ,
219225 args .outputFolder , args .version ,
@@ -336,9 +342,9 @@ def main():
336342 if not event .hasProduct (args .product ):
337343 continue
338344 try :
339- detail = event .getDetailEvent (includesuperseded = True ,
345+ detail = event .getDetailEvent (includesuperseded = get_superseded ,
340346 scenario = args .scenario )
341- except Exception as e :
347+ except Exception :
342348 print (
343349 'Failed to retrieve detail event for event %s... continuing.' % event .id )
344350 continue
0 commit comments