More Python 3 fixes for scripts (bug #1134092).
This commit is contained in:
parent
71c633e3d9
commit
e67195d0fc
@ -111,6 +111,9 @@ def get_driver_version():
|
||||
except OSError:
|
||||
return None
|
||||
|
||||
if stdout != None:
|
||||
stdout = stdout.decode ()
|
||||
|
||||
return stdout
|
||||
|
||||
stdout = run_with_arg ("org.gutenprint.extensions")
|
||||
@ -268,7 +271,7 @@ def update_ppd (ppd_source_filename):
|
||||
ppd_dest_filename = "%s/%s" % (ppd_out_dir,
|
||||
os.path.basename (ppd_dest_filename))
|
||||
|
||||
orig = io.FileIO (ppd_source_filename)
|
||||
orig = open (ppd_source_filename, encoding="utf-8")
|
||||
orig_metadata = os.fstat (orig.fileno ())
|
||||
if debug & 1:
|
||||
print ("Source Filename: %s" % ppd_source_filename)
|
||||
@ -596,7 +599,7 @@ def update_ppd (ppd_source_filename):
|
||||
# Write new PPD...
|
||||
tmpnew = "%s.new" % ppd_dest_filename
|
||||
try:
|
||||
newppd = io.FileIO (tmpnew, "w")
|
||||
newppd = open (tmpnew, "w")
|
||||
except IOError as err:
|
||||
(e, s) = err.args
|
||||
print ("Can't create %s: %s" % (tmpnew, s))
|
||||
@ -774,10 +777,11 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
||||
stderr=subprocess.DEVNULL)
|
||||
server_multicat_initialized = mc_proc
|
||||
|
||||
print ("%s" % url, file=server_multicat_initialized.stdin)
|
||||
server_multicat_initialized.stdin.flush ()
|
||||
mc_in = io.TextIOWrapper (server_multicat_initialized.stdin)
|
||||
print ("%s" % url, file=mc_in)
|
||||
mc_in.flush ()
|
||||
return (new_ppd_filename,
|
||||
server_multicat_initialized.stdout)
|
||||
io.TextIOWrapper (server_multicat_initialized.stdout))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
@ -787,7 +791,7 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL)
|
||||
return (new_ppd_filename, proc.stdout)
|
||||
return (new_ppd_filename, io.TextIOWrapper (proc.stdout))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
@ -821,9 +825,9 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
||||
print ("can't open for decompression: %s" % s)
|
||||
sys.exit (1)
|
||||
|
||||
return (new_ppd_filename, proc.stdout)
|
||||
return (new_ppd_filename, io.TextIOWrapper (proc.stdout))
|
||||
else:
|
||||
return (new_ppd_filename, io.FileIO (new_ppd_filename))
|
||||
return (new_ppd_filename, open (new_ppd_filename))
|
||||
|
||||
def find_ppd (gutenprintfilename, drivername, lang, region):
|
||||
global file_version
|
||||
@ -909,7 +913,7 @@ def find_ppd (gutenprintfilename, drivername, lang, region):
|
||||
new_file_version = ""
|
||||
else:
|
||||
(stdin, stderr) = p.communicate ()
|
||||
new_file_version = stdin.rstrip ()
|
||||
new_file_version = stdin.decode ().rstrip ()
|
||||
|
||||
if new_file_version != "":
|
||||
if debug & 8:
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
import sys
|
||||
import glob
|
||||
import io
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
@ -46,7 +45,8 @@ def generate_ppd (ppdfile, printer, driver):
|
||||
(ppd, stderr) = p.communicate ()
|
||||
fname = ppdfile + ".tmp"
|
||||
try:
|
||||
io.FileIO (fname, "w").write (ppd)
|
||||
with open (fname, "w") as f:
|
||||
f.write (ppd)
|
||||
except IOError as e:
|
||||
print (e)
|
||||
raise
|
||||
@ -129,8 +129,8 @@ def update_ppdfile (ppdfile):
|
||||
if ps:
|
||||
update_options ([ps], genppd, ppd)
|
||||
|
||||
f = io.FileIO (ppdfile, "w")
|
||||
genppd.writeFd (f.fileno ())
|
||||
with open (ppdfile, "w") as f:
|
||||
genppd.writeFd (f.fileno ())
|
||||
print ("Updated PPD file %s" % ppdfile)
|
||||
|
||||
for ppdfile in glob.glob ("/etc/cups/ppd/*.ppd"):
|
||||
|
@ -3,7 +3,7 @@
|
||||
Name: gutenprint
|
||||
Summary: Printer Drivers Package
|
||||
Version: 5.2.10
|
||||
Release: 7%{?dist}
|
||||
Release: 8%{?dist}
|
||||
URL: http://gimp-print.sourceforge.net/
|
||||
Source0: http://downloads.sourceforge.net/gimp-print/%{name}-%{version}.tar.bz2
|
||||
# Post-install script to update foomatic PPDs.
|
||||
@ -281,6 +281,9 @@ fi
|
||||
/bin/rm -f /var/cache/foomatic/*
|
||||
|
||||
%changelog
|
||||
* Fri Aug 29 2014 Tim Waugh <twaugh@redhat.com> - 5.2.10-8
|
||||
- More Python 3 fixes for scripts (bug #1134092).
|
||||
|
||||
* Fri Aug 22 2014 Tim Waugh <twaugh@redhat.com> - 5.2.10-7
|
||||
- Python 3 fixes for scripts (bug #1132924).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user