Exemple #1
0
    def __init__(self, fromDict=None):
        """c'tor

    :param self: self reference
    :param dict fromDict: data dict
    """
        Record.__init__(self)
        now = datetime.datetime.utcnow().replace(microsecond=0)
        self.__data__["CreationTime"] = now
        self.__data__["SubmitTime"] = now
        self.__data__["LastUpdate"] = now
        self.__data__["Status"] = "Submitted"
        self.__data__["Completeness"] = 0
        self.__data__["FTSJobID"] = 0
        self.__files__ = TypedList(allowedTypes=FTSFile)

        self._log = gLogger.getSubLogger("FTSJob-%s" % self.FTSJobID, True)

        fromDict = fromDict if fromDict else {}
        for ftsFileDict in fromDict.get("FTSFiles", []):
            self += FTSFile(ftsFileDict)
        if "FTSFiles" in fromDict: del fromDict["FTSFiles"]
        for key, value in fromDict.items():
            if key not in self.__data__:
                raise AttributeError("Unknown FTSJob attribute '%s'" % key)
            if value:
                setattr(self, key, value)
Exemple #2
0
    def test01ctor(self):
        """ c'tor test """
        NumericList = TypedList(allowedTypes=self.numericTypes)
        FloatList = TypedList(allowedTypes=self.floatType)
        TestClassList = TypedList(allowedTypes=self.testClassType)

        self.assertEqual(isinstance(NumericList, TypedList), True)
        self.assertEqual(isinstance(FloatList, TypedList), True)
        self.assertEqual(isinstance(TestClassList, TypedList), True)

        self.assertEqual(NumericList.allowedTypes() == self.numericTypes, True)
        self.assertEqual(FloatList.allowedTypes() == self.floatType, True)
        self.assertEqual(TestClassList.allowedTypes() == self.testClassType,
                         True)

        self.assertRaises(TypeError, TypedList.__init__, (),
                          {"allowedTypes": (1, 2, 3)})
Exemple #3
0
    def test02_add_iadd_radd(self):
        """ += +lvalue +rvalue """
        NumericList = TypedList((1, 1.0, 1), self.numericTypes)
        ## +=
        NumericList += [2, 2.0, 2]
        self.assertEqual(len(NumericList), 6)
        self.assertEqual(NumericList, [1, 1.0, 1, 2, 2.0, 2])
        ## +lvalue
        lList = NumericList + [3, 3.0, 3]
        self.assertEqual(len(lList), 9)
        self.assertEqual(lList, [1, 1.0, 1, 2, 2.0, 2, 3, 3.0, 3])

        ## rvalue+
        rList = [0, 0.0, 0] + NumericList
        self.assertEqual(len(rList), 9)
        self.assertEqual(rList, [0, 0.0, 0, 1, 1.0, 1, 2, 2.0, 2])
Exemple #4
0
  def __init__( self, fromDict = None ):
    """c'tor

    :param self: self reference
    """
    Record.__init__( self )
    self.__waiting = None

    now = datetime.datetime.utcnow().replace( microsecond = 0 )
    self.__data__["CreationTime"] = now
    self.__data__["SubmitTime"] = now
    self.__data__["LastUpdate"] = now
    self.__data__["Status"] = "Done"
    self.__data__["JobID"] = 0
    self.__data__["RequestID"] = 0

    proxyInfo = getProxyInfo()
    if proxyInfo["OK"]:
      proxyInfo = proxyInfo["Value"]
      if proxyInfo["validGroup"] and proxyInfo["validDN"]:
        self.OwnerDN = proxyInfo["identity"]
        self.OwnerGroup = proxyInfo["group"]

    self.__dirty = []
    self.__operations__ = TypedList( allowedTypes = Operation )

    fromDict = fromDict if fromDict else {}

    self.__dirty = fromDict.get( "__dirty", [] )
    if "__dirty" in fromDict:
      del fromDict["__dirty"]

    for opDict in fromDict.get( "Operations", [] ):
      self +=Operation( opDict )
    if "Operations" in fromDict:
      del fromDict["Operations"]

    for key, value in fromDict.items():
      if key not in self.__data__:
        raise AttributeError( "Unknown Request attribute '%s'" % key )
      if value:
        setattr( self, key, value )
    self._notify()
Exemple #5
0
    def __init__(self, fromDict=None):
        """ c'tor

    :param self: self reference
    :param dict fromDict: attributes dictionary
    """
        Record.__init__(self)
        self._parent = None
        # # sub-request attributes
        # self.__data__ = dict.fromkeys( self.tableDesc()["Fields"].keys(), None )
        now = datetime.datetime.utcnow().replace(microsecond=0)
        self.__data__["SubmitTime"] = now
        self.__data__["LastUpdate"] = now
        self.__data__["CreationTime"] = now
        self.__data__["OperationID"] = 0
        self.__data__["RequestID"] = 0
        self.__data__["Status"] = "Queued"

        # # operation files
        self.__files__ = TypedList(allowedTypes=File)
        # # dirty fileIDs
        self.__dirty = []

        # # init from dict
        fromDict = fromDict if fromDict else {}

        self.__dirty = fromDict.get("__dirty", [])
        if "__dirty" in fromDict:
            del fromDict["__dirty"]

        for fileDict in fromDict.get("Files", []):
            self.addFile(File(fileDict))
        if "Files" in fromDict:
            del fromDict["Files"]

        for key, value in fromDict.items():
            if key not in self.__data__:
                raise AttributeError("Unknown Operation attribute '%s'" % key)
            if key != "Order" and value:
                setattr(self, key, value)
Exemple #6
0
    def __init__(self, fromDict=None):
        """c'tor

    :param self: self reference
    :param dict fromDict: data dict
    """
        self.__data__ = dict.fromkeys(self.tableDesc()["Fields"].keys(), None)

        now = datetime.datetime.utcnow().replace(microsecond=0)
        self.__data__["CreationTime"] = now
        self.__data__["SubmitTime"] = now
        self.__data__["LastUpdate"] = now
        self.__data__["Status"] = "Submitted"
        self.__data__["Completeness"] = 0
        self.__data__["FTSJobID"] = 0
        self._regTime = 0.
        self._regSuccess = 0
        self._regTotal = 0
        self.__files__ = TypedList(allowedTypes=FTSFile)

        self._fc = FileCatalog()
        self._fts3context = None

        self._states = tuple(
            set(self.INITSTATES + self.TRANSSTATES + self.FAILEDSTATES +
                self.FINALSTATES))

        fromDict = fromDict if fromDict else {}
        for ftsFileDict in fromDict.get("FTSFiles", []):
            self += FTSFile(ftsFileDict)
        if "FTSFiles" in fromDict:
            del fromDict["FTSFiles"]
        for key, value in fromDict.items():
            if key not in self.__data__:
                raise AttributeError("Unknown FTSJob attribute '%s'" % key)
            if value:
                setattr(self, key, value)
        self._log = gLogger.getSubLogger(
            "req_%s/FTSJob-%s" % (self.RequestID, self.FTSGUID), True)