Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.1:Rings:1-MinimalX
python-pycups
revert-postscriptdriver.prov-py3.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File revert-postscriptdriver.prov-py3.patch of Package python-pycups
From: BenoƮt Monin <benoit.monin@gmx.fr> Date: Sun, 8 Mar 2015 13:14:03 +0100 Subject: [PATCH] Revert "Converted postscriptdriver.prov to Python3." Upstream: no This reverts commit 83d0ee6cbafbc7f9abec72d4062643d51fe37974. Upstream switched to python3 but we're building a pyhon2 package, so revert. --- postscriptdriver.prov | 64 ++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/postscriptdriver.prov b/postscriptdriver.prov index 21c1116..7bf74b1 100755 --- a/postscriptdriver.prov +++ b/postscriptdriver.prov @@ -1,6 +1,6 @@ -#!/usr/bin/python3 +#!/usr/bin/python -## Copyright (C) 2009, 2010, 2014 Red Hat, Inc. +## Copyright (C) 2009, 2010 Red Hat, Inc. ## Author: Tim Waugh <twaugh@redhat.com> ## This program is free software; you can redistribute it and/or modify @@ -54,7 +54,7 @@ class DeviceIDs: def get_tags (self): ret = [] - for mfg, mdlset in self.ids.items (): + for mfg, mdlset in self.ids.iteritems (): mfgl = mfg.lower ().replace (" ", "_") for mdl in mdlset: mdll = mdl.lower ().replace (" ", "_") @@ -65,7 +65,7 @@ class DeviceIDs: def __add__ (self, other): if isinstance(other, DeviceIDs): - for omfg, omdlset in other.ids.items (): + for omfg, omdlset in other.ids.iteritems (): try: mdlset = self.ids[omfg] except KeyError: @@ -121,7 +121,7 @@ class PPDDriver(Driver): def examine_file (self, path): try: ppd = cups.PPD (path) - except RuntimeError: + except RuntimeError, e: # Not a PPD file. Perhaps it's a drv file. drv = DrvDriver (path) self.ids += drv.list () @@ -164,16 +164,16 @@ class DynamicDriver(Driver): posix.kill (p.pid, signal.SIGKILL) raise - if stderr: - print(stderr.decode (), file=sys.stderr) + if stderr: + print >> sys.stderr, stderr - ppds = [] - lines = stdout.decode ().split ('\n') - for line in lines: - l = shlex.split (line) - if len (l) < 5: - continue - self.ids += l[4] + ppds = [] + lines = stdout.split ('\n') + for line in lines: + l = shlex.split (line) + if len (l) < 5: + continue + self.ids += l[4] return Driver.list (self) @@ -211,35 +211,22 @@ class DrvDriver(PPDDriver): posix.kill (p.pid, signal.SIGKILL) raise - for (dirpath, dirnames, filenames) in os.walk (outputdir, - topdown=False): - for filename in filenames: - path = dirpath + os.path.sep + filename - self.examine_file (path) - try: - os.unlink (path) - except OSError: - pass - - for dirname in dirnames: - try: - os.rmdir (dirpath + os.paht.sep + dirname) - except OSError: - pass - - try: - os.rmdir (outputdir) - except OSError: - pass - + os.path.walk (outputdir, self.examine_directory, None) + os.rmdir (outputdir) return Driver.list (self) + def examine_directory (self, unused, dirname, fnames): + for fname in fnames: + path = dirname + os.path.sep + fname + self.examine_file (path) + os.unlink (path) + class TagBuilder: def __init__ (self, filelist=None): if filelist == None: filelist = sys.stdin - paths = [x.rstrip () for x in filelist.readlines ()] + paths = map (lambda x: x.rstrip (), filelist.readlines ()) self.ids = DeviceIDs () for path in paths: @@ -248,8 +235,7 @@ class TagBuilder: self.ids += DynamicDriver (path).list () except TimedOut: pass - except OSError as exc: - (e, s) = exc.args + except OSError, (e, s): if e == errno.EACCES or e == errno.ENOENT: # Not executable pass @@ -270,4 +256,4 @@ if __name__ == "__main__": builder = TagBuilder () tags = builder.get_tags () for tag in tags: - print (tag) + print tag
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor