Debian Codegraph @

troubleshoot/QueueRejectingJobs.py

raw
1 #!/usr/bin/python3
2
3 ## Printing troubleshooter
4
5 ## Copyright (C) 2008, 2009 Red Hat, Inc.
6 ## Copyright (C) 2008, 2009 Tim Waugh <[email protected]>
7
8 ## This program is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12
13 ## This program is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ## GNU General Public License for more details.
17
18 ## You should have received a copy of the GNU General Public License
19 ## along with this program; if not, write to the Free Software
20 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
22 from gi.repository import Gtk
23
24 import cups
25 from .base import *
26 class QueueRejectingJobs(Question):
27 def __init__ (self, troubleshooter):
28 Question.__init__ (self, troubleshooter, "Queue rejecting jobs?")
29 solution = Gtk.VBox ()
30 solution.set_border_width (12)
31 solution.set_spacing (12)
32 label = Gtk.Label(label='<span weight="bold" size="larger">' +
33 _("Queue Rejecting Jobs") + '</span>')
34 label.set_alignment (0, 0)
35 label.set_use_markup (True)
36 solution.pack_start (label, False, False, 0)
37 self.label = Gtk.Label ()
38 self.label.set_alignment (0, 0)
39 self.label.set_line_wrap (True)
40 solution.pack_start (self.label, False, False, 0)
41 solution.set_border_width (12)
42
43 troubleshooter.new_page (solution, self)
44
45 def display (self):
46 answers = self.troubleshooter.answers
47 if not answers['cups_queue_listed']:
48 return False
49
50 if answers['is_cups_class']:
51 queue = answers['cups_class_dict']
52 else:
53 queue = answers['cups_printer_dict']
54
55 rejecting = queue['printer-type'] & cups.CUPS_PRINTER_REJECTING
56 if not rejecting:
57 return False
58
59 if answers['cups_printer_remote']:
60 attrs = answers['remote_cups_queue_attributes']
61 reason = attrs['printer-state-message']
62 else:
63 reason = queue['printer-state-message']
64
65 text = (_("The queue '%s' is rejecting jobs.") % answers['cups_queue'])
66
67 if reason:
68 text += ' ' + _("The reason given is: '%s'.") % reason
69
70 if not answers['cups_printer_remote']:
71 text += "\n\n"
72 text += _("To make the queue accept jobs, select the "
73 "'Accepting Jobs' checkbox in the 'Policies' "
74 "tab for the printer in the printer administration "
75 "tool.") + ' ' + _(TEXT_start_print_admin_tool)
76
77 self.label.set_text (text)
78 return True
79
80 def can_click_forward (self):
81 return False