コード例 #1
0
def testMakeGuid():
    """ makeGuid tests """
    # no filename - fake guid produced
    assert checkGuid(makeGuid()) is True, "fake guid for inexisting file"
    # using this python file
    assert checkGuid(makeGuid(
        abspath(__file__))) is True, "guid for FileTestCase.py file"
コード例 #2
0
 def testMakeGuid(self):
     """ makeGuid tests """
     # no filename - fake guid produced
     self.assertEqual(checkGuid(makeGuid()), True,
                      "fake guid for inexisting file")
     # using this python file
     self.assertEqual(checkGuid(makeGuid(os.path.abspath(__file__))), True,
                      "guid for FileTestCase.py file")
コード例 #3
0
ファイル: Test_File.py プロジェクト: DIRACGrid/DIRAC
 def testMakeGuid(self):
   """ makeGuid tests """
   # no filename - fake guid produced
   self.assertEqual(checkGuid(makeGuid()), True, "fake guid for inexisting file")
   # using this python file
   self.assertEqual(
       checkGuid(
           makeGuid(
               os.path.abspath(__file__))),
       True,
       "guid for FileTestCase.py file")
コード例 #4
0
ファイル: FTSRequest.py プロジェクト: sbel/bes3-jinr
  def __submitFTSTransfer( self ):
    """ create and execute glite-transfer-submit CLI command

    :param self: self reference
    """
    comm = [ 'glite-transfer-submit', '-s', self.ftsServer, '-f', self.surlFile, '-o' ]
    if self.targetToken:
      comm += [ '-t', self.targetToken ]
    if self.sourceToken:
      comm += [ '-S', self.sourceToken ]
    if self.__cksmTest:
      comm.append( "--compare-checksums" )
    gLogger.verbose( 'Executing %s' % ' '.join( comm ) )
    res = executeGridCommand( '', comm )
    os.remove( self.surlFile )
    if not res['OK']:
      return res
    returnCode, output, errStr = res['Value']
    if not returnCode == 0:
      return S_ERROR( errStr )
    guid = output.replace( '\n', '' )
    if not checkGuid( guid ):
      return S_ERROR( 'Wrong GUID format returned' )
    self.ftsGUID = guid
    # if self.priority != 3:
    #  comm = ['glite-transfer-setpriority','-s', self.ftsServer,self.ftsGUID,str(self.priority)]
    #  executeGridCommand('',comm)
    return res
コード例 #5
0
    def __submitFTSTransfer(self):
        """ create and execute glite-transfer-submit CLI command 

    :param self: self reference
    """
        comm = [
            'glite-transfer-submit', '-s', self.ftsServer, '-f', self.surlFile,
            '-o'
        ]
        if self.targetToken:
            comm.append('-t')
            comm.append(self.targetToken)
        if self.sourceToken:
            comm.append('-S')
            comm.append(self.sourceToken)
        if self.__cksmTest:
            comm.append("--compare-checksums")
        res = executeGridCommand('', comm)
        os.remove(self.surlFile)
        if not res['OK']:
            return res
        returnCode, output, errStr = res['Value']
        if not returnCode == 0:
            return S_ERROR(errStr)
        guid = output.replace('\n', '')
        if not checkGuid(guid):
            return S_ERROR('Wrong GUID format returned')
        self.ftsGUID = guid
        #if self.priority != 3:
        #  comm = ['glite-transfer-setpriority','-s', self.ftsServer,self.ftsGUID,str(self.priority)]
        #  executeGridCommand('',comm)
        return res
コード例 #6
0
 def __submitFTSTransfer(self):
     comm = [
         'glite-transfer-submit', '-s', self.ftsServer, '-f', self.surlFile,
         '-o'
     ]
     if self.targetToken:
         comm.append('-t')
         comm.append(self.targetToken)
     if self.sourceToken:
         comm.append('-S')
         comm.append(self.sourceToken)
     res = executeGridCommand('', comm, self.gridEnv)
     os.remove(self.surlFile)
     if not res['OK']:
         return res
     returnCode, output, errStr = res['Value']
     if not returnCode == 0:
         return S_ERROR(errStr)
     guid = output.replace('\n', '')
     if not checkGuid(guid):
         return S_ERROR('Wrong GUID format returned')
     self.ftsGUID = guid
     #if self.priority != 3:
     #  comm = ['glite-transfer-setpriority','-s', self.ftsServer,self.ftsGUID,str(self.priority)]
     #  executeGridCommand('',comm,self.gridEnv)
     return res
コード例 #7
0
ファイル: File.py プロジェクト: Eo300/DIRAC
 def GUID(self, value):
     """ GUID setter """
     if value:
         if type(value) not in StringTypes:
             raise TypeError("GUID should be a string!")
         if not checkGuid(value):
             raise ValueError("'%s' is not a valid GUID!" % str(value))
     self._GUID = value
コード例 #8
0
ファイル: File.py プロジェクト: DIRACGrid-test/DIRAC
 def GUID( self, value ):
   """ GUID setter """
   if value:
     if type( value ) not in StringTypes:
       raise TypeError( "GUID should be a string!" )
     if not checkGuid( value ):
       raise ValueError( "'%s' is not a valid GUID!" % str( value ) )
   self._GUID = value
コード例 #9
0
 def GUID(self, value):
   """ GUID setter """
   if value:
     if not isinstance(value, six.string_types):
       raise TypeError("GUID should be a string!")
     if not checkGuid(value):
       raise ValueError("'%s' is not a valid GUID!" % str(value))
   self._GUID = value
コード例 #10
0
ファイル: File.py プロジェクト: Teddy22/DIRAC
 def GUID( self, value ):
   """ GUID setter """
   if value:
     if type( value ) not in ( str, unicode ):
       raise TypeError( "GUID should be a string!" )
     if not checkGuid( value ):
       raise ValueError( "'%s' is not a valid GUID!" % str( value ) )
   self.__data__["GUID"] = value
コード例 #11
0
ファイル: File.py プロジェクト: sposs/DIRAC
 def GUID(self, value):
     """ GUID setter """
     if value:
         if type(value) not in (str, unicode):
             raise TypeError("GUID should be a string!")
         if not checkGuid(value):
             raise ValueError("'%s' is not a valid GUID!" % str(value))
     self.__data__["GUID"] = value
コード例 #12
0
ファイル: FTSRequest.py プロジェクト: Teddy22/DIRAC
  def setFTSGUID( self, guid ):
    """ FTS job GUID setter

    :param self: self reference
    :param str guid: string containg GUID
    """
    if not checkGuid( guid ):
      return S_ERROR( "Incorrect GUID format" )
    self.ftsGUID = guid
    return S_OK()
コード例 #13
0
ファイル: FTSRequest.py プロジェクト: vingar/DIRAC
  def setFTSGUID( self, guid ):
    """ FTS job GUID setter

    :param self: self reference
    :param str guid: string containg GUID
    """
    if not checkGuid( guid ):
      return S_ERROR( "Incorrect GUID format" )
    self.ftsGUID = guid
    return S_OK()
コード例 #14
0
ファイル: FTSRequest.py プロジェクト: caitriana/DIRAC
 def __submitFTSTransfer( self ):
   comm = ['glite-transfer-submit', '-s', self.ftsServer, '-f', self.surlFile, '-o']
   if self.targetToken:
     comm.append( '-t' )
     comm.append( self.targetToken )
   if self.sourceToken:
     comm.append( '-S' )
     comm.append( self.sourceToken )
   res = executeGridCommand( '', comm, self.gridEnv )
   os.remove( self.surlFile )
   if not res['OK']:
     return res
   returnCode, output, errStr = res['Value']
   if not returnCode == 0:
     return S_ERROR( errStr )
   guid = output.replace( '\n', '' )
   if not checkGuid( guid ):
     return S_ERROR( 'Wrong GUID format returned' )
   self.ftsGUID = guid
   #if self.priority != 3:
   #  comm = ['glite-transfer-setpriority','-s', self.ftsServer,self.ftsGUID,str(self.priority)]
   #  executeGridCommand('',comm,self.gridEnv)
   return res
コード例 #15
0
 def setFTSGUID(self, guid):
     if not checkGuid(guid):
         return S_ERROR("Incorrect GUID format")
     self.ftsGUID = guid
     return S_OK()
コード例 #16
0
ファイル: Test_File.py プロジェクト: atsareg/DIRAC
  def testCheckGuid( self ):
    """ checkGuid tests """
    # empty string
    guid = ""
    self.assertEqual( checkGuid( guid ), False, "empty guid" )

    # wrong lenght in a 1st field
    guid = '012345678-0123-0123-0123-0123456789AB'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 1st field' )
    guid = '0123456-0123-0123-0123-0123456789AB'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 1st field')

    # wrong lenght in a 2nd field
    guid = '01234567-01234-0123-0123-0123456789AB'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 2nd field' )
    guid = '01234567-012-0123-0123-0123456789AB'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 2nd field' )

    # wrong lenght in a 3rd field
    guid = '01234567-0123-01234-0123-0123456789AB'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 3rd field' )
    guid = '01234567-0123-012-0123-0123456789AB'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 3rd field')

    # wrong lenght in a 4th field
    guid = '01234567-0123-0123-01234-0123456789AB'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 4th field' )
    guid = '01234567-0123-0123-012-0123456789AB'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 4th field' )

    # wrong lenght in a 5th field
    guid = '01234567-0123-0123-0123-0123-0123456789ABC'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 5th field' )
    guid = '01234567-0123-0123-0123-0123-0123456789A'
    self.assertEqual( checkGuid( guid ), False, 'wrong lenght in 5th field' )

    # small caps
    guid = '01234567-9ABC-0DEF-0123-456789ABCDEF'.lower()
    self.assertEqual( checkGuid( guid ), True, "small caps in guid, zut!" )

    # wrong characters not in [0-9A-F]
    guid = 'NEEDMORE-SPAM-SPAM-SPAM-SPAMWITHEGGS'
    self.assertEqual( checkGuid( guid ), True, "wrong set of characters, zut!" )

    # normal operation
    guid = '01234567-9ABC-0DEF-0123-456789ABCDEF'
    self.assertEqual( checkGuid( guid ), True, "proper GUID" )
コード例 #17
0
def testCheckGuid():
    """checkGuid tests"""
    # empty string
    guid = ""
    assert checkGuid(guid) is False, "empty guid"

    # wrong length in a 1st field
    guid = "012345678-0123-0123-0123-0123456789AB"
    assert checkGuid(guid) is False, "wrong length in 1st field"
    guid = "0123456-0123-0123-0123-0123456789AB"
    assert checkGuid(guid) is False, "wrong length in 1st field"

    # wrong length in a 2nd field
    guid = "01234567-01234-0123-0123-0123456789AB"
    assert checkGuid(guid) is False, "wrong length in 2nd field"
    guid = "01234567-012-0123-0123-0123456789AB"
    assert checkGuid(guid) is False, "wrong length in 2nd field"

    # wrong length in a 3rd field
    guid = "01234567-0123-01234-0123-0123456789AB"
    assert checkGuid(guid) is False, "wrong length in 3rd field"
    guid = "01234567-0123-012-0123-0123456789AB"
    assert checkGuid(guid) is False, "wrong length in 3rd field"

    # wrong length in a 4th field
    guid = "01234567-0123-0123-01234-0123456789AB"
    assert checkGuid(guid) is False, "wrong length in 4th field"
    guid = "01234567-0123-0123-012-0123456789AB"
    assert checkGuid(guid) is False, "wrong length in 4th field"

    # wrong length in a 5th field
    guid = "01234567-0123-0123-0123-0123-0123456789ABC"
    assert checkGuid(guid) is False, "wrong length in 5th field"
    guid = "01234567-0123-0123-0123-0123-0123456789A"
    assert checkGuid(guid) is False, "wrong length in 5th field"

    # small caps
    guid = "01234567-9ABC-0DEF-0123-456789ABCDEF".lower()
    assert checkGuid(guid) is True, "small caps in guid, zut!"

    # wrong characters not in [0-9A-F]
    guid = "NEEDMORE-SPAM-SPAM-SPAM-SPAMWITHEGGS"
    assert checkGuid(guid) is True, "wrong set of characters, zut!"

    # normal operation
    guid = "01234567-9ABC-0DEF-0123-456789ABCDEF"
    assert checkGuid(guid) is True, "proper GUID"
コード例 #18
0
ファイル: FTSRequest.py プロジェクト: caitriana/DIRAC
 def setFTSGUID( self, guid ):
   if not checkGuid( guid ):
     return S_ERROR( "Incorrect GUID format" )
   self.ftsGUID = guid
   return S_OK()