def get_latest_event_id(self): """Query the ftp server and determine the latest event id. :return: A string containing a valid event id. :raises: NetworkError """ ftp_client = FtpClient() try: ftp_client_list = ftp_client.get_listing() ftp_client_list.sort(key=lambda x: x.lower()) except NetworkError: raise now = datetime.now() now = int( '%04d%02d%02d%02d%02d%02d' % ( now.year, now.month, now.day, now.hour, now.minute, now.second )) event_id = now + 1 while int(event_id) > now: if len(ftp_client_list) < 1: raise EventIdError('Latest Event Id could not be obtained') event_id = ftp_client_list.pop().split('/')[-1].split('.')[0] if event_id is None: raise EventIdError('Latest Event Id could not be obtained') self.event_id = event_id
def get_latest_event_id(self): """Query the ftp server and determine the latest event id. :return: A string containing a valid event id. :raises: NetworkError """ ftp_client = FtpClient() try: ftp_client_list = ftp_client.get_listing() ftp_client_list.sort(key=lambda x: x.lower()) except NetworkError: raise now = datetime.now() now = int( '%04d%02d%02d%02d%02d%02d' % (now.year, now.month, now.day, now.hour, now.minute, now.second)) event_id = now + 1 while int(event_id) > now: if len(ftp_client_list) < 1: raise EventIdError('Latest Event Id could not be obtained') event_id = ftp_client_list.pop().split('/')[-1].split('.')[0] if event_id is None: raise EventIdError('Latest Event Id could not be obtained') self.event_id = event_id
my_event_id = sys.argv[1] if my_event_id in "--list": # ftp_client = FtpClient() sftp_client = SFtpClient() # myListing = ftp_client.get_listing() dir_listing = sftp_client.get_listing(my_func=is_event_id) for event in dir_listing: print event sys.exit(0) elif my_event_id in "--run-all": # # Caution, this code path gets memory leaks, use the # batch file approach rather! # ftp_client = FtpClient() dir_listing = ftp_client.get_listing() for event in dir_listing: if "out" not in event: continue event = event.replace("ftp://118.97.83.243/", "") event = event.replace(".out.zip", "") print "Processing %s" % event # noinspection PyBroadException try: process_event(event, my_locale) except: # pylint: disable=W0702 LOGGER.exception("Failed to process %s" % event) sys.exit(0) else: process_event(my_event_id, my_locale)
my_event_id = sys.argv[1] if my_event_id in '--list': # myFtpClient = FtpClient() sftp_client = SFtpClient() # myListing = myFtpClient.get_listing() dir_listing = sftp_client.get_listing(my_func=is_event_id) for event in dir_listing: print event sys.exit(0) elif my_event_id in '--run-all': # # Caution, this code path gets memory leaks, use the # batch file approach rather! # myFtpClient = FtpClient() dir_listing = myFtpClient.get_listing() for event in dir_listing: if 'out' not in event: continue event = event.replace('ftp://118.97.83.243/', '') event = event.replace('.out.zip', '') print 'Processing %s' % event # noinspection PyBroadException try: process_event(event, my_locale) except: # pylint: disable=W0702 LOGGER.exception('Failed to process %s' % event) sys.exit(0) else: process_event(my_event_id, my_locale)
my_event_id = sys.argv[1] if my_event_id in '--list': # ftp_client = FtpClient() sftp_client = SFtpClient() # myListing = ftp_client.get_listing() dir_listing = sftp_client.get_listing(my_func=is_event_id) for event in dir_listing: print event sys.exit(0) elif my_event_id in '--run-all': # # Caution, this code path gets memory leaks, use the # batch file approach rather! # ftp_client = FtpClient() dir_listing = ftp_client.get_listing() for event in dir_listing: if 'out' not in event: continue event = event.replace('ftp://118.97.83.243/', '') event = event.replace('.out.zip', '') print 'Processing %s' % event # noinspection PyBroadException try: process_event(event, my_locale) except: # pylint: disable=W0702 LOGGER.exception('Failed to process %s' % event) sys.exit(0) else: process_event(my_event_id, my_locale)