diff options
Diffstat (limited to 'interfaces')
-rw-r--r-- | interfaces/email/interactive/send_pgp_mime.py | 30 | ||||
-rwxr-xr-x | interfaces/web/cfbe.py | 2 | ||||
-rw-r--r-- | interfaces/web/web.py | 22 |
3 files changed, 27 insertions, 27 deletions
diff --git a/interfaces/email/interactive/send_pgp_mime.py b/interfaces/email/interactive/send_pgp_mime.py index 8febe10..e0ffbd5 100644 --- a/interfaces/email/interactive/send_pgp_mime.py +++ b/interfaces/email/interactive/send_pgp_mime.py @@ -27,7 +27,7 @@ the pgp_* commands. You may need to adjust the sendmail command to point to whichever sendmail-compatible mailer you have on your system. """ -from cStringIO import StringIO +from io import StringIO import os import re #import GnuPGInterface # Maybe should use this instead of subprocess @@ -150,16 +150,16 @@ def header_from_text(text, encoding="us-ascii"): <BLANKLINE> """ text = text.strip() - if type(text) == types.UnicodeType: + if type(text) == str: text = text.encode(encoding) # assume StringType arguments are already encoded p = Parser() return p.parsestr(text, headersonly=True) def guess_encoding(text): - if type(text) == types.StringType: + if type(text) == bytes: encoding = "us-ascii" - elif type(text) == types.UnicodeType: + elif type(text) == str: for encoding in ["us-ascii", "iso-8859-1", "utf-8"]: try: text.encode(encoding) @@ -181,7 +181,7 @@ def encodedMIMEText(body, encoding=None): def append_text(text_part, new_text): original_payload = text_part.get_payload(decode=True) - new_payload = u"%s%s" % (original_payload, new_text) + new_payload = "%s%s" % (original_payload, new_text) new_encoding = guess_encoding(new_payload) text_part.set_payload(new_payload.encode(new_encoding), new_encoding) @@ -190,7 +190,7 @@ def attach_root(header, root_part): Attach the email.Message root_part to the email.Message header without generating a multi-part message. """ - for k,v in header.items(): + for k,v in list(header.items()): root_part[k] = v return root_part @@ -199,19 +199,19 @@ def execute(args, stdin=None, expect=(0,)): Execute a command (allows us to drive gpg). """ if verboseInvoke == True: - print >> sys.stderr, '$ '+args + print('$ '+args, file=sys.stderr) try: p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, close_fds=True) - except OSError, e: + except OSError as e: strerror = '%s\nwhile executing %s' % (e.args[1], args) - raise Exception, strerror + raise Exception(strerror) output, error = p.communicate(input=stdin) status = p.wait() if verboseInvoke == True: - print >> sys.stderr, '(status: %d)\n%s%s' % (status, output, error) + print('(status: %d)\n%s%s' % (status, output, error), file=sys.stderr) if status not in expect: strerror = '%s\nwhile executing %s\n%s\n%d' % (args[1], args, error, status) - raise Exception, strerror + raise Exception(strerror) return status, output, error def replace(template, format_char, replacement_text): @@ -245,7 +245,7 @@ def flatten(msg, to_unicode=False): text = fp.getvalue() if to_unicode == True: encoding = msg.get_content_charset() or "utf-8" - text = unicode(text, encoding=encoding) + text = str(text, encoding=encoding) return text def source_email(msg, return_realname=False): @@ -581,7 +581,7 @@ if __name__ == '__main__': else: header = file(options.header_filename, 'r').read() if header == None: - raise Exception, "missing header" + raise Exception("missing header") headermsg = header_from_text(header) body = None if options.body_filename != None: @@ -592,7 +592,7 @@ if __name__ == '__main__': else: body = file(options.body_filename, 'r').read() if body == None: - raise Exception, "missing body" + raise Exception("missing body") m = PGPMimeMessageFactory(body) if options.mode == "sign": @@ -609,6 +609,6 @@ if __name__ == '__main__': message = attach_root(headermsg, bodymsg) if options.output == True: message = flatten(message) - print message + print(message) else: mail(message, sendmail) diff --git a/interfaces/web/cfbe.py b/interfaces/web/cfbe.py index 68c484d..33edc0d 100755 --- a/interfaces/web/cfbe.py +++ b/interfaces/web/cfbe.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import cherrypy -import web +from . import web from optparse import OptionParser from os import path diff --git a/interfaces/web/web.py b/interfaces/web/web.py index 2907932..ed87c78 100644 --- a/interfaces/web/web.py +++ b/interfaces/web/web.py @@ -1,5 +1,5 @@ from datetime import datetime -from urllib import urlencode +from urllib.parse import urlencode from jinja2 import Environment, FileSystemLoader import cherrypy @@ -30,7 +30,7 @@ class WebInterface: store = storage.get_storage(self.bug_root) store.connect() version = store.storage_version() - print version + print(version) self.bd = bugdir.BugDir(store, from_storage=True) self.repository_name = self.bug_root.split('/')[-1] self.env = Environment(loader=FileSystemLoader(template_root)) @@ -39,20 +39,20 @@ class WebInterface: def get_common_information(self): """Returns a dict of common information that most pages will need.""" possible_assignees = list(set( - [unicode(bug.assigned) for bug in self.bd if bug.assigned != EMPTY])) - possible_assignees.sort(key=unicode.lower) + [str(bug.assigned) for bug in self.bd if bug.assigned != EMPTY])) + possible_assignees.sort(key=str.lower) possible_targets = list(set( - [unicode(bug.summary.rstrip("\n")) for bug in self.bd \ - if bug.severity == u"target"])) + [str(bug.summary.rstrip("\n")) for bug in self.bd \ + if bug.severity == "target"])) - possible_targets.sort(key=unicode.lower) + possible_targets.sort(key=str.lower) - possible_statuses = [u'open', u'assigned', u'test', u'unconfirmed', - u'closed', u'disabled', u'fixed', u'wontfix'] + possible_statuses = ['open', 'assigned', 'test', 'unconfirmed', + 'closed', 'disabled', 'fixed', 'wontfix'] - possible_severities = [u'minor', u'serious', u'critical', u'fatal', - u'wishlist'] + possible_severities = ['minor', 'serious', 'critical', 'fatal', + 'wishlist'] return {'possible_assignees': possible_assignees, 'possible_targets': possible_targets, |