X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fcommand.py;h=a3092f6f1c72e2ef732f8270a65ef0fca8c1f3a1;hb=e19a80c83efc0412914411def05bca6a0c0ca89d;hp=74d205680148d783fddcd6f65fc7aac0470321e4;hpb=0d52859a59eec1f7bda3cdbd9cf2894ca280fa66;p=dak.git diff --git a/daklib/command.py b/daklib/command.py index 74d20568..a3092f6f 100644 --- a/daklib/command.py +++ b/daklib/command.py @@ -72,6 +72,8 @@ class CommandFile(object): if action == 'dm': self.action_dm(self.fingerprint, section, session) + elif action == 'break-the-archive': + self.action_break_the_archive(self.fingerprint, section, session) else: raise CommandError('Unknown action: {0}'.format(action)) except StopIteration: @@ -155,7 +157,7 @@ class CommandFile(object): self.result.append('') except Exception as e: self.log.log(['ERROR', e]) - self.result.append("There was an error processing this section:\n{0}".format(e)) + self.result.append("There was an error processing this section. No changes were committed.\nDetails:\n{0}".format(e)) result = False self._notify_uploader() @@ -201,6 +203,10 @@ class CommandFile(object): self.result.append('Uid: {0}'.format(addresses[0])) for source in self._split_packages(section.get('Allow', '')): + # Check for existance of source package to catch typos + if session.query(DBSource).filter_by(source=source).first() is None: + raise CommandError('Tried to grant permissions for unknown source package: {0}'.format(source)) + if session.query(ACLPerSource).filter_by(acl=acl, fingerprint=fpr, source=source).first() is None: aps = ACLPerSource() aps.acl = acl @@ -217,8 +223,20 @@ class CommandFile(object): session.flush() for source in self._split_packages(section.get('Deny', '')): - session.query(ACLPerSource).filter_by(acl=acl, fingerprint=fpr, source=source).delete() + count = session.query(ACLPerSource).filter_by(acl=acl, fingerprint=fpr, source=source).delete() + if count == 0: + raise CommandError('Tried to remove upload permissions for package {0}, ' + 'but no upload permissions were granted before.'.format(source)) + self.log.log(['dm', 'deny', fpr.fingerprint, source]) self.result.append('Denied: {0}'.format(source)) session.commit() + + def action_break_the_archive(self, fingerprint, section, session): + name = 'Dave' + uid = fingerprint.uid + if uid is not None and uid.name is not None: + name = uid.name.split()[0] + + self.result.append("DAK9000: I'm sorry, {0}. I'm afraid I can't do that.".format(name))