def __measureDiskSpace(self): """ Returns the amount of space used by this package, in bytes, as determined by examining the actual contents of the package directory and its subdirectories. """ thisDir = ScanDirectoryNode(self.getPackageDir(), ignoreUsageXml=True) diskSpace = thisDir.getTotalSize() self.notify.info("Package %s uses %s MB" % (self.packageName, (diskSpace + 524288) / 1048576)) return diskSpace
def scanInstalledPackages(self): """ Scans the hosts and packages already installed locally on the system. Returns a list of InstalledHostData objects, each of which contains a list of InstalledPackageData objects. """ result = [] hostsFilename = Filename(self.rootDir, 'hosts') hostsDir = ScanDirectoryNode(hostsFilename) for dirnode in hostsDir.nested: host = self.getHostWithDir(dirnode.pathname) hostData = InstalledHostData(host, dirnode) if host: for package in host.getAllPackages(includeAllPlatforms=True): packageDir = package.getPackageDir() if not packageDir.exists(): continue subdir = dirnode.extractSubdir(packageDir) if not subdir: # This package, while defined by the host, isn't installed # locally; ignore it. continue packageData = InstalledPackageData(package, subdir) hostData.packages.append(packageData) # Now that we've examined all of the packages for the host, # anything left over is junk. for subdir in dirnode.nested: packageData = InstalledPackageData(None, subdir) hostData.packages.append(packageData) result.append(hostData) return result