Read the task.json from work_dir.

    Args:
        config (dict): the running config, to find work_dir.

    Returns:
        dict: the contents of task.json

    Raises:
        ScriptWorkerTaskException: on error.
559682
def get_task(config):
    
    path = os.path.join(config['work_dir'], "task.json")
    message = "Can't read task from {}!\n%(exc)s".format(path)
    contents = load_json_or_yaml(path, is_path=True, message=message)
    return contents
536954
def load(self):
    
    try:
      if not self.__in_memory:
        self._json = json.loads(self._load_from_configs(self._main_config))
        # ToDo: make this via extension for root logger
        # self._log = aLogger.getLogger(__name__, cfg=self)  # reload logger using loaded configuration
        self._load_modules()
      else:
        self._json = {}
      # parse command line, currently used for re-assign settings in configuration, but can't be used as replacement
      self._load_from_commandline()
    except Exception as err:
      self._json = None
      raise
136148
function readConfigFile(configJSONPath) {
  var confiJSONFullPath = path.join(process.cwd(), configJSONPath);
  
  try{
    var configStr = fs.readFileSync(confiJSONFullPath, {encoding:'utf8'});
    return JSON.parse(configStr);
  } catch (err){
    throw new Error(`Invalid launcher configuration file: ${confiJSONFullPath}
${err.toString()}`);
  }
}
280762
def try_read(self, config_dir=None, **kwargs):
        
        if isinstance(config_dir, basestring):
            config_dir = (config_dir,)

        for cdir in config_dir:
            try:
                self.read(cdir, **kwargs)
                return cdir

            except IOError as e:
                pass
114127
def serialized_task(self, task: Task) -> Tuple[str, str]:
        
        return f"{task.hash}.json", task.json
833412
public void toJson(JsonWriter jsonWriter, boolean keepConfig) throws IOException {
    jsonWriter.beginObject();

    jsonWriter.name("task id").value(this.getTaskId()).name("task state").value(this.getWorkingState().name())
        .name("start time").value(this.getStartTime()).name("end time").value(this.getEndTime()).name("duration")
        .value(this.getTaskDuration()).name("retry count")
        .value(this.getPropAsInt(ConfigurationKeys.TASK_RETRIES_KEY, 0));

    // Also add failure exception information if it exists. This information is useful even in the
    // case that the task finally succeeds so we know what happened in the course of task execution.
    if (getTaskFailureException().isPresent()) {
      jsonWriter.name("exception").value(getTaskFailureException().get());
    }

    if (keepConfig) {
      jsonWriter.name("properties");
      jsonWriter.beginObject();
      for (String key : this.getPropertyNames()) {
        jsonWriter.name(key).value(this.getProp(key));
      }
      jsonWriter.endObject();
    }

    jsonWriter.endObject();
  }
1104308
def load_project_config(self):
        # type: () -> Dict[str, Any]
        
        config_file = os.path.join(self.project_dir, '.chalice', 'config.json')
        with open(config_file) as f:
            return json.loads(f.read())
1048365
def rq_task(self):
        
        task_path = self.task.split('.')
        module_name = '.'.join(task_path[:-1])
        task_name = task_path[-1]

        module = importlib.import_module(module_name)
        return getattr(module, task_name)
467961
def load_conf(cfg_path):
    
    global config
    try:
        cfg = open(cfg_path, 'r')
    except Exception as ex:
        if verbose:
            print("Unable to open {0}".format(cfg_path))
            print(str(ex))
        return False

    # Read the entire contents of the conf file
    cfg_json = cfg.read()
    cfg.close()
    # print(cfg_json)

    # Try to parse the conf file into a Python structure
    try:
        config = json.loads(cfg_json)
    except Exception as ex:
        print("Unable to parse configuration file as JSON")
        print(str(ex))
        return False

    # This config was successfully loaded
    return True
991185
def _load_config(self, path):
        
        p = os.path.abspath(os.path.expanduser(path))
        logger.debug('Loading configuration from: %s', p)
        return read_json_file(p)
801560
def exec_task(task_path, data):
    
    if not data:
        data = {'data': None, 'path': task_path}

    elif not isinstance(data, (str, bytes)):
        data = {'data': json.dumps(data, cls=RequestJSONEncoder),
                'path': task_path}

    else:
        # Open the data from file, if necessary.
        if data is not None and data.startswith("file://"):
            with open(data[len("file://"):]) as f:
                data = f.read()

        data = {'data': data, 'path': task_path}

    # Prepare the task.
    job = Job(data)
    (task, task_callable) = create_task(task_path)

    with delegating_job_context(job, task, task_callable) as jc:
        return jc.task_callable(jc.task_data)
1056733
def readConfigFromJSON(self, fileName):
        
        self.__logger.debug("readConfigFromJSON: reading from " + fileName)
        with open(fileName) as data_file:
            data = load(data_file)
        self.readConfig(data)
853425
def check_task_status_and_id(task_json):
        
        if task_json.get('ImportImageTasks') is not None:
            task = task_json['ImportImageTasks'][0]
        else:
            task = task_json

        current_status = task['Status']
        image_id = task['ImportTaskId']
        if current_status == 'completed':
            print "The import has completed succesfully as ID: {}".format(image_id)
            return False, image_id
        elif current_status == 'deleting':
            print "The import job has been cancelled for some reason"
            return False, None
        elif current_status == 'deleted':
            print "The import job was cancelled"
            return False, None
        else:
            print "The current import job for id {} status is: {}".format(image_id, current_status)
            print "sleeping for 30 seconds"
            time.sleep(30)
            return True, image_id
569786
def parser(input_file_path='config.json'):
    '''
    
    '''

    # --- Read .json file
    try:
        with open(input_file_path, 'r') as config_file:
            config_new = json.load(config_file)
            config_file.close()
    except:
        raise Exception('Config file "'+input_file_path+'" not loaded properly. Please check it an try again.')

    import copy
    options = update_config(config_new, copy.deepcopy(default_config))

    return options
357450
def get_task_workers(self, task_name=None, json_obj=None):
        
        if task_name is None and json_obj is None:
            raise ValueError('Either task_name or json_obj should be provided')

        if json_obj is None:
            json_obj = self.get_task_detail2(task_name)
        return WorkerDetail2.extract_from_json(json_obj, client=self._client, parent=self)
398985
def _taskdict(task):
    '''
    
    '''
    if task is None:
        task = asyncio.current_task()

    assert task
    taskvars = getattr(task, '_syn_taskvars', None)

    if taskvars is None:
        taskvars = varinit(task)

    return taskvars
1168895
function loadConfig() {
  var root = process.cwd()
    , config = readConfig(path.join(root, '_config.json'));
  config.root = root;
  return config;
}