!52 backport Fix bad use of NamedTemporaryFile
From: @liyy9 Reviewed-by: @Charlie_li Signed-off-by: @Charlie_li
This commit is contained in:
commit
f3c792425d
67
0006-Fix-bad-use-of-NamedTemporaryFile.patch
Normal file
67
0006-Fix-bad-use-of-NamedTemporaryFile.patch
Normal file
@ -0,0 +1,67 @@
|
||||
From f5f670069d6aef364b2245b5b3068e4c4a1c1148 Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Korbar <tkorbar@redhat.com>
|
||||
Date: Mon, 19 Nov 2018 13:34:48 +0100
|
||||
Subject: [PATCH] Fix bad use of NamedTemporaryFile
|
||||
|
||||
- os.stat call expects file path not file object
|
||||
---
|
||||
troubleshoot/ErrorLogCheckpoint.py | 42 +++++++++++++++---------------
|
||||
1 file changed, 21 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/troubleshoot/ErrorLogCheckpoint.py b/troubleshoot/ErrorLogCheckpoint.py
|
||||
index 7394c581..7ba7396e 100644
|
||||
--- a/troubleshoot/ErrorLogCheckpoint.py
|
||||
+++ b/troubleshoot/ErrorLogCheckpoint.py
|
||||
@@ -134,28 +134,28 @@ class ErrorLogCheckpoint(Question):
|
||||
if 'error_log_checkpoint' in self.answers:
|
||||
return self.answers
|
||||
|
||||
- with NamedTemporaryFile () as tmpf:
|
||||
- try:
|
||||
- self.op = TimedOperation (self.authconn.getFile,
|
||||
- args=('/admin/log/error_log',
|
||||
- tmpf.file),
|
||||
- parent=parent)
|
||||
- self.op.run ()
|
||||
- except (RuntimeError, cups.IPPError) as e:
|
||||
- self.answers['error_log_checkpoint_exc'] = e
|
||||
- except cups.HTTPError as e:
|
||||
- self.answers['error_log_checkpoint_exc'] = e
|
||||
-
|
||||
- # Abandon the CUPS connection and make another.
|
||||
- answers = self.troubleshooter.answers
|
||||
- factory = answers['_authenticated_connection_factory']
|
||||
- self.authconn = factory.get_connection ()
|
||||
- self.answers['_authenticated_connection'] = self.authconn
|
||||
+ tmpf = NamedTemporaryFile()
|
||||
+ try:
|
||||
+ self.op = TimedOperation (self.authconn.getFile,
|
||||
+ args=["/admin/log/error_log"],
|
||||
+ kwargs={'file': tmpf},
|
||||
+ parent=parent)
|
||||
+ self.op.run ()
|
||||
+ except (RuntimeError, cups.IPPError) as e:
|
||||
+ self.answers['error_log_checkpoint_exc'] = e
|
||||
+ except cups.HTTPError as e:
|
||||
+ self.answers['error_log_checkpoint_exc'] = e
|
||||
+
|
||||
+ # Abandon the CUPS connection and make another.
|
||||
+ answers = self.troubleshooter.answers
|
||||
+ factory = answers['_authenticated_connection_factory']
|
||||
+ self.authconn = factory.get_connection ()
|
||||
+ self.answers['_authenticated_connection'] = self.authconn
|
||||
|
||||
- try:
|
||||
- statbuf = os.stat (tmpf.file)
|
||||
- except OSError:
|
||||
- statbuf = [0, 0, 0, 0, 0, 0, 0]
|
||||
+ try:
|
||||
+ statbuf = os.stat (tmpf.name)
|
||||
+ except OSError:
|
||||
+ statbuf = [0, 0, 0, 0, 0, 0, 0]
|
||||
|
||||
self.answers['error_log_checkpoint'] = statbuf[6]
|
||||
self.persistent_answers['error_log_checkpoint'] = statbuf[6]
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
Name: system-config-printer
|
||||
Summary: a graphical tool for CUPS administration
|
||||
Version: 1.5.11
|
||||
Release: 19
|
||||
Release: 20
|
||||
License: GPLv2+
|
||||
URL: https://github.com/zdohnal/system-config-printer
|
||||
Source0: https://github.com/zdohnal/system-config-printer/archive/%{version}.tar.gz
|
||||
@ -13,6 +13,7 @@ Patch0002: 0002-Require-proper-version-of-GDK-and-GTK-in-scp-dbus-se.patch
|
||||
Patch0003: 0003-Set-programe-name-for-scp-dbus-service-as-well.patch
|
||||
Patch0004: 0004-Fix-typo-in-debugprint-call.patch
|
||||
Patch0005: 0005-Fix-TypeError-raised-by-debugprint-call.patch
|
||||
Patch0006: 0006-Fix-bad-use-of-NamedTemporaryFile.patch
|
||||
|
||||
BuildRequires: libusb1-devel gcc gettext-devel systemd xmlto systemd-devel python3-devel
|
||||
BuildRequires: intltool cups-devel >= 1.2 desktop-file-utils >= 0.2.92 pkgconfig(glib-2.0)
|
||||
@ -88,6 +89,9 @@ rm -rf /var/cache/foomatic/foomatic.pickle
|
||||
exit 0
|
||||
|
||||
%changelog
|
||||
* Thu Nov 09 2023 liyuanyuan <liyuanyuan@xfusion.com> - 1.5.11-20
|
||||
- Fix bad use of NamedTemporaryFile
|
||||
|
||||
* Thu Nov 02 2023 liyuanyuan <liyuanyuan@xfusion.com> - 1.5.11-19
|
||||
- Fix TypeError raised by debugprint call
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user