def testWritePackageRecordFile(self): file_path = os.path.join(os.path.dirname(__file__), "data/packages-out.xml") packages = [Package(name='foo', version='1'), Package(name='baz', version='0.1'), Package(name='bar')] package_record_file = PackagesRecordFile(file_path) package_record_file.write(packages) contents = FileManager.read_file(file_path) self.assertEqual("<packages><package>foo</package><package>baz</package><package>bar</package></packages>", contents) os.remove(file_path)
def backup(self, basedir, include=[], exclude=[]): '''backup the packages installed locally''' if snap.config.options.log_level_at_least('verbose'): snap.callback.snapcallback.message("Backing up software on windows"); packages = Win.get_packages() # backup program files for pkg in packages: for pkg_file in FileManager.get_all_files(include=[pkg.name]): SFile(pkg_file).copy_to(os.path.join(basedir, "windows-packages")) # TODO Backup registry? # write record file to basedir record = PackagesRecordFile(os.path.join(basedir, "packages.xml")) record.write(packages)
def testWritePackageRecordFile(self): file_path = os.path.join(os.path.dirname(__file__), "data/packages-out.xml") packages = [ Package(name='foo', version='1'), Package(name='baz', version='0.1'), Package(name='bar') ] package_record_file = PackagesRecordFile(file_path) package_record_file.write(packages) contents = FileManager.read_file(file_path) self.assertEqual( "<packages><package>foo</package><package>baz</package><package>bar</package></packages>", contents) os.remove(file_path)
def backup(self, basedir, include=[], exclude=[]): '''backup the packages installed locally''' if snap.config.options.log_level_at_least('verbose'): snap.callback.snapcallback.message("Backing up packages using yum backend"); # retrieve installed packages packages=[] packagenames = set() for pkg in self.yum.rpmdb: if not pkg.name in packagenames: if snap.config.options.log_level_at_least('verbose'): snap.callback.snapcallback.message("Backing up package " + pkg.name); packagenames.add(pkg.name) encoded_pkgname = PackageRegistry.encode('yum', pkg.name) packages.append(Package(encoded_pkgname, pkg.version)) # write record file to basedir record = PackagesRecordFile(basedir + "/packages.xml") record.write(packages)
def backup(self, basedir, include=[], exclude=[]): '''backup the packages installed locally''' if snap.config.options.log_level_at_least('verbose'): snap.callback.snapcallback.message( "Backing up software on windows") packages = Win.get_packages() # backup program files for pkg in packages: for pkg_file in FileManager.get_all_files(include=[pkg.name]): SFile(pkg_file).copy_to( os.path.join(basedir, "windows-packages")) # TODO Backup registry? # write record file to basedir record = PackagesRecordFile(os.path.join(basedir, "packages.xml")) record.write(packages)