Ejemplo n.º 1
0
class LmServerEnv(LmEnv):
   """
   @summary: LmEnv subclass that relies on the Lifemapper core code and the 
                scribe to determine what values to replace strings with
   """
   # .......................
   def __init__(self, server=WEBSERVICES_ROOT, userId=None):
      self.log = LmServerLogger("serverEnv")
      self.scribe = Scribe(self.log)
      self.scribe.openConnections()
      self.values = {
         "#SERVER#" : server,
      }
      self._getSdmValues()
      if userId is not None:
         self._getSdmValues(userId=userId)
         self._getRadValues(userId)
   
   # .......................
   def getReplacementValue(self, valKey):
      """
      @summary: Get the replacement value for the key
      @param valKey: The key to get the value of
      """
      return self.values[valKey]
   
   # .......................
   def _getSdmValues(self, userId=ARCHIVE_USER):
      if userId == ARCHIVE_USER:
         prefix = "PUB"
         forUser = "******"
      else:
         prefix = "USR"
         forUser = "******"
         
      try:
         self.values['#%s_SDM_EXP_ID#' % prefix] = str(
               self.scribe.listModels(0, 1, userId=userId, 
                                              status=JobStatus.COMPLETE)[0].id)
      except Exception, e:
         self.log.debug(
                    "Could not populate %s SDM experiment id: %s" % (forUser, 
                                                                     str(e)))

      try:
         self.values['#%s_SDM_LYR_ID#' % prefix] = str(
               self.scribe.listLayers(0, 1, userId=userId)[0].id)
      except Exception, e:
         self.log.debug("Could not populate %s SDM layer id: %s" % (forUser, 
                                                                    str(e)))
Ejemplo n.º 2
0
 def __init__(self, server=WEBSERVICES_ROOT, userId=None):
    self.log = LmServerLogger("serverEnv")
    self.scribe = Scribe(self.log)
    self.scribe.openConnections()
    self.values = {
       "#SERVER#" : server,
    }
    self._getSdmValues()
    if userId is not None:
       self._getSdmValues(userId=userId)
       self._getRadValues(userId)