parameters: (self, instance_config, osm_filename, job_id, dataset_uid)
docstring: launch osm2ed
docstring_summary: launch osm2ed
docstring_tokens: launch osm2ed
function: def osm2ed(self, instance_config, osm_filename, job_id, dataset_uid):
      """ launch osm2ed """
      job = models.Job.query.get(job_id)
      dataset = _retrieve_dataset_and_set_state("osm", job.id)
      instance = job.instance
      poi_types_json = None
      if instance.poi_type_json:
          poi_types_json = instance.poi_type_json.poi_types_json
  
      osm_filename = unzip_if_needed(osm_filename)
      if os.path.isdir(osm_filename):
          osm_filename = glob.glob('{}/*.pbf'.format(osm_filename))[0]
  
      logger = get_instance_logger(instance, task_id=job_id)
      try:
          connection_string = make_connection_string(instance_config)
          res = None
          args = ["-i", osm_filename, "--connection-string", connection_string]
          if poi_types_json:
              args.append('-p')
              args.append(u'{}'.format(poi_types_json))
  
          args.append("--local_syslog")
          args.append("--log_comment")
          args.append(instance_config.name)
  
          if instance.admins_from_cities_db:
              cities_db = current_app.config.get('CITIES_DATABASE_URI')
              if not cities_db:
                  raise ValueError(
                      "impossible to use osm2ed with cities db since no cities database configuration has been set"
                  )
              args.extend(["--cities-connection-string", cities_db])
          with collect_metric("osm2ed", job, dataset_uid):
              res = launch_exec("osm2ed", args, logger)
          if res != 0:
              # @TODO: exception
              raise ValueError("osm2ed failed")
          dataset.state = "done"
      except:
          logger.exception("")
          job.state = "failed"
          dataset.state = "failed"
          raise
      finally:
          models.db.session.commit()
function_tokens: def osm2ed ( self , instance_config , osm_filename , job_id , dataset_uid ) : job = models . Job . query . get ( job_id ) dataset = _retrieve_dataset_and_set_state ( "osm" , job . id ) instance = job . instance poi_types_json = None if instance . poi_type_json : poi_types_json = instance . poi_type_json . poi_types_json osm_filename = unzip_if_needed ( osm_filename ) if os . path . isdir ( osm_filename ) : osm_filename = glob . glob ( '{}/*.pbf' . format ( osm_filename ) ) [ 0 ] logger = get_instance_logger ( instance , task_id = job_id ) try : connection_string = make_connection_string ( instance_config ) res = None args = [ "-i" , osm_filename , "--connection-string" , connection_string ] if poi_types_json : args . append ( '-p' ) args . append ( u'{}' . format ( poi_types_json ) ) args . append ( "--local_syslog" ) args . append ( "--log_comment" ) args . append ( instance_config . name ) if instance . admins_from_cities_db : cities_db = current_app . config . get ( 'CITIES_DATABASE_URI' ) if not cities_db : raise ValueError ( "impossible to use osm2ed with cities db since no cities database configuration has been set" ) args . extend ( [ "--cities-connection-string" , cities_db ] ) with collect_metric ( "osm2ed" , job , dataset_uid ) : res = launch_exec ( "osm2ed" , args , logger ) if res != 0 : # @TODO: exception raise ValueError ( "osm2ed failed" ) dataset . state = "done" except : logger . exception ( "" ) job . state = "failed" dataset . state = "failed" raise finally : models . db . session . commit ( )