Author: poeml Date: 2009-06-29 03:18:35 -0600 (Mon, 29 Jun 2009) New Revision: 7642 Modified: trunk/tools/download-redirector-v2/tools/metalink-hasher.py Log: metalink-hasher: - when removing directories that match the "ignore" regexp, ignore failure on missing permissions - small improvements in output and program help Modified: trunk/tools/download-redirector-v2/tools/metalink-hasher.py =================================================================== --- trunk/tools/download-redirector-v2/tools/metalink-hasher.py 2009-06-29 08:22:38 UTC (rev 7641) +++ trunk/tools/download-redirector-v2/tools/metalink-hasher.py 2009-06-29 09:18:35 UTC (rev 7642) _at_@ -100,7 +100,7 @@ class Metalinks(cmdln.Cmdln): _at_cmdln.option('-n', '--dry-run', action='store_true', - help='don\'t actually do anything') + help='don\'t actually do anything, just show what would be done') _at_cmdln.option('--copy-permissions', action='store_true', help='copy the permissions of directories and files ' 'to the hashes files. Normally, this should not ' _at_@ -109,7 +109,10 @@ _at_cmdln.option('-f', '--file-mask', metavar='REGEX', help='regular expression to select files to create hashes for') _at_cmdln.option('-i', '--ignore-mask', metavar='REGEX', - help='regular expression to ignore certain files, and don\'t create hashes for them') + help='regular expression to ignore certain files or directories. ' + 'If matching a file, no hashes are created for it. ' + 'If matching a directory, the directory is ignored and ' + 'deleted in the target tree.') _at_cmdln.option('-b', '--base-dir', metavar='PATH', help='set the base directory (so that you can work on a subdirectory)') _at_cmdln.option('-t', '--target-dir', metavar='PATH', _at_@ -170,7 +173,7 @@ src_dir_mode = os.stat(src_dir).st_mode except OSError, e: if e.errno == errno.ENOENT: - sys.stderr.write('Directory vanished: %r' % src) + sys.stderr.write('Directory vanished: %r\n' % src) continue dst_dir = os.path.join(opts.target_dir, src_dir[len(opts.base_dir):].lstrip('/')) _at_@ -184,6 +187,7 @@ os.chmod(dst_dir, 0755) src_names = set(os.listdir(src_dir)) + #print 'doing', src_dir try: dst_names = os.listdir(dst_dir) dst_names.sort() _at_@ -205,18 +209,24 @@ try: os.unlink(i_path) except OSError, e: - print 'Unlink failed for %r: %s' % (i_path, e.errno) + sys.stderr.write('Unlink failed for %r: %s\n' \ + % (i_path, os.strerror(e.errno))) unlinked_files += 1 # removal of obsolete directories else: - if i not in src_names: + if i not in src_names or (opts.ignore_mask and re.match(opts.ignore_mask, i_path)): if os.path.isdir(i_path): print 'Recursively removing obsolete directory %r' % i_path if not opts.dry_run: try: shutil.rmtree(i_path) except OSError, e: - print 'Recursive unlinking failed for %r: %s' % (i_path, e.errno) + if e.errno == errno.EACCES: + sys.stderr.write('Recursive removing failed for %r (%s). Ignoring.\n' \ + % (i_path, os.strerror(e.errno))) + else: + sys.exit('Recursive removing failed for %r: %s\n' \ + % (i_path, os.strerror(e.errno))) unlinked_dirs += 1 else: print 'Unlinking obsolete %r' % i_path _at_@ -236,7 +246,7 @@ src_statinfo = os.lstat(src) except OSError, e: if e.errno == errno.ENOENT: - sys.stderr.write('File vanished: %r' % src) + sys.stderr.write('File vanished: %r\n' % src) continue if stat.S_ISLNK(src_statinfo.st_mode): _______________________________________________ Opensuse-svn mailing list Opensuse-svn_at_forge.novell.com http://forge.novell.com/mailman/listinfo/opensuse-svn _______________________________________________ mirrorbrain-commits mailing list Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/ Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Mon Jun 29 2009 - 09:19:03 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT