def download_append(self, vg, versions_file, **additional_params): """ @param vg an instance of VersionGetterBase, such as SSVersions or DrupalVersions @param versions_file the versions_file which corresponds to this VersionGetterBase, in the filesystem. @param **aditional_params: - override_newer: utilize this value instead of calling newer_get. """ versions = VersionsFile(versions_file) ok = self.confirm('This will download a whole bunch of stuff. OK?') if ok: base_folder = mkdtemp() + "/" # Get information needed. if 'override_newer' in additional_params: new = additional_params['override_newer'] else: majors = versions.highest_version_major(vg.update_majors) new = vg.newer_get(majors) if len(new) == 0: self.error("No new version found, versions.xml is up to date.") # Get hashes. dl_files = vg.download(new, base_folder) extracted_dirs = vg.extract(dl_files, base_folder) file_sums = vg.sums_get(extracted_dirs, versions.files_get()) versions.update(file_sums) xml = versions.str_pretty() # Final sanity checks. f_temp = NamedTemporaryFile(delete=False) f_temp.write(xml) f_temp.close() call(['diff', '-s', f_temp.name, versions_file]) os.remove(f_temp.name) ok = self.confirm('Overwrite %s with the new file?' % versions_file) if ok: f_real = open(versions_file, 'w') f_real.write(xml) f_real.close() print "Done." call(['git', 'status']) else: self.error('Aborted.') else: self.error('Aborted.')
def test_updates_changelog(self): weird_hash = '13371337133713371337133713371337' vf = VersionsFile(self.update_versions_xml) hashes = { '6.34': { 'misc/ajax.js': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'CHANGELOG.txt': weird_hash, 'misc/drupal.js': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'misc/tabledrag.js': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' } } vf.update(hashes) out = vf.str_pretty() assert weird_hash in str(out)