parent
d83ffaebf2
commit
ce129d3443
@ -2,7 +2,7 @@
|
||||
# $Id$
|
||||
# Update CUPS PPDs for Gutenprint queues.
|
||||
# Copyright (C) 2002-2003 Roger Leigh (rleigh@debian.org)
|
||||
# Copyright (C) 2009, 2011 Red Hat, Inc.
|
||||
# Copyright (C) 2009, 2011, 2014 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
import getopt
|
||||
import glob
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import stat
|
||||
@ -60,7 +61,7 @@ global ppd_files
|
||||
global languagemappings
|
||||
|
||||
def help():
|
||||
print("""
|
||||
print ("""
|
||||
Usage: %s [OPTION]... [PPD_FILE]...
|
||||
Update CUPS+Gutenprint PPD files.
|
||||
|
||||
@ -92,7 +93,7 @@ def die_if_not_directory (dir):
|
||||
os.chdir (dir)
|
||||
except OSError as err:
|
||||
(e, s) = err.args
|
||||
print("%s: invalid directory: %s" % (dir, s))
|
||||
print ("%s: invalid directory: %s" % (dir, s))
|
||||
sys.exit (1)
|
||||
|
||||
def get_driver_version():
|
||||
@ -102,9 +103,9 @@ def get_driver_version():
|
||||
def run_with_arg (arg):
|
||||
try:
|
||||
p = subprocess.Popen ([driver_bin, arg],
|
||||
stdin=file("/dev/null"),
|
||||
stdin=io.FileIO("/dev/null"),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=file("/dev/null", "w"),
|
||||
stderr=io.FileIO("/dev/null", "w"),
|
||||
shell=False)
|
||||
(stdout, stderr) = p.communicate ()
|
||||
except OSError:
|
||||
@ -205,7 +206,8 @@ def parse_options():
|
||||
use_static_ppd = "no"
|
||||
file_version = "\"%s\"$" % driver_version
|
||||
else:
|
||||
print("Gutenprint %s does not appear to be installed!" % version)
|
||||
print ("Gutenprint %s does not appear to be installed!" %
|
||||
version)
|
||||
sys.exit (1)
|
||||
|
||||
if 's' in optargs:
|
||||
@ -229,7 +231,7 @@ def parse_options():
|
||||
get_driver_version ()
|
||||
use_static_ppd = "no"
|
||||
else:
|
||||
print("%s: invalid executable" % opt_P)
|
||||
print ("%s: invalid executable" % opt_P)
|
||||
|
||||
if 'h' in optargs:
|
||||
help ()
|
||||
@ -237,7 +239,7 @@ def parse_options():
|
||||
if ('l' in optargs and
|
||||
optargs['l'].lower () != "original" and
|
||||
optargs['l'].lower () not in languages):
|
||||
print("Unknown language '%s'" % optargs['l'], file=sys.stderr)
|
||||
print ("Unknown language '%s'" % optargs['l'], file=sys.stderr)
|
||||
|
||||
if 'i' in optargs:
|
||||
interactive = 1
|
||||
@ -246,7 +248,7 @@ def parse_options():
|
||||
sys.exit (0)
|
||||
|
||||
if verbose and driver_version != "":
|
||||
print("Updating PPD files from Gutenprint %s" % driver_version)
|
||||
print ("Updating PPD files from Gutenprint %s" % driver_version)
|
||||
|
||||
return args
|
||||
|
||||
@ -266,10 +268,10 @@ def update_ppd (ppd_source_filename):
|
||||
ppd_dest_filename = "%s/%s" % (ppd_out_dir,
|
||||
os.path.basename (ppd_dest_filename))
|
||||
|
||||
orig = file (ppd_source_filename)
|
||||
orig = io.FileIO (ppd_source_filename)
|
||||
orig_metadata = os.fstat (orig.fileno ())
|
||||
if debug & 1:
|
||||
print("Source Filename: %s" % ppd_source_filename)
|
||||
print ("Source Filename: %s" % ppd_source_filename)
|
||||
|
||||
filename = ""
|
||||
driver = ""
|
||||
@ -325,8 +327,8 @@ def update_ppd (ppd_source_filename):
|
||||
break
|
||||
|
||||
if not valid:
|
||||
#print >>sys.stderr, ("Skipping %s: not a Gutenprint PPD file" %
|
||||
# ppd_source_filename)
|
||||
#print (("Skipping %s: not a Gutenprint PPD file" %
|
||||
# ppd_source_filename), file=sys.stderr)
|
||||
return -1
|
||||
|
||||
if ('l' in optargs and
|
||||
@ -336,14 +338,14 @@ def update_ppd (ppd_source_filename):
|
||||
orig_locale = locale
|
||||
|
||||
if debug & 2:
|
||||
print("Gutenprint Filename: %s" % filename)
|
||||
print ("Gutenprint Filename: %s" % filename)
|
||||
if 'l' in optargs:
|
||||
print("Locale: %s (from -l)" % locale)
|
||||
print ("Locale: %s (from -l)" % locale)
|
||||
else:
|
||||
print("Locale: %s" % locale)
|
||||
print ("Locale: %s" % locale)
|
||||
|
||||
print("Language: %s" % lingo)
|
||||
print("Driver: %s" % driver)
|
||||
print ("Language: %s" % lingo)
|
||||
print ("Driver: %s" % driver)
|
||||
|
||||
if locale:
|
||||
# Split into the language and territory.
|
||||
@ -366,8 +368,8 @@ def update_ppd (ppd_source_filename):
|
||||
locale = languagemappings.get (lingo.lower (), "C")
|
||||
|
||||
if debug & 2:
|
||||
print("Base Locale: %s" % locale)
|
||||
print("Region: %s" % region)
|
||||
print ("Base Locale: %s" % locale)
|
||||
print ("Region: %s" % region)
|
||||
|
||||
# Read in the new PPD, decompressing it if needed...
|
||||
(new_ppd_filename, source_fd) = get_ppd_fh (ppd_source_filename,
|
||||
@ -376,7 +378,7 @@ def update_ppd (ppd_source_filename):
|
||||
locale,
|
||||
region)
|
||||
if source_fd == None:
|
||||
print("Unable to retrieve PPD file!")
|
||||
print ("Unable to retrieve PPD file!")
|
||||
return 0
|
||||
|
||||
if interactive:
|
||||
@ -386,13 +388,13 @@ def update_ppd (ppd_source_filename):
|
||||
if not server_multicat:
|
||||
source_fd.close ()
|
||||
|
||||
print("Skipping all...")
|
||||
print ("Skipping all...")
|
||||
return -2
|
||||
elif not inp.startswith ("y"):
|
||||
if not server_multicat:
|
||||
source_fd.close ()
|
||||
|
||||
print("Skipping...")
|
||||
print ("Skipping...")
|
||||
return -1
|
||||
|
||||
# Extract the default values from the original PPD...
|
||||
@ -433,7 +435,7 @@ def update_ppd (ppd_source_filename):
|
||||
source_data += line + "\n"
|
||||
|
||||
if debug & 4:
|
||||
print("Options (Old->New Default Type):")
|
||||
print ("Options (Old->New Default Type):")
|
||||
keys = list(options.keys ())
|
||||
keys.sort ()
|
||||
for t in keys:
|
||||
@ -451,23 +453,23 @@ def update_ppd (ppd_source_filename):
|
||||
|
||||
out += "%s " % opt
|
||||
|
||||
print(out)
|
||||
print (out)
|
||||
|
||||
if len (list(resolution_map.keys ())) > 0:
|
||||
print("Resolution Map:")
|
||||
print ("Resolution Map:")
|
||||
keys = list(resolution_map.keys ())
|
||||
keys.sort ()
|
||||
for key in keys:
|
||||
print(" %s: %s" % (key, resolution_map[key]))
|
||||
print (" %s: %s" % (key, resolution_map[key]))
|
||||
|
||||
if len (list(old_resolution_map.keys ())) > 0:
|
||||
print("Old Resolution Map:")
|
||||
print ("Old Resolution Map:")
|
||||
keys = list(old_resolution_map.keys ())
|
||||
keys.sort ()
|
||||
for key in keys:
|
||||
print(" %s: %s" % (key, old_resolution_map[key]))
|
||||
print (" %s: %s" % (key, old_resolution_map[key]))
|
||||
|
||||
print("Non-UI Defaults:")
|
||||
print ("Non-UI Defaults:")
|
||||
keys = list(defaults.keys ())
|
||||
keys.sort ()
|
||||
for key in keys:
|
||||
@ -475,24 +477,24 @@ def update_ppd (ppd_source_filename):
|
||||
if xkey.startswith ("Default"):
|
||||
xkey = xkey[7:]
|
||||
if xkey not in options:
|
||||
print(" %s: %s" % (key, defaults[key]))
|
||||
print (" %s: %s" % (key, defaults[key]))
|
||||
|
||||
print("Default Types of dropped options:")
|
||||
print ("Default Types of dropped options:")
|
||||
keys = list(orig_default_types.keys ())
|
||||
keys.sort ()
|
||||
for t in keys:
|
||||
if t not in options:
|
||||
print(" %s: %s" % (t, orig_default_types[t]))
|
||||
print (" %s: %s" % (t, orig_default_types[t]))
|
||||
|
||||
if no_action:
|
||||
if not quiet or verbose:
|
||||
if ppd_dest_filename == ppd_source_filename:
|
||||
print("Would update %s using %s" % (ppd_source_filename,
|
||||
new_ppd_filename))
|
||||
print ("Would update %s using %s" % (ppd_source_filename,
|
||||
new_ppd_filename))
|
||||
else:
|
||||
print("Would update %s to %s using %s" % (ppd_source_filename,
|
||||
ppd_dest_filename,
|
||||
new_ppd_filename))
|
||||
print ("Would update %s to %s using %s" % (ppd_source_filename,
|
||||
ppd_dest_filename,
|
||||
new_ppd_filename))
|
||||
|
||||
return 0
|
||||
|
||||
@ -520,9 +522,9 @@ def update_ppd (ppd_source_filename):
|
||||
if (new_default != None and
|
||||
default_option_value == new_default):
|
||||
if verbose:
|
||||
print("%s: Preserve *%s (%s)" % (ppd_source_filename,
|
||||
default_option,
|
||||
default_option_value))
|
||||
print ("%s: Preserve *%s (%s)" % (ppd_source_filename,
|
||||
default_option,
|
||||
default_option_value))
|
||||
|
||||
continue
|
||||
|
||||
@ -536,8 +538,8 @@ def update_ppd (ppd_source_filename):
|
||||
if (option == "Resolution" and
|
||||
def_option in old_resolution_map):
|
||||
if debug & 4:
|
||||
print(("Intermapping old resolution %s to %s" %
|
||||
def_option, old_resolution_map[def_option]))
|
||||
print (("Intermapping old resolution %s to %s" %
|
||||
def_option, old_resolution_map[def_option]))
|
||||
|
||||
def_option = old_resolution_map[def_option]
|
||||
|
||||
@ -569,9 +571,10 @@ def update_ppd (ppd_source_filename):
|
||||
source_data += line + "\n"
|
||||
|
||||
if verbose:
|
||||
print("%s: Set *%s to %s" % (ppd_source_filename,
|
||||
default_option,
|
||||
dopt))
|
||||
print ("%s: Set *%s to %s" %
|
||||
(ppd_source_filename,
|
||||
default_option,
|
||||
dopt))
|
||||
|
||||
next_default = True
|
||||
break
|
||||
@ -581,22 +584,22 @@ def update_ppd (ppd_source_filename):
|
||||
if next_default:
|
||||
continue
|
||||
|
||||
print(("Warning: %s: Invalid option: *%s: %s. Using default "
|
||||
"setting %s." % (ppd_source_filename, default_option,
|
||||
defaults[default_option],
|
||||
new_defaults[default_option])))
|
||||
print (("Warning: %s: Invalid option: *%s: %s. Using default "
|
||||
"setting %s." % (ppd_source_filename, default_option,
|
||||
defaults[default_option],
|
||||
new_defaults[default_option])))
|
||||
continue
|
||||
|
||||
print(("Warning: %s: PPD OpenUI method %s not understood." %
|
||||
(ppd_source_filename, new_default_types[default_option])))
|
||||
print (("Warning: %s: PPD OpenUI method %s not understood." %
|
||||
(ppd_source_filename, new_default_types[default_option])))
|
||||
|
||||
# Write new PPD...
|
||||
tmpnew = "%s.new" % ppd_dest_filename
|
||||
try:
|
||||
newppd = file (tmpnew, "w")
|
||||
newppd = io.FileIO (tmpnew, "w")
|
||||
except IOError as err:
|
||||
(e, s) = err.args
|
||||
print("Can't create %s: %s" % (tmpnew, s))
|
||||
print ("Can't create %s: %s" % (tmpnew, s))
|
||||
return 0
|
||||
|
||||
newppd.writelines (source_data)
|
||||
@ -604,13 +607,13 @@ def update_ppd (ppd_source_filename):
|
||||
newppd.close ()
|
||||
except IOError as err:
|
||||
(e, s) = err.args
|
||||
print("Can't write to %s: %s" % (tmpnew, s))
|
||||
print ("Can't write to %s: %s" % (tmpnew, s))
|
||||
return 0
|
||||
|
||||
chcon = subprocess.Popen (["chcon", "--reference=%s" % ppd_dest_filename,
|
||||
tmpnew], shell=False,
|
||||
stdin=file("/dev/null"),
|
||||
stdout=file("/dev/null", "w"),
|
||||
stdin=io.FileIO("/dev/null"),
|
||||
stdout=io.FileIO("/dev/null", "w"),
|
||||
stderr=subprocess.STDOUT)
|
||||
chcon.communicate ()
|
||||
|
||||
@ -618,7 +621,7 @@ def update_ppd (ppd_source_filename):
|
||||
os.rename (tmpnew, ppd_dest_filename)
|
||||
except OSError as err:
|
||||
(e, s) = err.args
|
||||
print("Can't rename %s to %s: %s" % (tmpnew, ppd_dest_filename, s))
|
||||
print ("Can't rename %s to %s: %s" % (tmpnew, ppd_dest_filename, s))
|
||||
try:
|
||||
os.unlink (tmpnew)
|
||||
except OSError:
|
||||
@ -641,12 +644,12 @@ def update_ppd (ppd_source_filename):
|
||||
|
||||
if not quiet or verbose:
|
||||
if ppd_dest_filename == ppd_source_filename:
|
||||
print("Updated %s using %s" % (ppd_source_filename,
|
||||
new_ppd_filename))
|
||||
print ("Updated %s using %s" % (ppd_source_filename,
|
||||
new_ppd_filename))
|
||||
else:
|
||||
print("Updated %s to %s using %s" % (ppd_source_filename,
|
||||
ppd_dest_filename,
|
||||
new_ppd_filename))
|
||||
print ("Updated %s to %s using %s" % (ppd_source_filename,
|
||||
ppd_dest_filename,
|
||||
new_ppd_filename))
|
||||
|
||||
# All done!
|
||||
return 1
|
||||
@ -757,8 +760,8 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
||||
else:
|
||||
cat = "%s cat " % driver_bin
|
||||
|
||||
print(("Trying %s%s for %s, %s, %s, %s" %
|
||||
(cat, url, driver, simplified, locale, region)))
|
||||
print (("Trying %s%s for %s, %s, %s, %s" %
|
||||
(cat, url, driver, simplified, locale, region)))
|
||||
|
||||
if server_multicat:
|
||||
try:
|
||||
@ -768,11 +771,11 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
||||
shell=False,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=file("/dev/null",
|
||||
"w"))
|
||||
stderr=io.FileIO("/dev/null",
|
||||
"w"))
|
||||
server_multicat_initialized = mc_proc
|
||||
|
||||
print("%s" % url, file=server_multicat_initialized.stdin)
|
||||
print ("%s" % url, file=server_multicat_initialized.stdin)
|
||||
server_multicat_initialized.stdin.flush ()
|
||||
return (new_ppd_filename,
|
||||
server_multicat_initialized.stdout)
|
||||
@ -782,9 +785,9 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
||||
try:
|
||||
proc = subprocess.Popen ([driver_bin, "cat", url],
|
||||
shell=False,
|
||||
stdin=file("/dev/null"),
|
||||
stdin=io.FileIO("/dev/null"),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=file("/dev/null", "w"))
|
||||
stderr=io.FileIO("/dev/null", "w"))
|
||||
return (new_ppd_filename, proc.stdout)
|
||||
except OSError:
|
||||
pass
|
||||
@ -796,14 +799,14 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
||||
new_ppd_filename = find_ppd (filename, driver, locale, region)
|
||||
if not new_ppd_filename:
|
||||
# There wasn't a valid source PPD file, so give up.
|
||||
print(("%s: no valid candidate for replacement. "
|
||||
"Skipping" % ppd_source_filename), file=sys.stderr)
|
||||
print(("%s: please upgrade this PPD manually" %
|
||||
ppd_source_filename), file=sys.stderr)
|
||||
print (("%s: no valid candidate for replacement. Skipping" %
|
||||
ppd_source_filename), file=sys.stderr)
|
||||
print (("%s: please upgrade this PPD manually" %
|
||||
ppd_source_filename), file=sys.stderr)
|
||||
return ("", None)
|
||||
|
||||
if debug & 1:
|
||||
print("Candidate PPD: %s" % new_ppd_filename)
|
||||
print ("Candidate PPD: %s" % new_ppd_filename)
|
||||
|
||||
suffix = "\\" + gzext # Add '\' so the regexp matches the '.'
|
||||
if new_ppd_filename.endswith (".gz"):
|
||||
@ -811,17 +814,17 @@ def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
|
||||
try:
|
||||
proc = subprocess.Popen (['gunzip', '-c', new_ppd_filename],
|
||||
shell=False,
|
||||
stdin=file("/dev/null"),
|
||||
stdin=io.FileIO("/dev/null"),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=file("/dev/null", "w"))
|
||||
stderr=io.FileIO("/dev/null", "w"))
|
||||
except OSError as err:
|
||||
(e, s) = err.args
|
||||
print("can't open for decompression: %s" % s)
|
||||
print ("can't open for decompression: %s" % s)
|
||||
sys.exit (1)
|
||||
|
||||
return (new_ppd_filename, proc.stdout)
|
||||
else:
|
||||
return (new_ppd_filename, file (new_ppd_filename))
|
||||
return (new_ppd_filename, io.FileIO (new_ppd_filename))
|
||||
|
||||
def find_ppd (gutenprintfilename, drivername, lang, region):
|
||||
global file_version
|
||||
@ -880,8 +883,8 @@ def find_ppd (gutenprintfilename, drivername, lang, region):
|
||||
|
||||
fn = "%s/%s%s%s" % (basedir, lingo, base, suffix)
|
||||
if debug & 8:
|
||||
print(("Trying %s for %s, %s, %s" %
|
||||
(fn, gutenprintfilename, lang, region)))
|
||||
print (("Trying %s for %s, %s, %s" %
|
||||
(fn, gutenprintfilename, lang, region)))
|
||||
|
||||
try:
|
||||
st = os.stat (fn)
|
||||
@ -900,9 +903,10 @@ def find_ppd (gutenprintfilename, drivername, lang, region):
|
||||
|
||||
try:
|
||||
p = subprocess.Popen (cmdline,
|
||||
stdin=file("/dev/null"),
|
||||
stdin=io.FileIO("/dev/null"),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=file("/dev/null", "w"))
|
||||
stderr=io.FileIO("/dev/null",
|
||||
"w"))
|
||||
except OSError:
|
||||
new_file_version = ""
|
||||
else:
|
||||
@ -911,25 +915,26 @@ def find_ppd (gutenprintfilename, drivername, lang, region):
|
||||
|
||||
if new_file_version != "":
|
||||
if debug & 8:
|
||||
print((" Format valid: time %s best %s "
|
||||
"prev %s cur %s!" %
|
||||
(st.st_mtime, current_best_time,
|
||||
current_best_file, fn)))
|
||||
print ((" Format valid: time %s best %s "
|
||||
"prev %s cur %s!" %
|
||||
(st.st_mtime, current_best_time,
|
||||
current_best_file, fn)))
|
||||
|
||||
if st.st_mtime > current_best_time:
|
||||
current_best_time = st.st_mtime
|
||||
current_best_file = fn
|
||||
if debug & 8:
|
||||
print(("***current_best_file "
|
||||
" is %s" % fn), file=sys.stderr)
|
||||
print (("***current_best_file "
|
||||
" is %s" % fn), file=sys.stderr)
|
||||
elif debug & 8:
|
||||
print(" Format invalid")
|
||||
print (" Format invalid")
|
||||
else:
|
||||
if (not stat.S_ISDIR (st.st_mode) and
|
||||
not fn.endswith ("/")):
|
||||
print(("%s: not a regular file, "
|
||||
"or insecure ownership and "
|
||||
"permissions. Skipped" % fn), file=sys.stderr)
|
||||
print (("%s: not a regular file, "
|
||||
"or insecure ownership and "
|
||||
"permissions. Skipped" % fn),
|
||||
file=sys.stderr)
|
||||
|
||||
if current_best_file:
|
||||
return current_best_file
|
||||
@ -1012,8 +1017,8 @@ for f in args:
|
||||
elif os.access ("%s/%s.PPD" % (ppd_dir, f), os.F_OK):
|
||||
ppd_files.append ("%s/%s.PPD" % (ppd_dir, f))
|
||||
else:
|
||||
print(("Cannot find file %s/%s, %s/%s.ppd, or %s/%s.PPD" %
|
||||
ppd_dir, f, ppd_dir, f, ppd_dir, f), file=sys.stderr)
|
||||
print (("Cannot find file %s/%s, %s/%s.ppd, or %s/%s.PPD" %
|
||||
ppd_dir, f, ppd_dir, f, ppd_dir, f), file=sys.stderr)
|
||||
|
||||
if len (args) == 0:
|
||||
ppdtmp = glob.glob ("%s/*.ppd" % ppd_dir)
|
||||
@ -1045,20 +1050,20 @@ for ppd_file in ppd_files:
|
||||
|
||||
if (not quiet) or verbose:
|
||||
if len (ppd_files) == 0:
|
||||
print("No Gutenprint PPD files to update.")
|
||||
print ("No Gutenprint PPD files to update.")
|
||||
elif updated_ppd_count > 0:
|
||||
plural = ""
|
||||
if updated_ppd_count != 1:
|
||||
plural = "s"
|
||||
|
||||
print("Updated %d PPD file%s" % (updated_ppd_count, plural))
|
||||
print ("Updated %d PPD file%s" % (updated_ppd_count, plural))
|
||||
if (('o' not in optargs) or
|
||||
optargs['o'] != ""):
|
||||
print("Restart cupsd for the changes to take effect.")
|
||||
print ("Restart cupsd for the changes to take effect.")
|
||||
else:
|
||||
if failed_ppd_count > 0:
|
||||
print("Failed to update any PPD files")
|
||||
print ("Failed to update any PPD files")
|
||||
else:
|
||||
print("Did not update any PPD files")
|
||||
print ("Did not update any PPD files")
|
||||
|
||||
sys.exit (failed_ppd_count > 0)
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
## A utility for updating foomatic-generated PPDs so that they work with
|
||||
## a newly-installed gutenprint package.
|
||||
|
||||
## Copyright (C) 2007, 2009 Red Hat, Inc.
|
||||
## Copyright (C) 2007, 2009 Tim Waugh <twaugh@redhat.com
|
||||
## Copyright (C) 2007, 2009, 2014 Red Hat, Inc.
|
||||
## Author: Tim Waugh <twaugh@redhat.com
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@ -24,6 +24,7 @@
|
||||
|
||||
import sys
|
||||
import glob
|
||||
import io
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
@ -39,15 +40,15 @@ dry_run = True
|
||||
|
||||
def generate_ppd (ppdfile, printer, driver):
|
||||
p = subprocess.Popen (["foomatic-ppdfile", "-p", printer, "-d", driver],
|
||||
stdin=file ("/dev/null"),
|
||||
stdin=io.FileIO ("/dev/null"),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
(ppd, stderr) = p.communicate ()
|
||||
fname = ppdfile + ".tmp"
|
||||
try:
|
||||
file(fname, "w").write (ppd)
|
||||
io.FileIO (fname, "w").write (ppd)
|
||||
except IOError as e:
|
||||
print(e)
|
||||
print (e)
|
||||
raise
|
||||
|
||||
ppdobj = cups.PPD (fname)
|
||||
@ -67,7 +68,7 @@ def update_ppdfile (ppdfile):
|
||||
|
||||
IDs = attr.value.split (" ")
|
||||
if len (IDs) != 2:
|
||||
print("Don't understand FoomaticIDs: %s" % IDs)
|
||||
print ("Don't understand FoomaticIDs: %s" % IDs)
|
||||
return
|
||||
|
||||
if not IDs[1].startswith ("gutenprint"):
|
||||
@ -128,9 +129,9 @@ def update_ppdfile (ppdfile):
|
||||
if ps:
|
||||
update_options ([ps], genppd, ppd)
|
||||
|
||||
f = file (ppdfile, "w")
|
||||
f = io.FileIO (ppdfile, "w")
|
||||
genppd.writeFd (f.fileno ())
|
||||
print("Updated PPD file %s" % ppdfile)
|
||||
print ("Updated PPD file %s" % ppdfile)
|
||||
|
||||
for ppdfile in glob.glob ("/etc/cups/ppd/*.ppd"):
|
||||
update_ppdfile (ppdfile)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
Name: gutenprint
|
||||
Summary: Printer Drivers Package
|
||||
Version: 5.2.10
|
||||
Release: 6%{?dist}
|
||||
Release: 7%{?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 22 2014 Tim Waugh <twaugh@redhat.com> - 5.2.10-7
|
||||
- Python 3 fixes for scripts (bug #1132924).
|
||||
|
||||
* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.2.10-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user