X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fcommand.py;h=451c6b1f69bd2a6ecab7620f5e8f85300c0eb0b9;hb=772655d608069f12e400e0d6c7b7fac76eb98083;hp=88f65558c5e9659fe31da57acd4c95a4e7fa4c4b;hpb=650ec31aaf1883f5f866b5245db14bdf4cf196f7;p=dak.git diff --git a/daklib/command.py b/daklib/command.py index 88f65558..451c6b1f 100644 --- a/daklib/command.py +++ b/daklib/command.py @@ -59,17 +59,23 @@ 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: 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') - self.result.append('Action: {0}'.format(action)) if action == 'dm': self.action_dm(self.fingerprint, section, session) @@ -191,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)