Exemple #1
0
    def __store(self, statusDict, derive=False):
        """Store a dictionary of status alias/values into the staus system.
        If (derive)==True, then any derived status values that depend on
        these values will be recomputed (default is True).
        """

        with self._lock:
            mon_d = {}

            # Store status items
            self.logger.debug("Stored: %s" % str(statusDict))
            self.g2status.update(statusDict)

            if common.mon_transmit:
                mon_d.update(common.ro_sanitize(statusDict, pfx='mon.status.'))

            if derive:
                # Compute derived aliases linked to aliases sent.
                d = self.derive.aliasesToDerivedAliasesDict(
                    statusDict.keys(), None)
                if d:
                    self.derive.derive(d)
                    self.logger.debug("Derived: %s" % str(d))
                    self.g2status.update(d)

                    if common.mon_transmit:
                        mon_d.update(common.ro_sanitize(d, pfx='mon.status.'))

            if common.mon_transmit:
                # Update status seen through the monitor
                self.monitor.store(mon_d, ['status'])
Exemple #2
0
    def set_statusValuesDict(self, statusDict):

        if common.ro_long_fix:
            valDict = common.ro_sanitize(statusDict)
        else:
            valDict = statusDict

        try:
            self.statusObj.store(valDict)

        except ro.remoteObjectError, e:
            raise common.statusError(str(e))
Exemple #3
0
    def fetch(self, statusDict):
        """Fetch all aliases specified by the keys of statusDict.
        Returns a dict with all the key/value pairs.
        """

        d = self.__fetch(statusDict, derive=False, allow_none=False)

        # Sanitize for return trip over remoteObjects, if necessary
        if common.ro_long_fix:
            d = common.ro_sanitize(d)

        self.logger.debug("Fetched: %s" % (str(d)))
        return d
Exemple #4
0
    def monxmit(self, fetchDict):

        self.__fetch(fetchDict, derive=False, allow_none=False)

        # Get current status set
        mon_d = {}
        with self._lock:
            mon_d.update(common.ro_sanitize(fetchDict, pfx=None))

        try:
            # Update status seen through the monitor
            self.monitor.update('mon.status', mon_d, ['status'])

        except Exception, e:
            self.logger.error("Error transmitting status: %s" % str(e))
Exemple #5
0
    def fetchOne(self, alias):
        """Fetch exactly one alias value.
        """

        d = self.__fetch({ alias: common.STATNONE },
                         derive=False, allow_none=False)

        # Sanitize for return trip over remoteObjects, if necessary
        if common.ro_long_fix:
            d = common.ro_sanitize(d)

        val = d[alias]
        
        self.logger.debug("Fetched: %s=%s" % (alias, str(val)))
        return val