Python3 fixes from upstream.

This commit is contained in:
Tim Waugh 2014-09-11 17:21:01 +01:00
parent 5da49def1d
commit cbf665aad2
2 changed files with 227 additions and 1 deletions

View File

@ -0,0 +1,219 @@
diff -up system-config-printer-1.5.1/newprinter.py.python3 system-config-printer-1.5.1/newprinter.py
--- system-config-printer-1.5.1/newprinter.py.python3 2014-08-22 12:34:40.000000000 +0100
+++ system-config-printer-1.5.1/newprinter.py 2014-09-11 17:19:36.138730318 +0100
@@ -1803,7 +1803,7 @@ class NewPrinterGUI(GtkGUI):
return None
faxtype = -1
- for line in stdout.split ("\n"):
+ for line in stdout.decode ().split ("\n"):
if line.find ("fax-type") == -1:
continue
res = re.search ("(\d+)", line)
@@ -1834,7 +1834,7 @@ class NewPrinterGUI(GtkGUI):
# Problem executing command.
return None
- scan_type = stdout.strip ()
+ scan_type = stdout.decode ().strip ()
fields = scan_type.split ("=", 1)
if len (fields) < 2:
return None
@@ -1864,7 +1864,7 @@ class NewPrinterGUI(GtkGUI):
# Problem executing command.
return None
- uri = stdout.strip ()
+ uri = stdout.decode ().strip ()
return uri
def getNetworkPrinterMakeModel(self, host=None, device=None):
@@ -1905,7 +1905,7 @@ class NewPrinterGUI(GtkGUI):
pass
if stdout != None:
- line = stdout.strip ()
+ line = stdout.decode ().strip ()
words = probe_printer.wordsep (line)
n = len (words)
if n < 4:
@@ -3874,7 +3874,7 @@ class NewPrinterGUI(GtkGUI):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate ()
- err += stdout
+ err += stdout.decode ()
except:
# Problem executing command.
raise
diff -up system-config-printer-1.5.1/probe_printer.py.python3 system-config-printer-1.5.1/probe_printer.py
--- system-config-printer-1.5.1/probe_printer.py.python3 2014-08-22 12:20:15.000000000 +0100
+++ system-config-printer-1.5.1/probe_printer.py 2014-09-11 17:19:36.139730323 +0100
@@ -1,8 +1,8 @@
## system-config-printer
-## Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+## Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014 Red Hat, Inc.
## Copyright (C) 2006 Florian Festi <ffesti@redhat.com>
-## Copyright (C) 2007, 2008, 2009 Tim Waugh <twaugh@redhat.com>
+## Copyright (C) 2007, 2008, 2009, 2014 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
@@ -272,15 +272,14 @@ class PrinterFinder:
def _probe_snmp (self):
# Run the CUPS SNMP backend, pointing it at the host.
- null = open ("/dev/null", "r+")
try:
debugprint ("snmp: trying")
p = subprocess.Popen (args=["/usr/lib/cups/backend/snmp",
self.hostname],
close_fds=True,
- stdin=null,
+ stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
- stderr=null)
+ stderr=subprocess.DEVNULL)
except OSError as e:
debugprint ("snmp: no good")
if e == errno.ENOENT:
@@ -297,7 +296,7 @@ class PrinterFinder:
debugprint ("snmp: no good")
return
- for line in stdout.decode('utf-8').split ('\n'):
+ for line in stdout.decode ().split ('\n'):
words = wordsep (line)
n = len (words)
if n == 6:
@@ -365,14 +364,13 @@ class PrinterFinder:
self._cached_attributes['device-make-and-model'])
return
- null = open ("/dev/null", "r+")
try:
debugprint ("hplip: trying")
p = subprocess.Popen (args=["hp-makeuri", "-c", self.hostname],
close_fds=True,
- stdin=null,
+ stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
- stderr=null)
+ stderr=subprocess.DEVNULL)
except OSError as e:
if e == errno.ENOENT:
return
@@ -388,7 +386,7 @@ class PrinterFinder:
debugprint ("hplip: no good")
return
- uri = stdout.strip ()
+ uri = stdout.decode ().strip ()
debugprint ("hplip: uri is %s" % uri)
if uri.find (":") != -1:
self._new_device(uri, uri)
diff -up system-config-printer-1.5.1/system-config-printer.py.python3 system-config-printer-1.5.1/system-config-printer.py
--- system-config-printer-1.5.1/system-config-printer.py.python3 2014-08-22 12:20:15.000000000 +0100
+++ system-config-printer-1.5.1/system-config-printer.py 2014-09-11 17:19:36.140730329 +0100
@@ -736,7 +736,7 @@ class GUI(GtkGUI):
self.cups_connection_error)
self.monitor.connect ('cups-connection-recovered',
self.cups_connection_recovered)
- GObject.idle_add (self.monitor.refresh)
+ GLib.idle_add (self.monitor.refresh)
self.propertiesDlg.set_monitor (self.monitor)
if connected:
diff -up system-config-printer-1.5.1/troubleshoot/CheckSELinux.py.python3 system-config-printer-1.5.1/troubleshoot/CheckSELinux.py
--- system-config-printer-1.5.1/troubleshoot/CheckSELinux.py.python3 2014-08-22 12:20:15.000000000 +0100
+++ system-config-printer-1.5.1/troubleshoot/CheckSELinux.py 2014-09-11 17:19:40.508754380 +0100
@@ -2,7 +2,7 @@
## Printing troubleshooter
-## Copyright (C) 2010 Red Hat, Inc.
+## Copyright (C) 2010, 2014 Red Hat, Inc.
## Copyright (C) 2010 Jiri Popelka <jpopelka@redhat.com>
## This program is free software; you can redistribute it and/or modify
@@ -48,7 +48,6 @@ class CheckSELinux(Question):
return False
paths = ["/etc/cups/", "/usr/lib/cups/", "/usr/share/cups/"]
- null = open ("/dev/null", "r+")
parent = self.troubleshooter.get_window ()
contexts = {}
new_environ = os.environ.copy()
@@ -60,9 +59,9 @@ class CheckSELinux(Question):
args=restorecon_args,
close_fds=True,
env=new_environ,
- stdin=null,
+ stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
- stderr=null)
+ stderr=subprocess.DEVNULL)
(restorecon_stdout, restorecon_stderr, result) = self.op.run ()
except:
# Problem executing command.
diff -up system-config-printer-1.5.1/troubleshoot/VerifyPackages.py.python3 system-config-printer-1.5.1/troubleshoot/VerifyPackages.py
--- system-config-printer-1.5.1/troubleshoot/VerifyPackages.py.python3 2014-08-22 12:20:15.000000000 +0100
+++ system-config-printer-1.5.1/troubleshoot/VerifyPackages.py 2014-09-11 17:19:40.508754380 +0100
@@ -2,7 +2,7 @@
## Printing troubleshooter
-## Copyright (C) 2010 Red Hat, Inc.
+## Copyright (C) 2010, 2014 Red Hat, Inc.
## Copyright (C) 2010 Jiri Popelka <jpopelka@redhat.com>
## This program is free software; you can redistribute it and/or modify
@@ -45,7 +45,6 @@ class VerifyPackages(Question):
"hpijs",
"hplip",
"system-config-printer"]
- null = open ("/dev/null", "r+")
parent = self.troubleshooter.get_window ()
new_environ = os.environ.copy()
@@ -58,9 +57,9 @@ class VerifyPackages(Question):
args=verification_args,
close_fds=True,
env=new_environ,
- stdin=null,
+ stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
- stderr=null)
+ stderr=subprocess.DEVNULL)
(verif_stdout, verif_stderr, result) = self.op.run ()
except:
# Problem executing command.
diff -up system-config-printer-1.5.1/userdefault.py.python3 system-config-printer-1.5.1/userdefault.py
--- system-config-printer-1.5.1/userdefault.py.python3 2014-08-22 12:20:15.000000000 +0100
+++ system-config-printer-1.5.1/userdefault.py 2014-09-11 17:19:40.508754380 +0100
@@ -1,6 +1,6 @@
#!/usr/bin/python3
-## Copyright (C) 2006, 2007, 2008, 2010, 2012 Red Hat, Inc.
+## Copyright (C) 2006, 2007, 2008, 2010, 2012, 2014 Red Hat, Inc.
## Author: Tim Waugh <twaugh@redhat.com>
## This program is free software; you can redistribute it and/or modify
@@ -75,13 +75,13 @@ class UserDefaultPrinter:
def set (self, default):
p = subprocess.Popen ([ "lpoptions", "-d", default ],
close_fds=True,
- stdin=open ("/dev/null"),
- stdout=open ("/dev/null", "w"),
+ stdin=subprocess.DEVNULL,
+ stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate ()
exitcode = p.wait ()
if exitcode != 0:
- raise RuntimeError (exitcode, stderr.strip ())
+ raise RuntimeError (exitcode, stderr.decode ().strip ())
return
def __repr__ (self):

View File

@ -7,13 +7,14 @@
Summary: A printer administration tool
Name: system-config-printer
Version: 1.5.1
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv2+
URL: http://cyberelk.net/tim/software/system-config-printer/
Group: System Environment/Base
Source0: http://cyberelk.net/tim/data/system-config-printer/1.4/%{name}-%{version}.tar.xz
Patch1: system-config-printer-no-applet-in-gnome.patch
Patch2: system-config-printer-lock.patch
Patch3: system-config-printer-python3.patch
BuildRequires: cups-devel >= 1.2
BuildRequires: desktop-file-utils >= 0.2.92
@ -88,6 +89,9 @@ printers.
# Take the gdk lock before entering gtk_main() (bug #1052203 comment #24).
%patch2 -p1 -b .lock
# Python3 fixes from upstream.
%patch3 -p1 -b .python3
%build
%configure --with-udev-rules
make %{?_smp_mflags}
@ -187,6 +191,9 @@ touch %buildroot%{_localstatedir}/run/udev-configure-printer/usb-uris
exit 0
%changelog
* Thu Sep 11 2014 Tim Waugh <twaugh@redhat.com> - 1.5.1-3
- Python3 fixes from upstream.
* Sat Sep 6 2014 Tim Waugh <twaugh@redhat.com> - 1.5.1-2
- Take the gdk lock before entering gtk_main() (bug #1052203 comment #24).