Example #1
0
    def locateFiles(self,
                    cacheFolder=None,
                    additionalSourceLocations=None,
                    progressReporter=None):
        '''Find the actual files, and figure out what subclass of action is appropriate'''

        kwargs = self.kwargs

        # -- get a local path for the container

        # progressReporter
        if progressReporter is True:
            progressReporter = displayTools.statusHandler(
                taskMessage='Searching for ' + nameOrLocation)
        elif progressReporter is False:
            progressReporter = None

        localSourceLocation = cacheController.findItem(
            self.sourceLocation, self.checksumType, self.checksumValue,
            self.displayName, additionalSourceLocations, progressReporter)

        # -- find the container subtype, and instantiate it
        self.container = self.findItemForParentClass(
            containerBase.containerBase, localSourceLocation, **kwargs)

        # -- find the action subtype
        self.container.prepareForUse()  # open things up so we can work faster
        self.action = self.findItemForParentClass(actionBase.actionBase,
                                                  self.container, **kwargs)
        self.container.cleanupAfterUse()
Example #2
0
	def findItem(self, additionalSourceFolders=None, progressReporter=True):
		
		# progressReporter
		if progressReporter is True:
			progressReporter = displayTools.statusHandler(taskMessage='Searching for ' + nameOrLocation)
		elif progressReporter is False:
			progressReporter = None
		
		self.filePath = cacheController.findItem(self.source, self.checksumType, self.checksumValue, self.displayName, additionalSourceFolders, progressReporter)
Example #3
0
	def test_findItem(self):
		'''Test out both local files and downloads with the findItem method'''
		
		# perform all of the the local file tests
		for thisTest in self.testMaterials:
			
			result = None
			try:
				result = cacheController.findItem(nameOrLocation=thisTest['fileName'], checksumType=thisTest['checksumType'], checksumValue=thisTest['checksumValue'], displayName=None, additionalSourceFolders=None, progressReporter=None)
			except FileNotFoundException, error:
				self.fail(thisTest['errorMessage'] + ', was unable to find a package - ' + str(error))
			
			self.assertEqual(thisTest['filePath'], result, thisTest['errorMessage'] + ', should have been "%s" but was: %s' % (thisTest['filePath'], result))
Example #4
0
	def locateFiles(self, cacheFolder=None, additionalSourceLocations=None, progressReporter=None):
		'''Find the actual files, and figure out what subclass of action is appropriate'''
		
		kwargs = self.kwargs
		
		# -- get a local path for the container
		
		# progressReporter
		if progressReporter is True:
			progressReporter = displayTools.statusHandler(taskMessage='Searching for ' + nameOrLocation)
		elif progressReporter is False:
			progressReporter = None
		
		localSourceLocation = cacheController.findItem(self.sourceLocation, self.checksumType, self.checksumValue, self.displayName, additionalSourceLocations, progressReporter)
		
		# -- find the container subtype, and instantiate it
		self.container = self.findItemForParentClass(containerBase.containerBase, localSourceLocation, **kwargs)
		
		# -- find the action subtype
		self.container.prepareForUse() # open things up so we can work faster
		self.action = self.findItemForParentClass(actionBase.actionBase, self.container, **kwargs)
		self.container.cleanupAfterUse()
Example #5
0
    def test_findItem(self):
        '''Test out both local files and downloads with the findItem method'''

        # perform all of the the local file tests
        for thisTest in self.testMaterials:

            result = None
            try:
                result = cacheController.findItem(
                    nameOrLocation=thisTest['fileName'],
                    checksumType=thisTest['checksumType'],
                    checksumValue=thisTest['checksumValue'],
                    displayName=None,
                    additionalSourceFolders=None,
                    progressReporter=None)
            except FileNotFoundException, error:
                self.fail(thisTest['errorMessage'] +
                          ', was unable to find a package - ' + str(error))

            self.assertEqual(
                thisTest['filePath'], result, thisTest['errorMessage'] +
                ', should have been "%s" but was: %s' %
                (thisTest['filePath'], result))
Example #6
0
class cacheControllerTests(cacheControllerTest):
    '''Test cases for cacheController once it has been set up'''
    def test_findItemInCaches(self):
        '''Test out the findItemInCaches method'''

        for thisTest in self.testMaterials:
            resultPath, waste = cacheController.findItemInCaches(
                thisTest['fileName'],
                thisTest['checksumType'],
                thisTest['checksumValue'],
                progressReporter=None)
            thisTest['resultPath'] = resultPath
            self.assertEqual(
                thisTest['filePath'], resultPath, thisTest['errorMessage'] +
                ', should have been "%(filePath)s" but was: %(resultPath)s' %
                thisTest)

    def test_findItem(self):
        '''Test out both local files and downloads with the findItem method'''

        # perform all of the the local file tests
        for thisTest in self.testMaterials:

            result = None
            try:
                result = cacheController.findItem(
                    nameOrLocation=thisTest['fileName'],
                    checksumType=thisTest['checksumType'],
                    checksumValue=thisTest['checksumValue'],
                    displayName=None,
                    additionalSourceFolders=None,
                    progressReporter=None)
            except FileNotFoundException, error:
                self.fail(thisTest['errorMessage'] +
                          ', was unable to find a package - ' + str(error))

            self.assertEqual(
                thisTest['filePath'], result, thisTest['errorMessage'] +
                ', should have been "%s" but was: %s' %
                (thisTest['filePath'], result))

        # download a file

        try:
            result = cacheController.findItem(
                nameOrLocation=
                'http://images.apple.com/support/iknow/images/downloads_software_update.png',
                checksumType='sha1',
                checksumValue='4d200d3fc229d929ea9ed64a9b5e06c5be733b38',
                displayName=None,
                progressReporter=None)
            expectedResult = os.path.join(
                cacheController.getCacheFolder(),
                'downloads_software_update sha1-4d200d3fc229d929ea9ed64a9b5e06c5be733b38.png'
            )
            self.assertEqual(
                expectedResult, result,
                'Downloading a file from Apple\'s site returned: "%s" rather than "%s"'
                % (str(result), expectedResult))
        except FileNotFoundException, error:
            self.fail(thisTest['errorMessage'] +
                      ', was unable to find a package - ' + str(error))