forked from extern/django-helpdesk
Merge pull request #387 from brunotikami/hotfix/make_print_statements_3x_compatible
Make print statements Python 3.x compatible
This commit is contained in:
commit
bd7dca3a19
@ -8,6 +8,7 @@ scripts/create_escalation_exclusion.py - Easy way to routinely add particular
|
|||||||
days to the list of days on which no
|
days to the list of days on which no
|
||||||
escalation should take place.
|
escalation should take place.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from datetime import timedelta, date
|
from datetime import timedelta, date
|
||||||
import getopt
|
import getopt
|
||||||
@ -96,23 +97,24 @@ def create_exclusions(days, occurrences, verbose, queues):
|
|||||||
esc.save()
|
esc.save()
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Created exclusion for %s %s" % (day_name, workdate)
|
print("Created exclusion for %s %s" % (day_name, workdate))
|
||||||
|
|
||||||
for q in queues:
|
for q in queues:
|
||||||
esc.queues.add(q)
|
esc.queues.add(q)
|
||||||
if verbose:
|
if verbose:
|
||||||
print " - for queue %s" % q
|
print(" - for queue %s" % q)
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
workdate += timedelta(days=1)
|
workdate += timedelta(days=1)
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print "Options:"
|
print("Options:")
|
||||||
print " --days, -d: Days of week (monday, tuesday, etc)"
|
print(" --days, -d: Days of week (monday, tuesday, etc)")
|
||||||
print " --occurrences, -o: Occurrences: How many weeks ahead to exclude this day"
|
print(" --occurrences, -o: Occurrences: How many weeks ahead to exclude this day")
|
||||||
print " --queues, -q: Queues to include (default: all). Use queue slugs"
|
print(" --queues, -q: Queues to include (default: all). Use queue slugs")
|
||||||
print " --verbose, -v: Display a list of dates excluded"
|
print(" --verbose, -v: Display a list of dates excluded")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -150,7 +152,7 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
q = Queue.objects.get(slug__exact=queue)
|
q = Queue.objects.get(slug__exact=queue)
|
||||||
except Queue.DoesNotExist:
|
except Queue.DoesNotExist:
|
||||||
print "Queue %s does not exist." % queue
|
print("Queue %s does not exist." % queue)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
queues.append(q)
|
queues.append(q)
|
||||||
|
|
||||||
|
@ -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,
|
scripts/escalate_tickets.py - Easy way to escalate tickets based on their age,
|
||||||
designed to be run from Cron or similar.
|
designed to be run from Cron or similar.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from datetime import timedelta, date
|
from datetime import timedelta, date
|
||||||
import getopt
|
import getopt
|
||||||
@ -85,7 +86,7 @@ def escalate_tickets(queues, verbose):
|
|||||||
req_last_escl_date = date.today() - timedelta(days=days)
|
req_last_escl_date = date.today() - timedelta(days=days)
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Processing: %s" % q
|
print("Processing: %s" % q)
|
||||||
|
|
||||||
for t in q.ticket_set.filter(
|
for t in q.ticket_set.filter(
|
||||||
Q(status=Ticket.OPEN_STATUS)
|
Q(status=Ticket.OPEN_STATUS)
|
||||||
@ -134,11 +135,12 @@ def escalate_tickets(queues, verbose):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print " - Esclating %s from %s>%s" % (
|
print(" - Esclating %s from %s>%s" % (
|
||||||
t.ticket,
|
t.ticket,
|
||||||
t.priority+1,
|
t.priority+1,
|
||||||
t.priority
|
t.priority
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
f = FollowUp(
|
f = FollowUp(
|
||||||
ticket = t,
|
ticket = t,
|
||||||
@ -159,9 +161,9 @@ def escalate_tickets(queues, verbose):
|
|||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print "Options:"
|
print("Options:")
|
||||||
print " --queues: Queues to include (default: all). Use queue slugs"
|
print(" --queues: Queues to include (default: all). Use queue slugs")
|
||||||
print " --verboseescalation: Display a list of dates excluded"
|
print(" --verboseescalation: Display a list of dates excluded")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -187,7 +189,7 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
q = Queue.objects.get(slug__exact=queue)
|
q = Queue.objects.get(slug__exact=queue)
|
||||||
except Queue.DoesNotExist:
|
except Queue.DoesNotExist:
|
||||||
print "Queue %s does not exist." % queue
|
print("Queue %s does not exist." % queue)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
queues.append(queue)
|
queues.append(queue)
|
||||||
|
|
||||||
|
@ -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
|
helpdesk, creating tickets from the new messages (or
|
||||||
adding to existing tickets if needed)
|
adding to existing tickets if needed)
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import email
|
import email
|
||||||
import imaplib
|
import imaplib
|
||||||
@ -83,7 +84,7 @@ def process_email(quiet=False):
|
|||||||
|
|
||||||
def process_queue(q, quiet=False):
|
def process_queue(q, quiet=False):
|
||||||
if not quiet:
|
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:
|
if q.socks_proxy_type and q.socks_proxy_host and q.socks_proxy_port:
|
||||||
try:
|
try:
|
||||||
@ -290,7 +291,7 @@ def ticket_from_message(message, queue, quiet):
|
|||||||
f.save()
|
f.save()
|
||||||
|
|
||||||
if not quiet:
|
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:
|
for file in files:
|
||||||
if file['content']:
|
if file['content']:
|
||||||
@ -305,7 +306,7 @@ def ticket_from_message(message, queue, quiet):
|
|||||||
a.file.save(filename, ContentFile(file['content']), save=False)
|
a.file.save(filename, ContentFile(file['content']), save=False)
|
||||||
a.save()
|
a.save()
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print " - %s" % filename
|
print(" - %s" % filename)
|
||||||
|
|
||||||
|
|
||||||
context = safe_template_context(t)
|
context = safe_template_context(t)
|
||||||
|
17
setup.py
17
setup.py
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from distutils.util import convert_path
|
from distutils.util import convert_path
|
||||||
@ -63,9 +65,11 @@ def find_package_data(
|
|||||||
or fn.lower() == pattern.lower()):
|
or fn.lower() == pattern.lower()):
|
||||||
bad_name = True
|
bad_name = True
|
||||||
if show_ignored:
|
if show_ignored:
|
||||||
print >> sys.stderr, (
|
print(
|
||||||
"Directory %s ignored by pattern %s"
|
"Directory %s ignored by pattern %s" % (fn, pattern),
|
||||||
% (fn, pattern))
|
file=sys.stderr
|
||||||
|
)
|
||||||
|
|
||||||
break
|
break
|
||||||
if bad_name:
|
if bad_name:
|
||||||
continue
|
continue
|
||||||
@ -86,9 +90,10 @@ def find_package_data(
|
|||||||
or fn.lower() == pattern.lower()):
|
or fn.lower() == pattern.lower()):
|
||||||
bad_name = True
|
bad_name = True
|
||||||
if show_ignored:
|
if show_ignored:
|
||||||
print >> sys.stderr, (
|
print(
|
||||||
"File %s ignored by pattern %s"
|
"File %s ignored by pattern %s" % (fn, pattern),
|
||||||
% (fn, pattern))
|
file=sys.stderr
|
||||||
|
)
|
||||||
break
|
break
|
||||||
if bad_name:
|
if bad_name:
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user