From 2efe8255c5622759ce07f7d7ebad96984c6839fc Mon Sep 17 00:00:00 2001 From: Bruno Tikami Date: Tue, 1 Mar 2016 17:01:58 -0300 Subject: [PATCH] UPDATED: print statements to be Python 3.x compatible --- .../commands/create_escalation_exclusions.py | 18 ++++++++++-------- .../management/commands/escalate_tickets.py | 14 ++++++++------ helpdesk/management/commands/get_email.py | 7 ++++--- setup.py | 17 +++++++++++------ 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/helpdesk/management/commands/create_escalation_exclusions.py b/helpdesk/management/commands/create_escalation_exclusions.py index 52db4f85..089e9b26 100644 --- a/helpdesk/management/commands/create_escalation_exclusions.py +++ b/helpdesk/management/commands/create_escalation_exclusions.py @@ -8,6 +8,7 @@ scripts/create_escalation_exclusion.py - Easy way to routinely add particular days to the list of days on which no escalation should take place. """ +from __future__ import print_function from datetime import timedelta, date import getopt @@ -96,23 +97,24 @@ def create_exclusions(days, occurrences, verbose, queues): esc.save() if verbose: - print "Created exclusion for %s %s" % (day_name, workdate) + print("Created exclusion for %s %s" % (day_name, workdate)) for q in queues: esc.queues.add(q) if verbose: - print " - for queue %s" % q + print(" - for queue %s" % q) i += 1 workdate += timedelta(days=1) def usage(): - print "Options:" - print " --days, -d: Days of week (monday, tuesday, etc)" - print " --occurrences, -o: Occurrences: How many weeks ahead to exclude this day" - print " --queues, -q: Queues to include (default: all). Use queue slugs" - print " --verbose, -v: Display a list of dates excluded" + print("Options:") + print(" --days, -d: Days of week (monday, tuesday, etc)") + print(" --occurrences, -o: Occurrences: How many weeks ahead to exclude this day") + print(" --queues, -q: Queues to include (default: all). Use queue slugs") + print(" --verbose, -v: Display a list of dates excluded") + if __name__ == '__main__': @@ -150,7 +152,7 @@ if __name__ == '__main__': try: q = Queue.objects.get(slug__exact=queue) except Queue.DoesNotExist: - print "Queue %s does not exist." % queue + print("Queue %s does not exist." % queue) sys.exit(2) queues.append(q) diff --git a/helpdesk/management/commands/escalate_tickets.py b/helpdesk/management/commands/escalate_tickets.py index 37558f95..9212813b 100644 --- a/helpdesk/management/commands/escalate_tickets.py +++ b/helpdesk/management/commands/escalate_tickets.py @@ -7,6 +7,7 @@ django-helpdesk - A Django powered ticket tracker for small enterprise. scripts/escalate_tickets.py - Easy way to escalate tickets based on their age, designed to be run from Cron or similar. """ +from __future__ import print_function from datetime import timedelta, date import getopt @@ -85,7 +86,7 @@ def escalate_tickets(queues, verbose): req_last_escl_date = date.today() - timedelta(days=days) if verbose: - print "Processing: %s" % q + print("Processing: %s" % q) for t in q.ticket_set.filter( Q(status=Ticket.OPEN_STATUS) @@ -134,11 +135,12 @@ def escalate_tickets(queues, verbose): ) if verbose: - print " - Esclating %s from %s>%s" % ( + print(" - Esclating %s from %s>%s" % ( t.ticket, t.priority+1, t.priority ) + ) f = FollowUp( ticket = t, @@ -159,9 +161,9 @@ def escalate_tickets(queues, verbose): def usage(): - print "Options:" - print " --queues: Queues to include (default: all). Use queue slugs" - print " --verboseescalation: Display a list of dates excluded" + print("Options:") + print(" --queues: Queues to include (default: all). Use queue slugs") + print(" --verboseescalation: Display a list of dates excluded") if __name__ == '__main__': @@ -187,7 +189,7 @@ if __name__ == '__main__': try: q = Queue.objects.get(slug__exact=queue) except Queue.DoesNotExist: - print "Queue %s does not exist." % queue + print("Queue %s does not exist." % queue) sys.exit(2) queues.append(queue) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index e6a3b124..46812d71 100644 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -9,6 +9,7 @@ scripts/get_email.py - Designed to be run from cron, this script checks the helpdesk, creating tickets from the new messages (or adding to existing tickets if needed) """ +from __future__ import print_function import email import imaplib @@ -83,7 +84,7 @@ def process_email(quiet=False): def process_queue(q, quiet=False): if not quiet: - print "Processing: %s" % q + print("Processing: %s" % q) if q.socks_proxy_type and q.socks_proxy_host and q.socks_proxy_port: try: @@ -290,7 +291,7 @@ def ticket_from_message(message, queue, quiet): f.save() if not quiet: - print (" [%s-%s] %s" % (t.queue.slug, t.id, t.title,)).encode('ascii', 'replace') + print((" [%s-%s] %s" % (t.queue.slug, t.id, t.title,)).encode('ascii', 'replace')) for file in files: if file['content']: @@ -305,7 +306,7 @@ def ticket_from_message(message, queue, quiet): a.file.save(filename, ContentFile(file['content']), save=False) a.save() if not quiet: - print " - %s" % filename + print(" - %s" % filename) context = safe_template_context(t) diff --git a/setup.py b/setup.py index bd82c690..54166479 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import os import sys from distutils.util import convert_path @@ -63,9 +65,11 @@ def find_package_data( or fn.lower() == pattern.lower()): bad_name = True if show_ignored: - print >> sys.stderr, ( - "Directory %s ignored by pattern %s" - % (fn, pattern)) + print( + "Directory %s ignored by pattern %s" % (fn, pattern), + file=sys.stderr + ) + break if bad_name: continue @@ -86,9 +90,10 @@ def find_package_data( or fn.lower() == pattern.lower()): bad_name = True if show_ignored: - print >> sys.stderr, ( - "File %s ignored by pattern %s" - % (fn, pattern)) + print( + "File %s ignored by pattern %s" % (fn, pattern), + file=sys.stderr + ) break if bad_name: continue