~ubuntu-branches/ubuntu/wily/system-config-printer/wily

« back to all changes in this revision

Viewing changes to troubleshoot/ChoosePrinter.py

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2014-08-05 23:59:59 UTC
  • mfrom: (256.1.1 utopic-proposed)
  • Revision ID: package-import@ubuntu.com-20140805235959-v1yzis5mo1nkxo2m
Tags: 1.5.0+20140805-0ubuntu2
debian/control: Build-depend on Python 3 (python3-all-dev).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
 
1
#!/usr/bin/python3
2
2
 
3
3
## Printing troubleshooter
4
4
 
29
29
import cups
30
30
from gi.repository import GObject
31
31
from timedops import TimedOperation
32
 
from base import *
 
32
from .base import *
33
33
class ChoosePrinter(Question):
34
34
    def __init__ (self, troubleshooter):
35
35
        # First question: which printer? (page 1)
77
77
            dests = self.timedop (c.getDests, parent=parent).run ()
78
78
            printers = None
79
79
            dests_list = []
80
 
            for (name, instance), dest in dests.iteritems ():
 
80
            for (name, instance), dest in dests.items ():
81
81
                if name == None:
82
82
                    continue
83
83
 
90
90
                    printers = self.timedop (c.getPrinters,
91
91
                                             parent=parent).run ()
92
92
 
93
 
                if not printers.has_key (name):
 
93
                if name not in printers:
94
94
                    info = _("Unknown")
95
95
                    location = _("Unknown")
96
96
                else:
100
100
 
101
101
                dests_list.append ((queue, location, info, dest))
102
102
 
103
 
            dests_list.sort (lambda x, y: cmp (x[0], y[0]))
 
103
            dests_list.sort (key=lambda x: x[0])
104
104
            for queue, location, info, dest in dests_list:
105
105
                iter = model.append (None)
106
106
                model.set (iter, 0, queue, 1, location, 2, info, 3, dest)
138
138
                def each (self, model, path, iter, user_data):
139
139
                    dest = model.get_value (iter, 3)
140
140
                    if dest != NotListed:
141
 
                        self.dests.append ((dest.name.decode ('utf-8') if
142
 
                                             isinstance(dest.name, bytes) else
143
 
                                             dest.name,
 
141
                        self.dests.append ((dest.name,
144
142
                                            dest.instance))
145
143
 
146
144
            return { 'cups_queue_listed': False,
148
146
        else:
149
147
            return { 'cups_queue_listed': True,
150
148
                     'cups_dest': dest,
151
 
                     'cups_queue': dest.name.decode ('utf-8') if
152
 
                                    isinstance(dest.name, bytes) else
153
 
                                    dest.name,
 
149
                     'cups_queue': dest.name,
154
150
                     'cups_instance': dest.instance }
155
151
 
156
152
    def cancel_operation (self):