def verify(self): ''' The method which iterates through each item in the list and performs the appropriate actions.''' # Collect each of the elements which needs to be built elements = [(self.scan, Output.SCANNING), (self.download, Output.DOWNLOADING), (self.checksum, Output.VERIFYING), (self.copy, Output.COPYING)] # Store all of the results result = True # Iterate through each item in turn for element in self.elements: # Get the information from the file self.version = self.elements[element].get('version') self.description = self.elements[element].get('description') + ' ' + str(self.version) self.file = self.elements[element].get('file').replace('{version}', str(self.version)) self.extension = self.elements[element].get('extension') self.url = path.join(self.elements[element].get('url').replace('{version}', str(self.version)).replace('{version_}', str(self.version).replace('.', '_')), self.file + self.extension) self.md5 = self.elements[element].get('md5') # Store the root file name self.source = path.join(sys.path[0], '..', 'sources', self.file) self.target = path.join(self.environment['WANDER'], 'sources', self.file) # Notify the user of what's happening Output.log(Output.PENDING, self.description) # Presume that each stage will run successfully success = True # Iterate through each of the phases for element, stage in elements: # Notify the user of what we're doing Output.clear() Output.log(stage, self.description) # Add the result to our success variable success &= element() # Add the result to our results variable result &= success # And stop if there is an error if not success: break # At this point, we're pretty much finished Output.clear() Output.log(Output.PASSED if success else Output.FAILED, self.description) # Add the final line of output print('') # And return how we did return result
def verify(self): ''' The verify method, which checks that a module built correctly, and prints that to the console.''' # Check if this module should be skipped if self.skip: # We're now finished with this prerequisite Output.clear() Output.log(Output.SKIPPED, self.description) # And return our result return True # Collect each of the elements which needs to be built elements = [(self.extract, Output.EXTRACTING), (self.fix, Output.PATCHING), (self.setup, Output.SETUP), (self.prepare, Output.PREPARING), (self.compile, Output.COMPILING), (self.configure, Output.CONFIGURING), (self.test, Output.TESTING), (self.install, Output.INSTALLING), (self.validate, Output.VALIDATING), (self.cleanup, Output.CLEANING)] # Store the result of the build result = True # Iterate through each of the phases for element, stage in elements: # Notify the user of what we're doing Output.clear() Output.log(stage, self.description) # Add the result to our results variable result &= element() # Check that everything is still fine if not result: # And stop our system Output.clear() Output.log(Output.FAILED, self.description) # And return our result return False # At this point, we're pretty much finished Output.clear() Output.log(Output.PASSED, self.description) # And return our result return True
def verify(self): ''' The verify method, which checks that a requirement is valid, and prints that to the console.''' # Perform the tests Output.clear() Output.log(Output.EXECUTING, self.description) # Iterate up to the test for element in range(self.test + 1): # Execute the commands result = self.parent.run([self.commands[element]], self.result is None, directory='/', logger=self.logger, phase='preparation')[-1] # And execute the rest of the commands for element in range(self.test + 1, len(self.commands)): # Execute the final commands self.parent.run([self.commands[element]], directory='/') # Check that the output is correct if self.result is not None: # Iterate through each of the acceptable results for possibility in self.result: # And return if the output matches if possibility.strip() in result.strip(): # Inform the user that things went well Output.clear() Output.log(Output.PASSED, self.description) return True # Check that the command exited safely elif result.endswith("0"): # If so, things are good Output.clear() Output.log(Output.PASSED, self.description) # And return our result return True # At this point, we obviously don't have the correct requirement Output.clear() Output.log(Output.FAILED, self.description) # And return our bad result return False
def verify(self): ''' The verify method, which checks that a requirement is valid, and prints that to the console.''' # Perform the tests Output.clear() Output.log(Output.TESTING, self.description) # Check the type of test if self.version is not None: # Execute the test code version = self.parent.run(self.commands)[-1] # Check that the command was found if 'not found' in version: # We don't have the program installed Output.clear() Output.log(Output.FAILED, self.description) # And return our result return False # Extrapolate the version information major, minor, revision = self.extrapolate(version) # Start checking the versions if major > self.major: # If the major is greater, we obviously have a newer version Output.clear() Output.log(Output.PASSED, self.description) # And return our result return True elif minor > self.minor: # If the minor is greater, we still have a newer version Output.clear() Output.log(Output.PASSED, self.description) # And return our result return True elif revision >= self.revision: # If the revision is greater or equal, we must have a newer # version Output.clear() Output.log(Output.PASSED, self.description) # And return our result return True elif self.endpoint is not None: # Execute the test code endpoint = self.parent.run(self.commands)[-1] # Check that the endpoint is correct if endpoint.endswith(self.endpoint): # If the endpoints are the same, things are good Output.clear() Output.log(Output.PASSED, self.description) # And return our result return True elif self.test is not None: # Iterate up to the test for element in range(self.test + 1): # Execute the commands result = self.parent.run([self.commands[element]], test = True)[-1] # And execute the rest of the commands for element in range(self.test + 1, len(self.commands)): # Execute the final commands self.parent.run([self.commands[element]]) # Check that the output is correct if result.endswith('0'): # If the endpoints are the same, things are good Output.clear() Output.log(Output.PASSED, self.description) # And return our result return True # At this point, we obviously don't have the correct requirement Output.clear() Output.log(Output.FAILED, self.description) # And return our bad result return False