X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fcommand.py;h=451c6b1f69bd2a6ecab7620f5e8f85300c0eb0b9;hb=1274df1d98f7004042768c9e2650f5ae9dd79e41;hp=a3092f6f1c72e2ef732f8270a65ef0fca8c1f3a1;hpb=e19a80c83efc0412914411def05bca6a0c0ca89d;p=dak.git diff --git a/daklib/command.py b/daklib/command.py index a3092f6f..451c6b1f 100644 --- a/daklib/command.py +++ b/daklib/command.py @@ -59,23 +59,32 @@ class CommandFile(object): session.add(signature_history) session.commit() + def _quote_section(self, section): + lines = [] + for l in str(section).splitlines(): + lines.append("> {0}".format(l)) + return "\n".join(lines) + def _evaluate_sections(self, sections, session): session.rollback() try: - sections.next() - section = sections.section - - action = section.get('Action', None) - if action is None: - raise CommandError('Encountered section without Action field') - self.result.append('Action: {0}'.format(action)) - - 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)) + while True: + sections.next() + section = sections.section + self.result.append(self._quote_section(section)) + + action = section.get('Action', None) + if action is None: + raise CommandError('Encountered section without Action field') + + 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)) + + self.result.append('') except StopIteration: pass finally: @@ -163,7 +172,6 @@ class CommandFile(object): self._notify_uploader() session.close() - self.log.log(['done', self.filename]) return result @@ -189,7 +197,10 @@ class CommandFile(object): acl_name = cnf.get('Command::DM::ACL', 'dm') acl = session.query(ACL).filter_by(name=acl_name).one() - fpr = session.query(Fingerprint).filter_by(fingerprint=section['Fingerprint']).one() + fpr_hash = section['Fingerprint'].translate(None, ' ') + fpr = session.query(Fingerprint).filter_by(fingerprint=fpr_hash).first() + if fpr is None: + raise CommandError('Unknown fingerprint {0}'.format(fpr_hash)) if fpr.keyring is None or fpr.keyring.keyring_name not in cnf.value_list('Command::DM::Keyrings'): raise CommandError('Key {0} is not in DM keyring.'.format(fpr.fingerprint)) addresses = gpg_get_key_addresses(fpr.fingerprint)