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

« back to all changes in this revision

Viewing changes to troubleshoot/CheckUSBPermissions.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
 
24
24
import os
25
25
import subprocess
26
26
from timedops import TimedSubprocess
27
 
import urllib
28
 
from base import *
 
27
import urllib.parse
 
28
from .base import *
29
29
from gi.repository import Gtk
30
30
 
31
31
class CheckUSBPermissions(Question):
47
47
        else:
48
48
            return False
49
49
 
50
 
        (scheme, rest) = urllib.splittype (device_uri)
 
50
        (scheme, rest) = urllib.parse.splittype (device_uri)
51
51
        if scheme not in ['hp', 'hpfax', 'usb', 'hal']:
52
52
            return False
53
53
 
135
135
        paths = []
136
136
        if not scheme.startswith ('hp'):
137
137
            paths.extend (glob.glob ("/dev/usb/lp?"))
138
 
        for mfr_id, mdls in dev_by_id.iteritems ():
139
 
            for mdl_id, devs in mdls.iteritems ():
 
138
        for mfr_id, mdls in dev_by_id.items ():
 
139
            for mdl_id, devs in mdls.items ():
140
140
                for dev in devs:
141
141
                    path = "/dev/bus/usb/%s/%s" % (dev['bus'], dev['dev'])
142
142
                    paths.append (path)
153
153
                                           stdout=subprocess.PIPE,
154
154
                                           stderr=subprocess.PIPE)
155
155
                (getfacl_stdout, getfacl_stderr, result) = self.op.run ()
156
 
                output = filter (lambda x: len (x) > 0, getfacl_stdout)
 
156
                output = [x for x in getfacl_stdout if len (x) > 0]
157
157
            except:
158
158
                # Problem executing command.
159
159
                output = []