Returns the design-time package for a specified process ID.
Returns the first match so does not support the same process in multiple packages.
Also, assumes the processId is not for an embedded subprocess.
483846
public static Package getProcessPackage(Long processId) {
        try {
            if (processId != null) {
                for (Package pkg : getPackageList()) {
                  if (pkg.containsProcess(processId))
                      return pkg;
                }
            }
            return Package.getDefaultPackage();
        }
        catch (CachingException ex) {
            logger.severeException(ex.getMessage(), ex);
            return null;
        }
    }
79119
def get_default_project_id():
  
  # Try getting default project id from gcloud. If it fails try config.json.
  try:
    proc = subprocess.Popen(['gcloud', 'config', 'list', '--format', 'value(core.project)'],
                            stdout=subprocess.PIPE)
    stdout, _ = proc.communicate()
    value = stdout.strip()
    if proc.poll() == 0 and value:
      if isinstance(value, six.string_types):
        return value
      else:
        # Hope it's a utf-8 string encoded in bytes. Otherwise an exception will
        # be thrown and config.json will be checked.
        return value.decode()
  except:
    pass

  config_file = os.path.join(get_config_dir(), 'config.json')
  if os.path.exists(config_file):
    with open(config_file) as f:
      config = json.loads(f.read())
      if 'project_id' in config and config['project_id']:
        return str(config['project_id'])

  if os.getenv('PROJECT_ID') is not None:
    return os.getenv('PROJECT_ID')
  return None
1171038
@VisibleForTesting
  static ProcessIdentifier getProcessIdentifier(String jvmName, Timestamp censusTimestamp) {
    String hostname;
    int pid;
    // jvmName should be something like '<pid>@<hostname>', at least in Oracle and OpenJdk JVMs
    int delimiterIndex = jvmName.indexOf('@');
    if (delimiterIndex < 1) {
      // Not the expected format, generate a random number.
      try {
        hostname = InetAddress.getLocalHost().getHostName();
      } catch (UnknownHostException e) {
        hostname = "localhost";
      }
      // Generate a random number as the PID.
      pid = new SecureRandom().nextInt();
    } else {
      hostname = jvmName.substring(delimiterIndex + 1, jvmName.length());
      try {
        pid = Integer.parseInt(jvmName.substring(0, delimiterIndex));
      } catch (NumberFormatException e) {
        // Generate a random number as the PID if format is unexpected.
        pid = new SecureRandom().nextInt();
      }
    }

    return ProcessIdentifier.newBuilder()
        .setHostName(hostname)
        .setPid(pid)
        .setStartTimestamp(MetricsProtoUtils.toTimestampProto(censusTimestamp))
        .build();
  }
1219675
def get_package_id_by_type(self, package_type):
        

        mask = "mask[id, name, description, isActive, type[keyName]]"
        package = self.get_package_by_type(package_type, mask)
        if package:
            return package['id']
        else:
            raise ValueError("No package found for type: " + package_type)
1301180
def get_process_mapping():
    
    try:
        output = subprocess.check_output([
            'ps', '-ww', '-o', 'pid=', '-o', 'ppid=', '-o', 'args=',
        ])
    except OSError as e:    # Python 2-compatible FileNotFoundError.
        if e.errno != errno.ENOENT:
            raise
        raise PsNotAvailable('ps not found')
    except subprocess.CalledProcessError as e:
        # `ps` can return 1 if the process list is completely empty.
        # (sarugaku/shellingham#15)
        if not e.output.strip():
            return {}
        raise
    if not isinstance(output, str):
        encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
        output = output.decode(encoding)
    processes = {}
    for line in output.split('\n'):
        try:
            pid, ppid, args = line.strip().split(None, 2)
            # XXX: This is not right, but we are really out of options.
            # ps does not offer a sane way to decode the argument display,
            # and this is "Good Enough" for obtaining shell names. Hopefully
            # people don't name their shell with a space, or have something
            # like "/usr/bin/xonsh is uber". (sarugaku/shellingham#14)
            args = tuple(a.strip() for a in args.split(' '))
        except ValueError:
            continue
        processes[pid] = Process(args=args, pid=pid, ppid=ppid)
    return processes
1190348
def get_processor(self, entity_id, sp_config):
        
        processor_string = sp_config.get('processor', None)
        if processor_string:
            try:
                return import_string(processor_string)(entity_id)
            except Exception as e:
                logger.error("Failed to instantiate processor: {} - {}".format(processor_string, e), exc_info=True)
                raise
        return BaseProcessor(entity_id)
830880
def get_software_package_compilation_timestamp(cls,calc,**kwargs):
        
        from dateutil.parser import parse
        try:
            date = calc.out.job_info.get_dict()['compiled']
            return parse(date.replace('_', ' ')).isoformat()
        except Exception:
            return None
1195820
protected synchronized void compareReply(List<Long> processIds) {
        Object[] replyIds = replyProcessIds.toArray();
        for (Object replyId : replyIds) {
            if (processIds.contains((Long) replyId) == false) { // 判断reply id是否在当前processId列表中
                // 因为存在并发问题，如在执行Listener事件的同时，可能触发了process的创建，这时新建的processId会进入到reply队列中
                // 此时接受到的processIds变量为上一个版本的内容，所以会删除新建的process，导致整个通道被挂住
                if (CollectionUtils.isEmpty(processIds) == false) {
                    Long processId = processIds.get(0);
                    if (processId > (Long) replyId) { // 如果当前最小的processId都大于replyId, processId都是递增创建的
                        logger.info("## {} remove reply id [{}]", ClassUtils.getShortClassName(this.getClass()),
                                    (Long) replyId);
                        replyProcessIds.remove((Long) replyId);
                    }
                }
            }
        }
    }
547307
function checkProjectCompilationsWithId(projectId) {
	return fetchProject(projectId)
	.then((project) => {
		return checkProjectCompilations(project);
	})
	.catch((error) => {
		console.trace(error);
		throw error;
	});
}
54753
def get_process_pid(process_name):
    
    try:
        pid_filename = get_pid_filename(process_name)
        with open(pid_filename, mode='r') as pid_file:
            pid = int(pid_file.read().strip())
    except IOError:
        pid = None
    return pid
961977
protected synchronized void compareReply(List<Long> processIds) {
        Object[] replyIds = replyProcessIds.toArray();
        for (Object replyId : replyIds) {
            if (processIds.contains((Long) replyId) == false) { // 判断reply id是否在当前processId列表中
                // 因为存在并发问题，如在执行Listener事件的同时，可能触发了process的创建，这时新建的processId会进入到reply队列中
                // 此时接受到的processIds变量为上一个版本的内容，所以会删除新建的process，导致整个通道被挂住
                if (CollectionUtils.isEmpty(processIds) == false) {
                    Long processId = processIds.get(0);
                    if (processId > (Long) replyId) { // 如果当前最小的processId都大于replyId, processId都是递增创建的
                        processTermined((Long) replyId); // 调用一下删除操作
                    }
                }
            }
        }
    }
159748
public ProcessInstance getProcessInstance() {
    Execution execution = getExecution();
    if(execution != null && !(execution.getProcessInstanceId().equals(execution.getId()))){
      return processEngine
            .getRuntimeService()
            .createProcessInstanceQuery()
            .processInstanceId(execution.getProcessInstanceId())
            .singleResult();
    }
    return (ProcessInstance) execution;
  }
771976
function getPPID () {
  const ppid = process.ppid

  if (typeof ppid === 'number') {
    return Promise.resolve(ppid)
  }

  return find('pid', process.pid)
    .then(list => {
      return list && list[0] && list[0].ppid
    })
}
1292993
def get_process_info(self, pid=None):
        '''
        

        '''

        pid = self._get_pid(pid)
        return self._call_rest_api('get', '/processes/'+pid, error='Failed to fetch process information')
910806
def find(self, package, **kwargs):
        
        spec = find_spec(package)
        if spec is None:
            return None
        limit = []
        if '.' in package:
            package, limit = package.split('.', 1)
            limit = [limit]
            spec = find_spec(package)
        if spec is not None:
            if spec.submodule_search_locations:
                path = spec.submodule_search_locations[0]
            elif spec.origin and spec.origin != 'built-in':
                path = spec.origin
            else:
                return None
            return PackageSpec(spec.name, path, limit)
        return None
714811
protected ProcessDefinition findProcessDefinition(String processDefinitionKey, String tenantId) {
    if (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) {
      return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKey(processDefinitionKey);
    } else {
      return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, tenantId);
    }
  }
896662
def find_workflow_path(self):
        
        for pth in settings.WORKFLOW_PACKAGES_PATHS:
            path = "%s/%s.bpmn" % (pth, self.current.workflow_name)
            if os.path.exists(path):
                return path
        err_msg = "BPMN file cannot found: %s" % self.current.workflow_name
        log.error(err_msg)
        raise RuntimeError(err_msg)