def flush_orphans(): all_files = {} changes_files = [] Logger.log(["check Incoming for old orphaned files", os.getcwd()]) # Build up the list of all files in the directory for i in os.listdir('.'): if os.path.isfile(i): all_files[i] = 1 if i.endswith(".changes"): changes_files.append(i) # Proces all .changes and .dsc files. for changes_filename in changes_files: try: changes = utils.parse_changes(changes_filename) files = utils.build_file_list(changes) except: utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_info()[0])) continue dsc_files = {} for f in files.keys(): if f.endswith(".dsc"): try: dsc = utils.parse_changes(f, dsc_file=1) dsc_files = utils.build_file_list(dsc, is_a_dsc=1) except: utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_info()[0])) continue # Ensure all the files we've seen aren't deleted keys = [] for i in (files.keys(), dsc_files.keys(), [changes_filename]): keys.extend(i) for key in keys: if key in all_files: if Options["Verbose"]: print("Skipping, has parents, '%s'." % (key)) del all_files[key] # Anthing left at this stage is not referenced by a .changes (or # a .dsc) and should be deleted if old enough. for f in all_files.keys(): if os.stat(f)[stat.ST_MTIME] < delete_date: remove('Incoming', f) else: if Options["Verbose"]: print("Skipping, too new, '%s'." % (os.path.basename(f)))
def flush_orphans (): all_files = {} changes_files = [] Logger.log(["check Incoming for old orphaned files", os.getcwd()]) # Build up the list of all files in the directory for i in os.listdir('.'): if os.path.isfile(i): all_files[i] = 1 if i.endswith(".changes"): changes_files.append(i) # Proces all .changes and .dsc files. for changes_filename in changes_files: try: changes = utils.parse_changes(changes_filename) files = utils.build_file_list(changes) except: utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_info()[0])) continue dsc_files = {} for f in files.keys(): if f.endswith(".dsc"): try: dsc = utils.parse_changes(f, dsc_file=1) dsc_files = utils.build_file_list(dsc, is_a_dsc=1) except: utils.warn("error processing '%s'; skipping it. [Got %s]" % (f, sys.exc_info()[0])) continue # Ensure all the files we've seen aren't deleted keys = [] for i in (files.keys(), dsc_files.keys(), [changes_filename]): keys.extend(i) for key in keys: if all_files.has_key(key): if Options["Verbose"]: print "Skipping, has parents, '%s'." % (key) del all_files[key] # Anthing left at this stage is not referenced by a .changes (or # a .dsc) and should be deleted if old enough. for f in all_files.keys(): if os.stat(f)[stat.ST_MTIME] < delete_date: remove('Incoming', f) else: if Options["Verbose"]: print "Skipping, too new, '%s'." % (os.path.basename(f))
def test_10(self): changes = self.assertParse('dsc/10.dsc', -1, 1) files = build_file_list(changes, 1) rejmsg = check_dsc_files('10.dsc', changes, files.keys()) self.assertEqual( rejmsg, ['10.dsc: contains source files not allowed in format 1.0'])
def check_changes (changes_filename): try: changes = utils.parse_changes (changes_filename) except ChangesUnicodeError: utils.warn("Encoding problem with changes file %s" % (changes_filename)) print display_changes(changes['distribution'], changes_filename) files = utils.build_file_list(changes) for f in files.keys(): if f.endswith(".deb") or f.endswith(".udeb"): print check_deb(changes['distribution'], f) if f.endswith(".dsc"): print check_dsc(changes['distribution'], f)
def check_changes(changes_filename): try: changes = utils.parse_changes(changes_filename) except UnicodeDecodeError: utils.warn("Encoding problem with changes file %s" % (changes_filename)) output = display_changes(changes['distribution'], changes_filename) files = utils.build_file_list(changes) for f in files.keys(): if f.endswith(".deb") or f.endswith(".udeb"): output += check_deb(changes['distribution'], f) if f.endswith(".dsc"): output += check_dsc(changes['distribution'], f) # else: => byhand return six.ensure_str(output)
def test_1(self): changes = self.assertParse('dsc/1.dsc', -1, 1) files = build_file_list(changes, 1) rejmsg = check_dsc_files('1.dsc', changes, files.keys()) self.assertEqual(rejmsg, [])
def test_10(self): changes = self.assertParse('dsc/10.dsc', -1, 1) files = build_file_list(changes, 1) rejmsg = check_dsc_files('10.dsc', changes, files.keys()) self.assertEqual(rejmsg, [])