Resolve PID from a value and return a tuple with PID and the record.

        :returns: A tuple with the PID and the record resolved.
190323
def data(self):
        
        try:
            return self.resolver.resolve(self.value)
        except PIDDoesNotExistError as pid_error:
            raise PIDDoesNotExistRESTError(pid_error=pid_error)
        except PIDUnregistered as pid_error:
            raise PIDUnregisteredRESTError(pid_error=pid_error)
        except PIDDeletedError as pid_error:
            raise PIDDeletedRESTError(pid_error=pid_error)
        except PIDMissingObjectError as pid_error:
            current_app.logger.exception(
                'No object assigned to {0}.'.format(pid_error.pid),
                extra={'pid': pid_error.pid})
            raise PIDMissingObjectRESTError(pid_error.pid, pid_error=pid_error)
        except PIDRedirectedError as pid_error:
            try:
                location = url_for(
                    '.{0}_item'.format(
                        current_records_rest.default_endpoint_prefixes[
                            pid_error.destination_pid.pid_type]),
                    pid_value=pid_error.destination_pid.pid_value)
                data = dict(
                    status=301,
                    message='Moved Permanently',
                    location=location,
                )
                response = make_response(jsonify(data), data['status'])
                response.headers['Location'] = location
                abort(response)
            except (BuildError, KeyError):
                current_app.logger.exception(
                    'Invalid redirect - pid_type "{0}" '
                    'endpoint missing.'.format(
                        pid_error.destination_pid.pid_type),
                    extra={
                        'pid': pid_error.pid,
                        'destination_pid': pid_error.destination_pid,
                    })
                raise PIDRedirectedRESTError(
                    pid_error.destination_pid.pid_type, pid_error=pid_error)
1222029
def position_p(self):
        
        self._position_p, value = self.get_attr_int(self._position_p, 'hold_pid/Kp')
        return value
286729
def _pid_to_id(self, pid):
        """"""
        return d1_common.url.joinPathElements(
            self._base_url,
            self._version_tag,
            "resolve",
            d1_common.url.encodePathElement(pid),
        )
596820
def _clean_pid(self, pid):
        
        if isinstance(pid, (list, tuple)):
            if len(pid) == 1:
                return pid[0]
            else:
                return pid
        return pid
875807
def _connected_pids(self, from_parent=True):
        
        to_pid = aliased(PersistentIdentifier, name='to_pid')
        if from_parent:
            to_relation = PIDRelation.child_id
            from_relation = PIDRelation.parent_id
        else:
            to_relation = PIDRelation.parent_id
            from_relation = PIDRelation.child_id
        query = PIDQuery(
            [to_pid], db.session(), _filtered_pid_class=to_pid
        ).join(
            PIDRelation,
            to_pid.id == to_relation
        )
        # accept both PersistentIdentifier models and fake PIDs with just
        # pid_value, pid_type as they are fetched with the PID fetcher.
        if isinstance(self.pid, PersistentIdentifier):
            query = query.filter(from_relation == self.pid.id)
        else:
            from_pid = aliased(PersistentIdentifier, name='from_pid')
            query = query.join(
                from_pid,
                from_pid.id == from_relation
            ).filter(
                from_pid.pid_value == self.pid.pid_value,
                from_pid.pid_type == self.pid.pid_type,
            )

        return query
910956
def init_pid(self, kp, ki, kd):
        """"""
        p, i, d = map(lambda x: int(x * (2 ** 16)), (kp, ki, kd))
        self._set_as_int(Addr.PConstant, p, 4)
        self._set_as_int(Addr.IConstant, i, 4)
        self._set_as_int(Addr.DConstant, d, 4)
994415
def getPID(self):
        
        if self._pid is not None:
            if not PlatformManager.isPIDValid(self._pid):
                self._pid = -1
            return self._pid
        return -1
754641
def read_pid(self):
        
        try:
            with open(self._path, 'r') as f:
                s = f.read().strip()
                if not s:
                    return None
                return int(s)
        except IOError as e:
            if e.errno == errno.ENOENT:
                return None
            raise
134114
def pid_from_file
      if File.exist?(pid_file_path)
        pid = File.read(pid_file_path)
        pid.length > 0 ? pid.strip.to_i : nil
      else
        nil
      end
    end
655524
def to_python(self, value=None):
        

        if value is None:
            return self.default

        if self.resolve:
            return self.resolve(value)
        return value
177478
def resolve_sid(sid):
    
    return d1_gmn.app.models.Chain.objects.get(sid__did=sid).head_pid.did
1201762
def process_get(self, pid):
        
        if not isinstance(pid, baseinteger):
            raise TypeError("pid can only be an instance of type baseinteger")
        guest_process = self._call("processGet",
                     in_p=[pid])
        guest_process = IGuestProcess(guest_process)
        return guest_process
236805
def get_pid(name):
    """"""
    if not shutil.which("pidof"):
        return False

    try:
        subprocess.check_output(["pidof", "-s", name])
    except subprocess.CalledProcessError:
        return False

    return True
658252
def _get_child_relation(self, child_pid):
        """"""
        return PIDRelation.query.filter_by(
            parent=self._resolved_pid,
            child=child_pid,
            relation_type=self.relation_type.id).one()
912396
def resolve_ids(identifier, resolvers):
    

    # Before doing anything, let's see if this is an integer
    try:
        return [int(identifier)]
    except ValueError:
        pass  # It was worth a shot

    # This looks like a globalIdentifier (UUID)
    if len(identifier) == 36 and UUID_RE.match(identifier):
        return [identifier]

    for resolver in resolvers:
        ids = resolver(identifier)
        if ids:
            return ids

    return []
1004226
def resolve(self, pid):
        """"""
        client = d1_cli.impl.client.CLICNClient(
            **self._cn_client_connect_params_from_session()
        )
        object_location_list_pyxb = client.resolve(pid)
        for location in object_location_list_pyxb.objectLocation:
            d1_cli.impl.util.print_info(location.url)
835035
def _get_chain_by_pid(pid):
    
    try:
        return d1_gmn.app.models.ChainMember.objects.get(pid__did=pid).chain
    except d1_gmn.app.models.ChainMember.DoesNotExist:
        pass