Ejemplo n.º 1
0
 def _make_process_file_dct(self):
     """ Prepares process-file dct.
         Called by make_context() """
     process_dct = {'allow_processing': True}
     results = ProcessorTracker.objects.all()  # only one record
     log.debug('results, ```{}```'.format(results))
     if not results:
         log.debug('gonna add an initial record')
         p = ProcessorTracker(current_status='not_yet_processed',
                              recent_processing=json.dumps(
                                  {
                                      'percent_done': 'N/A',
                                      'time_left': 'N/A',
                                      'recent_times_per_record': [],
                                      'average_time_per_record': 0
                                  },
                                  sort_keys=True,
                                  indent=2))
         p.save()
     tracker_data = ProcessorTracker.objects.all()[0]
     recent_processing_dct = json.loads(tracker_data.recent_processing)
     process_dct['status'] = tracker_data.current_status
     process_dct['last_run'] = tracker_data.processing_ended
     process_dct['percent_done'] = recent_processing_dct['percent_done']
     process_dct['time_left'] = recent_processing_dct['time_left']
     if tracker_data.current_status == 'in_process':
         process_dct['allow_processing'] = False
     return process_dct
Ejemplo n.º 2
0
 def setUp( self ):
     """ Runs initialization. """
     self.builder = HoldingsDctBuilder(
         settings_app.TEST_FROM_RAPID_UTF8_FILEPATH,
         )
     p = ProcessorTracker(
         current_status='not_yet_processed',
         recent_processing=json.dumps(
             {'percent_done': 'N/A', 'time_left': 'N/A', 'recent_times_per_record': [], 'average_time_per_record': 0 }, sort_keys=True, indent=2 )
         )
     p.save()
Ejemplo n.º 3
0
 def setUp(self):
     """ Runs initialization. """
     self.builder = HoldingsDctBuilder(
         settings_app.TEST_FROM_RAPID_UTF8_FILEPATH, )
     p = ProcessorTracker(current_status='not_yet_processed',
                          recent_processing=json.dumps(
                              {
                                  'percent_done': 'N/A',
                                  'time_left': 'N/A',
                                  'recent_times_per_record': [],
                                  'average_time_per_record': 0
                              },
                              sort_keys=True,
                              indent=2))
     p.save()
Ejemplo n.º 4
0
 def _make_process_file_dct( self ):
     """ Prepares process-file dct.
         Called by make_context() """
     process_dct = { 'allow_processing': True }
     results = ProcessorTracker.objects.all()  # only one record
     log.debug( 'results, ```{}```'.format(results) )
     if not results:
         log.debug( 'gonna add an initial record' )
         p = ProcessorTracker(
             current_status='not_yet_processed',
             recent_processing=json.dumps(
                 {'percent_done': 'N/A', 'time_left': 'N/A', 'recent_times_per_record': [], 'average_time_per_record': 0 }, sort_keys=True, indent=2 )
             )
         p.save()
     tracker_data = ProcessorTracker.objects.all()[0]
     recent_processing_dct = json.loads( tracker_data.recent_processing )
     process_dct['status'] = tracker_data.current_status
     process_dct['last_run'] = tracker_data.processing_ended
     process_dct['percent_done'] = recent_processing_dct['percent_done']
     process_dct['time_left'] = recent_processing_dct['time_left']
     if tracker_data.current_status == 'in_process':
         process_dct['allow_processing'] = False
     return process_dct