diff options
author | Christoph Goehre <christoph.goehre@gmx.de> | 2008-09-20 10:52:41 +0200 |
---|---|---|
committer | Christoph Goehre <christoph.goehre@gmx.de> | 2008-09-20 18:10:30 +0200 |
commit | a4cc92989da6619456a69f8d176e0986c4935496 (patch) | |
tree | 5dfbee6a2297f83bf43443e73f10f3523ab55a96 | |
parent | 5bbaa283c704fb3a1d83c281031d6131cfc58a91 (diff) | |
download | mini-dinstall-a4cc92989da6619456a69f8d176e0986c4935496.tar.bz2 mini-dinstall-a4cc92989da6619456a69f8d176e0986c4935496.tar.xz mini-dinstall-a4cc92989da6619456a69f8d176e0986c4935496.tar.zst |
expand tabs and remove tailing whitespaces
-rwxr-xr-x | mini-dinstall | 70 | ||||
-rw-r--r-- | minidinstall/ChangeFile.py | 10 | ||||
-rw-r--r-- | minidinstall/Dnotify.py | 6 | ||||
-rwxr-xr-x | minidinstall/DpkgControl.py | 6 | ||||
-rw-r--r-- | minidinstall/GPGSigVerifier.py | 2 | ||||
-rwxr-xr-x | minidinstall/SignedFile.py | 4 | ||||
-rw-r--r-- | minidinstall/misc.py | 26 |
7 files changed, 62 insertions, 62 deletions
diff --git a/mini-dinstall b/mini-dinstall index d03209d..fa21961 100755 --- a/mini-dinstall +++ b/mini-dinstall @@ -157,7 +157,7 @@ for key, val in opts: def do_mkdir(name): if os.access(name, os.X_OK): - return + return try: logger.info('Creating directory "%s"' % (name)) except: @@ -377,7 +377,7 @@ class DistOptionHandler: ret[key] = self.get_option (type, 'DEFAULT', key) if self._configp.has_option (dist, key): ret[key] = self.get_option (type, dist, key) - return ret + return ret def get_option (self, type, dist, key): if type == 'int': @@ -389,7 +389,7 @@ class DistOptionHandler: elif type == 'bool': return self._configp.getboolean(dist, key) assert(None) - + distoptionhandler = DistOptionHandler(distributions, configp) @@ -424,8 +424,8 @@ logger.debug("Distributions: %s" % (distributions,)) # def renameFile(self, source, dst): # self._start_op('rename', - - + + # def _sync(): # os.system("sync") os.chdir(toplevel_directory) @@ -486,7 +486,7 @@ class IncomingDir(threading.Thread): self._last_failed_targets = {} self._eventqueue = Queue.Queue() self._done_event = threading.Event() - # ensure we always have some reprocess queue + # ensure we always have some reprocess queue self._reprocess_queue = {} def run(self): @@ -524,17 +524,17 @@ class IncomingDir(threading.Thread): self._logger.debug("glob: " + globpath) changefilenames = glob.glob(globpath) for changefilename in changefilenames: - if not self._reprocess_queue.has_key(changefilename): - self._logger.info('Examining "%s"' % (changefilename,)) - changefile = ChangeFile() - try: - changefile.load_from_file(changefilename) - except ChangeFileException: - self._logger.debug("Unable to parse \"%s\", skipping" % (changefilename,)) - continue - ret.append((changefilename, changefile)) - else: - self._logger.debug('Skipping "%s" during new scan because it is in the reprocess queue.' % (changefilename,)) + if not self._reprocess_queue.has_key(changefilename): + self._logger.info('Examining "%s"' % (changefilename,)) + changefile = ChangeFile() + try: + changefile.load_from_file(changefilename) + except ChangeFileException: + self._logger.debug("Unable to parse \"%s\", skipping" % (changefilename,)) + continue + ret.append((changefilename, changefile)) + else: + self._logger.debug('Skipping "%s" during new scan because it is in the reprocess queue.' % (changefilename,)) return ret def _changefile_ready(self, changefilename, changefile): @@ -630,12 +630,12 @@ class IncomingDir(threading.Thread): changefile = ChangeFile() changefile.load_from_file(changefilename) except (ChangeFileException,IOError), e: - if not os.path.exists(changefilename): - self._logger.info('Changefile "%s" got removed' % (changefilename,)) - else: - self._logger.exception("Unable to load change file \"%s\"" % (changefilename,)) - self._logger.warn("Marking \"%s\" as screwed" % (changefilename,)) - fucked.append(changefilename) + if not os.path.exists(changefilename): + self._logger.info('Changefile "%s" got removed' % (changefilename,)) + else: + self._logger.exception("Unable to load change file \"%s\"" % (changefilename,)) + self._logger.warn("Marking \"%s\" as screwed" % (changefilename,)) + fucked.append(changefilename) del self._reprocess_queue[changefilename] continue if (curtime - starttime) > self._max_retry_time: @@ -647,8 +647,8 @@ class IncomingDir(threading.Thread): self._logger.debug('Preparing to install "%s"' % (changefilename,)) try: self._install_changefile(changefilename, changefile, doing_reprocess) - self._logger.debug('Removing "%s" from incoming queue after successful install.' % (changefilename,)) - del self._reprocess_queue[changefilename] + self._logger.debug('Removing "%s" from incoming queue after successful install.' % (changefilename,)) + del self._reprocess_queue[changefilename] except Exception, e: logger.exception("Unable to install \"%s\"; adding to screwed list" % (changefilename,)) fucked.append(changefilename) @@ -853,7 +853,7 @@ class ArchiveDir: target = self._source_target(file) newfiles.append((os.path.join(incomingdir, file), target, match.group(1), 'source')) continue - + all_arches = {} for arch in map(lambda x: x[3], newfiles): all_arches[arch] = 1 @@ -914,7 +914,7 @@ class ArchiveDir: if match and match.group(1) in map(lambda x: x[2], newfiles): oldfiles.append((file, target)) continue - + self._clean_targets = map(lambda x: x[1], oldfiles) allrenames = oldfiles + map(lambda x: x[:2], newfiles) try: @@ -957,8 +957,8 @@ class ArchiveDir: return 0 def _reject_changefile(self, changefilename, changefile, exception): - sourcename = changefile['source'] - version = changefile['version'] + sourcename = changefile['source'] + version = changefile['version'] incomingdir = os.path.dirname(changefilename) try: f = open(os.path.join(rejectdir, "%s_%s.reason" % (sourcename, version)), 'w') @@ -1015,7 +1015,7 @@ class SimpleSubdirArchiveDir(ArchiveDir): ret.append((match.group(1), match.group(2), match.group(3))) return ret - + class FlatArchiveDir(ArchiveDir): def _read_source_dir(self): return os.listdir(self._dir) @@ -1050,7 +1050,7 @@ class ArchiveDirIndexer(threading.Thread): do_mkdir(dir) self._use_dnotify = use_dnotify self._batch_mode = batch_mode - self._done_event = threading.Event() + self._done_event = threading.Event() def _abspath(self, *args): return os.path.abspath(apply(os.path.join, [self._dir] + list(args))) @@ -1116,7 +1116,7 @@ class ArchiveDirIndexer(threading.Thread): self._logger.exception("failure while running Release signature script") return None return 1 - + # Copied from ArchiveDir def _run_script(self, changefilename, script, dir=None): if script: @@ -1209,7 +1209,7 @@ class ArchiveDirIndexer(threading.Thread): obj = self._eventqueue.get() if type(obj) == type(''): self._logger.debug('got dir change') - dir = obj + dir = obj elif type(obj) == type(None): self._logger.debug('got general event') setevent = None @@ -1290,7 +1290,7 @@ class SimpleSubdirArchiveDirIndexer(ArchiveDirIndexer): self._logger.info('Packages generation complete') else: self._logger.info('Skipping generation of Packages file for %s' % (arch,)) - + else: pkgsfile = self._relpath(arch, 'Sources') if force or (not os.access(pkgsfile, os.R_OK)) or dirmtime > os.stat(pkgsfile)[stat.ST_MTIME]: @@ -1547,7 +1547,7 @@ else: archive = archivemap[dist][1] logger.info('Die event caught; waiting for archive %s to finish' % (archive.getName(),)) archive.wait() - + #logging.shutdown() logger.debug('Removing lock file: ' + lockfilename) os.unlink(lockfilename) diff --git a/minidinstall/ChangeFile.py b/minidinstall/ChangeFile.py index 3b89b34..ca88112 100644 --- a/minidinstall/ChangeFile.py +++ b/minidinstall/ChangeFile.py @@ -29,16 +29,16 @@ class ChangeFileException(Exception): self._value = value def __str__(self): return `self._value` - + class ChangeFile(DpkgControl.DpkgParagraph): md5_re = r'^(?P<md5>[0-9a-f]{32})[ \t]+(?P<size>\d+)[ \t]+(?P<section>[-/a-zA-Z0-9]+)[ \t]+(?P<priority>[-a-zA-Z0-9]+)[ \t]+(?P<file>[0-9a-zA-Z][-+:.,=~0-9a-zA-Z_]+)$' sha1_re = r'^(?P<sha1>[0-9a-f]{40})[ \t]+(?P<size>\d+)[ \t]+(?P<file>[0-9a-zA-Z][-+:.,=~0-9a-zA-Z_]+)$' sha256_re = r'^(?P<sha256>[0-9a-f]{64})[ \t]+(?P<size>\d+)[ \t]+(?P<file>[0-9a-zA-Z][-+:.,=~0-9a-zA-Z_]+)$' - def __init__(self): + def __init__(self): DpkgControl.DpkgParagraph.__init__(self) self._logger = logging.getLogger("mini-dinstall") - + def load_from_file(self, filename): f = SignedFile.SignedFile(open(filename)) self.load(f) @@ -78,7 +78,7 @@ class ChangeFile(DpkgControl.DpkgParagraph): raise ChangeFileException("Couldn't parse file entry \"%s\" in Files field of .changes" % (line,)) output[hash].append([match.group(hash), match.group('size'), match.group('file') ]) return output - + def verify(self, sourcedir): """ verify size and hash values from changes file """ checksum = self._get_checksum_from_changes() @@ -86,7 +86,7 @@ class ChangeFile(DpkgControl.DpkgParagraph): for (hashsum, size, filename) in checksum[hash]: self._verify_file_integrity(os.path.join(sourcedir, filename), int(size), hash, hashsum) - + def _verify_file_integrity(self, filename, expected_size, hash, expected_hashsum): """ check uploaded file integrity """ self._logger.debug('Checking integrity of %s' % (filename,)) diff --git a/minidinstall/Dnotify.py b/minidinstall/Dnotify.py index 122e03c..e31080c 100644 --- a/minidinstall/Dnotify.py +++ b/minidinstall/Dnotify.py @@ -92,7 +92,7 @@ class MtimeDirectoryNotifier(DirectoryNotifier): self._polltime = poll_time for dir in dirs: self._dirmap[dir] = os.stat(os.path.join(self._cwd, dir))[stat.ST_MTIME] - + def poll(self, timeout=None): timeout_time = None if timeout: @@ -123,7 +123,7 @@ class DnotifyDirectoryNotifier(DirectoryNotifier): self._queue = Queue.Queue() dnotify = DnotifyThread(self._queue, self._dirs, self._logger) dnotify.start() - + def poll(self, timeout=None): # delete duplicates i = self._queue.qsize() @@ -164,7 +164,7 @@ class DnotifyThread(threading.Thread): self._queue = queue self._dirs = dirs self._logger = logger - + def run(self): self._logger.debug('Starting dnotify reading thread') (infd, outfd) = os.pipe() diff --git a/minidinstall/DpkgControl.py b/minidinstall/DpkgControl.py index 38147c7..4bda8c5 100755 --- a/minidinstall/DpkgControl.py +++ b/minidinstall/DpkgControl.py @@ -50,7 +50,7 @@ class DpkgParagraph(DpkgOrderedDatalist): value = None while 1: line = f.readline() - if not line: + if not line: return # skip blank lines until we reach a paragraph if line == '\n': @@ -124,10 +124,10 @@ class DpkgSourceControl( DpkgControl ): f = SignedFile(f) self.source = self._load_one( f ) DpkgControl.load( self, f ) - + def __repr__( self ): return self.source.__repr__() + "\n" + DpkgControl.__repr__( self ) - + def _store( self, f ): "Write our control data to a file object" self.source._store( f ) diff --git a/minidinstall/GPGSigVerifier.py b/minidinstall/GPGSigVerifier.py index 78aeebb..a8fb46c 100644 --- a/minidinstall/GPGSigVerifier.py +++ b/minidinstall/GPGSigVerifier.py @@ -74,5 +74,5 @@ class GPGSigVerifier: msg = "gpgv died with signal %d" % (os.WTERMSIG(status),) raise GPGSigVerificationFailure(msg, output) return output - + # vim:ts=4:sw=4:et: diff --git a/minidinstall/SignedFile.py b/minidinstall/SignedFile.py index 648186e..71181c3 100755 --- a/minidinstall/SignedFile.py +++ b/minidinstall/SignedFile.py @@ -63,7 +63,7 @@ class SignedFile: self._signature = string.join return '' return line - + def readlines(self): ret = [] while 1: @@ -85,7 +85,7 @@ class SignedFile: def getSignatureVersion(self): return self._signatureversion - + if __name__=="__main__": import sys if len(sys.argv) == 0: diff --git a/minidinstall/misc.py b/minidinstall/misc.py index a942adc..aeb1490 100644 --- a/minidinstall/misc.py +++ b/minidinstall/misc.py @@ -21,19 +21,19 @@ import os, errno, time, string, re, popen2 def dup2(fd,fd2): - # dup2 with EBUSY retries (cf. dup2(2) and Debian bug #265513) - success = 0 - tries = 0 - while (not success): - try: - os.dup2(fd,fd2) - success = 1 - except OSError, e: - if (e.errno != errno.EBUSY) or (tries >= 3): - raise - # wait 0-2 seconds befor next try - time.sleep(tries) - tries += 1 + # dup2 with EBUSY retries (cf. dup2(2) and Debian bug #265513) + success = 0 + tries = 0 + while (not success): + try: + os.dup2(fd,fd2) + success = 1 + except OSError, e: + if (e.errno != errno.EBUSY) or (tries >= 3): + raise + # wait 0-2 seconds befor next try + time.sleep(tries) + tries += 1 def format_changes(L): """ remove changelog header and all lines with only a dot """ |