def test_02_client_Package(self):
     """Client Package: Stop if package is missing
     Purpose: Checks that all packages are there
     Tags: client packages
     Requirements: QAS ISO 
     Component: Environment Setup
     
     Steps:
     1. Compare the packages; Make sure all the avaliable packes are there
     """
     # determine which package should be there
     packageDir = vasUtilities.getPackageDirectory(self.version)
     files = vasUtilities.getAvailablePackages(self.computer.os, self.computer.version, 
                                               self.computer.cpuArchitecture, packageDir, self.computer.distro)
     
     # test to see if it exsists. This check is complete madness. It does nothing. This is Chris's legacy
     notFound = []
     for aFile in files:
         found = False
         for theFile in files:
             if theFile.find(aFile) > -1:
                 found = True
                 break
         if not found:
             notFound.append(aFile)
     
     # if it doesn't fail all tests
     self.assertStopTestsIfFalse(len(notFound) !=0 or files != [], 
                                 "The following packages were not found: {}".format(notFound))
def main(directory, computerName, create, saveTo, createFrom, logDir):
    
    #logger = logging.getLogger('findPackages')
    #hdlr = logging.FileHandler(logLocation)
    #formatter = logging.Formatter('%(message)s')
    #hdlr.setFormatter(formatter)
    #logger.addHandler(hdlr) 
    #logger.setLevel(logging.INFO)
    try:
        computer = create_computer_with_hostname(computerName, "root", "test123")
        if not computer.is_connected:
            print "could not connect to {}. Exiting.".format(computerName)
            exit()
            
        os = computer.os
        osVersion = computer.version
        cpuArchitecture = computer.cpuArchitecture
        linuxDistro = computer.distro
        # get the new set
        fileList = vasUtilities.getAvailablePackages(os, osVersion, cpuArchitecture, directory, linuxDistro)
        if "mac" in os:
            command, os_options, fileList = getMacCommands(fileList, computer)
        else:
            command, os_options = getOsPackageCommands(os, linuxDistro)
        files = ''
        for package in fileList:
            #files += "{}\n".format(package)
            # this will be platform dependent
            if "solaris" in os:
                package = "{} all".format(package)
            files += getFileList(command, os_options, package, computer)        
        zeroByteFileList, allFileInfo = getZeroByteAndFileInfo(files, computer)
        
        # We need to pull all the dat stuff out
        
        fileSet = set(allFileInfo)
        # if need creation
        if create:
            print '\nHere are the files:\n--------------------------------------------------------------------------------------------\n'
            for clientFile in fileSet:
                print clientFile
            saveToFile(saveTo.format(computerName), fileSet)
            print "created {}".format(saveTo.format(computerName))
        else:
            oldset = createFromFile(createFrom.format(computerName))
            if not oldset:
                print "Unable to load the old results from {}".format(createFrom.format(computerName))
                exit()
            # compare with older set
            diff = oldset ^ fileSet

            old = list(oldset)
            new = list(fileSet)

            # I added these so I could see more info 
            #print "\n Old list"
            #for x in old:
                #print x
            
            #print "\n New list"
            #for x in new:
                #print x
                        
            # list the differences in the new set
            if zeroByteFileList:
                print "\nHere are the files that are 0 bytes:"
                for i in zeroByteFileList:
                    print i
            else:
                print "0 | No zero byte files were found"
                
            if diff:
                dif_list = list(diff)
                print "{} | Differences found!".format(len(dif_list)) 
                print "\nHere are the differences:"
                for diff_file in diff:
                    print diff_file
                
                print "\n"
                
                old, new = sortDifferenceSet(oldset, fileSet, diff)
                for key, value in new.iteritems():
                    if old.get(key):
                        print "'{}' with the attributes '{}' is new to build {}".format(value, key, options.build)
            else:
                print "0 | There were no differences found"
        
    finally:
        if computer.is_connected:
            computer.closeConnection()