Bug 2158996

Summary: zim screenshot fails: AttributeError: 'TmpFile' object has no attribute 'rename'
Product: [Fedora] Fedora Reporter: Robert <redhat-bz>
Component: ZimAssignee: Otto Liljalaakso <otto.liljalaakso>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 37CC: oliver, otto.liljalaakso, robinlee.sysu
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Zim-0.75.2-1.fc38 Zim-0.75.2-1.fc37 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-07-28 02:41:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Robert 2023-01-07 15:53:48 UTC
Description of problem:


Version-Release number of selected component (if applicable):
Fedora versions 35, 36, and 37 all seem to be affected

How reproducible:
100%

Steps to Reproduce:
1. install & launch zim
2. enable screenshot plugin (edit>preferences>plugins>insert-screenshot>ok)
3. take a screenshot (insert>screenshot)

Actual results:
The screenshot is not inserted into the page with no user feedback.

Expected results:
The screenshot should appear in the open notebook page.

Additional info:

* Seems to be related to https://github.com/zim-desktop-wiki/zim-desktop-wiki/issues/2190

* The following stack trace appears in /tmp/zim-*/zim.log

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/zim/applications.py", line 438, in <lambda>
    lambda pid, status, data: callback(status, data), data)
                              ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/zim/plugins/screenshot.py", line 216, in callback
    tmpfile.rename(imgfile)
    ^^^^^^^^^^^^^^
AttributeError: 'TmpFile' object has no attribute 'rename'

Comment 1 Fedora Admin user for bugzilla script actions 2023-07-15 00:06:30 UTC
This package has changed maintainer in Fedora. Reassigning to the new maintainer of this component.

Comment 2 Fedora Admin user for bugzilla script actions 2023-07-20 00:08:23 UTC
This package has changed maintainer in Fedora. Reassigning to the new maintainer of this component.

Comment 3 Otto Liljalaakso 2023-07-20 11:01:26 UTC
Upstream issue #2190 has been resolved and indeed,
the given error does not appear when using 0.75.2,
which is the first version to include the fix.

0.75.2 is available on Rawhide now, and in testing for Fedora 38.
Koji build is failing for Fedora 37, which I still need to investigate.

I can now use the screenshot plugin on an X session.
However, on GNOME and Wayland I get a different error now:

    import: unable to read X window image 'root': Resource temporarily unavailable @ error/xwindow.c/XImportImage/5065.
    import:  `/tmp/zim-ex3ub765/insert-screenshot.png' @ error/import.c/ImportImageCommand/1289.

I have reported this upstream as
https://github.com/zim-desktop-wiki/zim-desktop-wiki/issues/2424

Comment 4 Fedora Update System 2023-07-24 13:35:28 UTC
FEDORA-2023-4ab5fee2bd has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-4ab5fee2bd

Comment 5 Fedora Update System 2023-07-24 13:36:23 UTC
FEDORA-2023-37846046df has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-37846046df

Comment 6 Otto Liljalaakso 2023-07-24 13:39:06 UTC
After a bit more research, I discovered that the Insert Screenshot plugin has settings
gnome-screenshot can be selected as the backend utility there.
After doing that, screenshots work on Wayland.

I have also submitted an upstream fix to get the gnome-screenshot used by default on Wayland:
https://github.com/zim-desktop-wiki/zim-desktop-wiki/pull/2431

Comment 7 Fedora Update System 2023-07-28 02:41:08 UTC
FEDORA-2023-37846046df has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 8 Fedora Update System 2023-07-29 01:19:29 UTC
FEDORA-2023-4ab5fee2bd has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.