def create_task_id(self):
     """Recorder init, create_task_id."""
     if disk_handle.check_disk(
             self.conf_reader.data_args.get('output_path')) == -2:
         return -1
     self.create_backup_id()
     self.output_directory = self.conf_reader.data_args.get('output_path') \
             + '/' \
             + self.conf_reader.vehicle['vehicle_id'] \
             + '_' \
             + datetime.datetime.now().strftime('%Y%m%d%H%M%S')
     if not os.path.exists(self.output_directory):
         os.mkdir(self.output_directory)
     for data_dir in self.conf_reader.data_type:
         try:
             os.mkdir(self.output_directory + "/" + data_dir)
         except Exception as e:
             logging.error("Make sub directory in task failed, %s", str(e))
             return -1
     recorder_meta = {
         'meta_info': [
             {
                 'basic': {
                     'data_recorder_version': G_VERSION,
                     'organization_name': \
                         self.conf_reader.organization.get('name'),
                     'organization_website': \
                         self.conf_reader.organization.get('website'),
                     'organization_description': \
                         self.conf_reader.organization.get('description'),
                     'vehicle_id': \
                         self.conf_reader.vehicle.get('vehicle_id'),
                     'vehicle_type': \
                         self.conf_reader.vehicle.get('vehicle_type'),
                     'vehicle_tag': \
                         self.conf_reader.vehicle.get('vehicle_tag'),
                     'vehicle_description': \
                         self.conf_reader.vehicle.get('description'),
                     'task_purpose': self.conf_reader.task_purpose,
                     'system_uptime': self.get_system_uptime()
                 }
             }
         ]
     }
     meta_ext = self.conf_reader.data_args.get('meta_extension')
     meta_extension = (meta_ext if meta_ext == 'ini' or meta_ext == 'json'
                       else "ini")
     ret = meta_manager.create_meta(
         self.output_directory + '/meta/recorder.' + meta_extension,
         meta_extension, recorder_meta)
     if ret != 0:
         return -1
     self.update_link()
     logging.info("Create task_id %s successfully", self.output_directory)
     for k, v in self.conf_reader.task_data_args.iteritems():
         if v['if_record'] and v['record_method'] == "rsync":
             if v['action_args']['with_remove']:
                 continue
             self.sync_static_data(k)
     self.if_taskid_isready = True
     return 0
Beispiel #2
0
 def create_task_id(self):
     """Recorder init, create_task_id."""
     if disk_handle.check_disk(
         self.conf_reader.data_args.get('output_path')) == -2:
         return -1
     self.create_backup_id()
     self.output_directory = self.conf_reader.data_args.get('output_path') \
             + '/' \
             + self.conf_reader.vehicle['vehicle_id'] \
             + '_' \
             + datetime.datetime.now().strftime('%Y%m%d%H%M%S')
     if not os.path.exists(self.output_directory):
         os.mkdir(self.output_directory)
     for data_dir in self.conf_reader.data_type:
         try:
             os.mkdir(self.output_directory + "/" + data_dir)
         except Exception as e:
             logging.error("Make sub directory in task failed, %s", str(e))
             return -1
     recorder_meta = {
         'meta_info': [
             {
                 'basic': {
                     'data_recorder_version': G_VERSION,
                     'organization_name': \
                         self.conf_reader.organization.get('name'),
                     'organization_website': \
                         self.conf_reader.organization.get('website'),
                     'organization_description': \
                         self.conf_reader.organization.get('description'),
                     'vehicle_id': \
                         self.conf_reader.vehicle.get('vehicle_id'),
                     'vehicle_type': \
                         self.conf_reader.vehicle.get('vehicle_type'),
                     'vehicle_tag': \
                         self.conf_reader.vehicle.get('vehicle_tag'),
                     'vehicle_description': \
                         self.conf_reader.vehicle.get('description'),
                     'task_purpose': self.conf_reader.task_purpose,
                     'system_uptime': self.get_system_uptime()
                 }
             }
         ]
     }
     meta_ext = self.conf_reader.data_args.get('meta_extension')
     meta_extension = (meta_ext
         if meta_ext == 'ini' or meta_ext == 'json' else "ini")
     ret = meta_manager.create_meta(
         self.output_directory + '/meta/recorder.' + meta_extension,
         meta_extension,
         recorder_meta)
     if ret != 0:
         return -1
     self.update_link()
     logging.info("Create task_id %s successfully", self.output_directory)
     for k, v in self.conf_reader.task_data_args.iteritems():
         if v['if_record'] and v['record_method'] == "rsync":
             if v['action_args']['with_remove']:
                 continue
             self.sync_static_data(k)
     self.if_taskid_isready = True
     return 0