Converts a .taskrc file path into a Hash that can be converted into a
 TaskrcModel object

 @param rc_file [String,Pathname] a valid pathname to a .taskrc file
 @return [Models::TaskrcModel] the instance variable config
 @api private
963571
def mappable_to_model rc_file
      rc_file.map! { |l| line_to_tuple(l) }.compact!
      taskrc = Hash[rc_file]
      hash_to_model(taskrc)
    end
56781
def send(self, task_path, args, kwargs):
        
        message = {
                'task_path': task_path,
                'capture_response': self.capture_response,
                'response_id': self.response_id,
                'args': args,
                'kwargs': kwargs
            }
        self._send(message)
        return self
1178879
def load_config(self, namespace=None, rcfile=None):
        
        if namespace is None:
            namespace = config
        if namespace.scgi_url:
            return  # already have the connection to rTorrent

        # Get and check config file name
        if not rcfile:
            rcfile = getattr(config, "rtorrent_rc", None)
        if not rcfile:
            raise error.UserError("No 'rtorrent_rc' path defined in configuration!")
        if not os.path.isfile(rcfile):
            raise error.UserError("Config file %r doesn't exist!" % (rcfile,))

        # Parse the file
        self.LOG.debug("Loading rtorrent config from %r" % (rcfile,))
        rc_vals = Bunch(scgi_local='', scgi_port = '')
        with open(rcfile) as handle:
            continued = False
            for line in handle.readlines():
                # Skip comments, continuations, and empty lines
                line = line.strip()
                continued, was_continued = line.endswith('\\'), continued
                if not line or was_continued or line.startswith("#"):
                    continue

                # Be lenient about errors, after all it's not our own config file
                try:
                    key, val = line.split("=", 1)
                except ValueError:
                    self.LOG.warning("Ignored invalid line %r in %r!" % (line, rcfile))
                    continue
                key, val = key.strip(), val.strip()
                key = self.RTORRENT_RC_ALIASES.get(key, key).replace('.', '_')

                # Copy values we're interested in
                if key in self.RTORRENT_RC_KEYS:
                    self.LOG.debug("rtorrent.rc: %s = %s" % (key, val))
                    rc_vals[key] = val

        # Validate fields
        if rc_vals.scgi_local:
            rc_vals.scgi_local = os.path.expanduser(rc_vals.scgi_local)
            if rc_vals.scgi_local.startswith('/'):
                rc_vals.scgi_local = "scgi://" + rc_vals.scgi_local
        if rc_vals.scgi_port and not rc_vals.scgi_port.startswith("scgi://"):
            rc_vals.scgi_port = "scgi://" + rc_vals.scgi_port

        # Prefer UNIX domain sockets over TCP sockets
        namespace.scgi_url = rc_vals.scgi_local or rc_vals.scgi_port
887448
def _GetTaskStorageFilePath(self, task):
    
    filename = '{0:s}.plaso'.format(task.identifier)
    return os.path.join(self._task_storage_path, filename)
824620
def rm_rf(z, path)
      z.get_children(:path => path).tap do |h|
        if h[:rc].zero?
          h[:children].each do |child|
            rm_rf(z, File.join(path, child))
          end
        elsif h[:rc] == ZNONODE
          # no-op
        else
          raise "Oh noes! unexpected return value! #{h.inspect}"
        end
      end

      rv = z.delete(:path => path)

      unless (rv[:rc].zero? or rv[:rc] == ZNONODE)
        raise "oh noes! failed to delete #{path}" 
      end

      path
    end
1237420
private void setupTaskCacheFileAccess(TaskControllerContext context) {
    String taskId = context.task.getTaskID().toString();
    JobID jobId = JobID.forName(getJobId(context));
    //Change permission for the task across all the disks
    for(String localDir : mapredLocalDirs) {
      File f = new File(localDir);
      File taskCacheDir = new File(f,TaskTracker.getLocalTaskDir(
          jobId.toString(), taskId, context.task.isTaskCleanupTask()));
      if(taskCacheDir.exists()) {
        changeDirectoryPermissions(taskCacheDir.getPath(), 
            FILE_PERMISSIONS, true);
      }          
    }//end of local directory Iteration 
  }
560219
public static Path getTaskOutputPath(JobConf conf, String name) 
  throws IOException {
    // ${mapred.out.dir}
    Path outputPath = getOutputPath(conf);
    if (outputPath == null) {
      throw new IOException("Undefined job output-path");
    }

    OutputCommitter committer = conf.getOutputCommitter();
    Path workPath = outputPath;
    TaskAttemptContext context = new TaskAttemptContext(conf,
                TaskAttemptID.forName(conf.get("mapred.task.id")));
    if (committer instanceof FileOutputCommitter) {
      workPath = ((FileOutputCommitter)committer).getWorkPath(context,
                                                              outputPath);
    }
    
    // ${mapred.out.dir}/_temporary/_${taskid}/${name}
    return new Path(workPath, name);
  }
1205925
def erb(templateFileName)
      @binding = binding
      fullTemplateFilePath = relative_path(@rootLinkPath + templateFileName)
      File.open(fullTemplateFilePath, "r") do |input|
        templateText = input.read
        template = ERB.new(templateText, nil, nil)
        template.filename = templateFileName
        result = template.result(@binding)
      end
    end
107778
File getCacheFile(TemplateClass tc) {
        String id = cacheFileName(tc, ".rythm");
        return getCacheFile(id);
    }
614376
def taskdef_to_hash(taskdef)
      args = %i[family cpu memory requires_compatibilities task_role_arn execution_role_arn network_mode container_definitions volumes placement_constraints]
      taskdef.to_hash.slice(*args)
    end
829395
def get_task_filelist(cls, task_factory, courseid, taskid):
        
        task_fs = task_factory.get_task_fs(courseid, taskid)
        if not task_fs.exists():
            return []

        tmp_out = {}
        entries = task_fs.list(True, True, True)
        for entry in entries:
            if os.path.splitext(entry)[0] == "task" and os.path.splitext(entry)[1][1:] in task_factory.get_available_task_file_extensions():
                continue

            data = entry.split("/")
            is_directory = False
            if data[-1] == "":
                is_directory = True
                data = data[0:len(data)-1]
            cur_pos = 0
            tree_pos = tmp_out
            while cur_pos != len(data):
                if data[cur_pos] not in tree_pos:
                    tree_pos[data[cur_pos]] = {} if is_directory or cur_pos != len(data) - 1 else None
                tree_pos = tree_pos[data[cur_pos]]
                cur_pos += 1

        def recur_print(current, level, current_name):
            iteritems = sorted(current.items())
            # First, the files
            recur_print.flattened += [(level, False, f, current_name+"/"+f) for f, t in iteritems if t is None]
            # Then, the dirs
            for name, sub in iteritems:
                if sub is not None:
                    recur_print.flattened.append((level, True, name, current_name+"/"+name+"/"))
                    recur_print(sub, level + 1, current_name + "/" + name)
        recur_print.flattened = []
        recur_print(tmp_out, 0, '')
        return recur_print.flattened
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)
1094409
public void compile(final CCTask task, final File outputDir, final String[] sourceFiles, String[] args,
      final String[] endArgs, final boolean relentless, final CommandLineCompilerConfiguration config,
      final ProgressMonitor monitor) throws BuildException {
    BuildException exc = null;
    //
    // determine length of executable name and args
    //
    String command = getCommandWithPath(config);
    if (config.isUseCcache()) {
      // Replace the command with "ccache" and push the old compiler
      // command into the args.
      final String compilerCommand = command;
      command = CCACHE_CMD;
      args = ObjectArrays.concat(compilerCommand, args);
    }
    int baseLength = command.length() + args.length + endArgs.length;
    if (this.libtool) {
      baseLength += 8;
    }
    for (final String arg : args) {
      baseLength += arg.length();
    }
    for (final String endArg : endArgs) {
      baseLength += endArg.length();
    }
    if (baseLength > getMaximumCommandLength()) {
      throw new BuildException("Command line is over maximum length without specifying source file");
    }
    //
    // typically either 1 or Integer.MAX_VALUE
    //
    final int maxInputFilesPerCommand = getMaximumInputFilesPerCommand();
    final int argumentCountPerInputFile = getArgumentCountPerInputFile();
    for (int sourceIndex = 0; sourceIndex < sourceFiles.length;) {
      int cmdLength = baseLength;
      int firstFileNextExec;
      for (firstFileNextExec = sourceIndex; firstFileNextExec < sourceFiles.length
          && firstFileNextExec - sourceIndex < maxInputFilesPerCommand; firstFileNextExec++) {
        cmdLength += getTotalArgumentLengthForInputFile(outputDir, sourceFiles[firstFileNextExec]);
        if (cmdLength >= getMaximumCommandLength()) {
          break;
        }
      }
      if (firstFileNextExec == sourceIndex) {
        throw new BuildException("Extremely long file name, can't fit on command line");
      }

      ArrayList<String> commandlinePrefix = new ArrayList<>();
      if (this.libtool) {
        commandlinePrefix.add("libtool");
      }
      if((this.fortifyID !=null) && (!this.fortifyID.equals("")))
      {// If FortifyID attribute was set, run the Fortify framework

        commandlinePrefix.add("sourceanalyzer");
        commandlinePrefix.add("-b");
        commandlinePrefix.add(this.fortifyID);
      }
      commandlinePrefix.add(command);
      Collections.addAll(commandlinePrefix, args);

      int retval = 0;
      for (int j = sourceIndex; j < firstFileNextExec; j++) {
        ArrayList<String> commandlineSuffix = new ArrayList<>();

        for (int k = 0; k < argumentCountPerInputFile; k++) {
          commandlineSuffix.add(getInputFileArgument(outputDir, sourceFiles[j], k));
        }
        Collections.addAll(commandlineSuffix, endArgs);

        ArrayList<String> commandline = new ArrayList<>(commandlinePrefix);
        commandline.addAll(commandlineSuffix);
        final int ret = runCommand(task, workDir,
            commandline.toArray(new String[commandline.size()]));
        if (ret != 0) { retval = ret; }
      }
      if (monitor != null) {
        final String[] fileNames = new String[firstFileNextExec - sourceIndex];

        System.arraycopy(sourceFiles, sourceIndex + 0, fileNames, 0, fileNames.length);
        monitor.progress(fileNames);
      }
      //
      // if the process returned a failure code and
      // we aren't holding an exception from an earlier
      // interation
      if (retval != 0 && exc == null) {
        //
        // construct the exception
        //
        exc = new BuildException(getCommandWithPath(config) + " failed with return code " + retval, task.getLocation());

        //
        // and throw it now unless we are relentless
        //
        if (!relentless) {
          throw exc;
        }
      }
      sourceIndex = firstFileNextExec;
    }
    //
    // if the compiler returned a failure value earlier
    // then throw an exception
    if (exc != null) {
      throw exc;
    }
  }
585919
function copyTemplateDir (srcDir, outDir, vars, cb) {
  if (!cb) {
    if (!vars) vars = noop
    cb = vars
    vars = {}
  }

  assert.equal(typeof srcDir, 'string')
  assert.equal(typeof outDir, 'string')
  assert.equal(typeof vars, 'object')
  assert.equal(typeof cb, 'function')

  // create directory
  mkdirp(outDir, function (err) {
    if (err) return cb(err)

    const rs = readdirp({ root: srcDir })
    const streams = []
    const createdFiles = []

    // create a new stream for every file emitted
    rs.on('data', function (file) {
      createdFiles.push(path.join(outDir, maxstache(removeUnderscore(file.path), vars)))
      streams.push(writeFile(outDir, vars, file))
    })

    // delegate errors & close streams
    eos(rs, function (err) {
      if (err) return cb(err)
      parallel(streams, function (err) {
        if (err) return cb(err)
        cb(null, createdFiles)
      })
    })
  })
}
1263704
def define
      if rdoc_task_name != "rdoc"
        desc "Build the RDOC HTML Files"
      else
        desc "Build the #{rdoc_task_name} HTML Files"
      end
      task rdoc_task_name
      
      desc "Force a rebuild of the RDOC files"
      task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
      
      desc "Remove rdoc products" 
      task clobber_task_name do
        rm_r rdoc_dir rescue nil
      end
      
      task :clobber => [clobber_task_name]
      
      directory @rdoc_dir
      task rdoc_task_name => [rdoc_target]
      file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
        rm_r @rdoc_dir rescue nil
        @before_running_rdoc.call if @before_running_rdoc
        args = option_list + @rdoc_files
        if @external
          argstring = args.join(' ')
          sh %{ruby -Ivendor vendor/rd #{argstring}}
        else
          require 'rdoc/rdoc'
          RDoc::RDoc.new.document(args)
        end
      end
      self
    end
481674
def _submit_task_with_template(self, task_ids):
        ''''''
        runtime = self.config
        runtime.update({
            'workdir': os.getcwd(),
            'cur_dir': os.getcwd(),  # for backward compatibility
            'verbosity': env.verbosity,
            'sig_mode': env.config.get('sig_mode', 'default'),
            'run_mode': env.config.get('run_mode', 'run'),
            'home_dir': os.path.expanduser('~')
        })
        if '_runtime' in env.sos_dict:
            runtime.update({
                x: env.sos_dict['_runtime'][x]
                for x in ('nodes', 'cores', 'workdir', 'mem', 'walltime')
                if x in env.sos_dict['_runtime']
            })
        if 'nodes' not in runtime:
            runtime['nodes'] = 1
        if 'cores' not in runtime:
            runtime['cores'] = 1

        # let us first prepare a task file
        job_text = ''
        for task_id in task_ids:
            runtime['task'] = task_id
            try:
                job_text += cfg_interpolate(self.job_template, runtime)
                job_text += '\n'
            except Exception as e:
                raise ValueError(
                    f'Failed to generate job file for task {task_id}: {e}')

        filename = task_ids[0] + ('.sh' if len(task_ids) == 1 else
                                  f'-{task_ids[-1]}.sh')
        # now we need to write a job file
        job_file = os.path.join(
            os.path.expanduser('~'), '.sos', 'tasks', filename)
        # do not translate newline under windows because the script will be executed
        # under linux/mac
        with open(job_file, 'w', newline='') as job:
            job.write(job_text)

        # then copy the job file to remote host if necessary
        self.agent.send_task_file(job_file)

        try:
            cmd = f'bash ~/.sos/tasks/{filename}'
            self.agent.run_command(cmd, wait_for_task=self.wait_for_task)
        except Exception as e:
            raise RuntimeError(f'Failed to submit task {task_ids}: {e}')
        return True
1032513
def load_parameter_file(file_path, name = ''):
    
    if not os.path.exists(file_path):
        raise ValueError("{} doest not exist".format(file_path))
    if os.path.isdir(file_path):
        return ParameterNode(name, directory_path = file_path)
    data = _load_yaml_file(file_path)
    return _parse_child(name, data, file_path)