software-properties-{qt,kde} attempts to use KUrl but it doesn't exist

Bug #1795278 reported by Kristopher Ives
44
This bug affects 7 people
Affects Status Importance Assigned to Milestone
software-properties (Ubuntu)
Triaged
Undecided
Unassigned

Bug Description

Release: Kubuntu 18.04
Version: 0.96.24.32.1

When clicking the "Import Key" button in the "Authentication" section of the panel it throws this error:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/softwareproperties/kde/SoftwarePropertiesKDE.py", line 667, in add_key_clicked
        url = KUrl.fromPath(home)
    NameError: name 'KUrl' is not defined

While this doesn't crash the program it causes nothing to happen when clicking the button. Running the program in a terminal reveals the error being printed to stderr.

After debugging it appears KUrl doesn't exist anywhere and I'm not sure if's a python module that has changed.

Revision history for this message
Kristopher Ives (krisives) wrote :
Norbert (nrbrtx)
tags: added: bionic
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in software-properties (Ubuntu):
status: New → Confirmed
Revision history for this message
Walter Lapchynski (wxl) wrote :

According to the dupe, this affects more recent versions, too. And not just Kubuntu.

summary: - software-properties-kde attempts to use KUrl but it doesn't exist
+ software-properties-{qt,kde} attempts to use KUrl but it doesn't exist
tags: added: eoan focal kubuntu lubuntu
Revision history for this message
Walter Lapchynski (wxl) wrote :

There are no PyKDE imports anymore, only PyQt. That said, replacing `KUrl.fromPath` with just `QUrl` should resolve that.

But that's not our only issue:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/softwareproperties/qt/SoftwarePropertiesQt.py", line 713, in add_key_clicked
    filename = KFileDialog.getOpenFileName(url, 'application/pgp-keys', self.userinterface, _("Import key"))
NameError: name 'KFileDialog' is not defined

So we replace `KFileDialog` with `QFileDialog` and move some arguments around:

    filename = QFileDialog.getOpenFileName(self.userinterface, _("Import key"), url, 'application/pgp-keys')

The only other thing missing is that KFileDialog wanted a KUrl while QFileDialog wants a string. So we should cast our QUrl call:

    url = str(QUrl(home))

Maybe there's a prettier/better way to do this, but that's what I got for 10 minutes which is more progress than I can say this bug has had in the past XD If people can test those changes, it would be greatly appreciated.

Changed in software-properties (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
Hans P. Möller (hmollercl) wrote :

this should be the diff to be tested:

diff --git a/softwareproperties/qt/SoftwarePropertiesQt.py b/softwareproperties/qt/SoftwarePropertiesQt.py
index 8172e25..b210323 100644
--- a/softwareproperties/qt/SoftwarePropertiesQt.py
+++ b/softwareproperties/qt/SoftwarePropertiesQt.py
@@ -709,8 +709,7 @@ class SoftwarePropertiesQt(SoftwareProperties):
     home = QDir.homePath()
     if "SUDO_USER" in os.environ:
         home = os.path.expanduser("~%s" % os.environ["SUDO_USER"])
- url = KUrl.fromPath(home)
- filename = KFileDialog.getOpenFileName(url, 'application/pgp-keys', self.userinterface, _("Import key"))
+ filename = QFileDialog.getOpenFileName(self.userinterface, _("Import key"), home, 'application/pgp-keys')
     if filename:
       if not self.add_key(filename):
         title = _("Error importing selected file")

Revision history for this message
Michal Dziczkowski (mdziczkowski) wrote :

# diff --git a/softwareproperties/qt/SoftwarePropertiesQt.py b/softwareproperties/qt/SoftwarePropertiesQt.p
diff: unrecognized option '--git'
diff: Try 'diff --help' for more information.

Revision history for this message
Walter Lapchynski (wxl) wrote :

Michal, that's not how patching works, unfortunately. You can put all that in a file and use the `patch` command. The easy way is to go to the folder containing the file and run `sudo patch < /path/to/diff`.

Or you could simply edit the file (/usr/lib/python3/dist-packages/softwareproperties/qt/SoftwarePropertiesQt.py) according to the instructions given by the diff:

 1. Starting at line 709, look at it and the following 7 lines for a total of eight lines (this is what "-709,8" refers to in the original)
 2. Note, too, that after the change, the same hunk is referenced as "+709,7" meaning that the end result is one less line.
 3. Remove the definition of the "url" variable in line 712.
 4. In the next line (which is now 712) which defines the "filename" variable, change it from using the KFileDialog.getOpenFileName method to the QFileDialog.getOpenFileName method. Note that the arguments and their order are different.
 5. Save it and try again.

tags: added: groovy hirsute
Revision history for this message
Walter Lapchynski (wxl) wrote :

P.S. added Hirsute and Groovy tags since the latest dupe shows it affects Hirsute and thus should affect Groovy.

Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
http://iso.qa.ubuntu.com/qatracker/reports/bugs/1795278

tags: added: iso-testing
tags: added: rls-hh-incoming
tags: added: rls-hh-notfixing
removed: rls-hh-incoming
Revision history for this message
Leó Kolbeinsson (leok) wrote :

@wxl

This is still occuring on Lubuntu Hirsute daily ISO 2021-03-26.

Tested also Ubuntu Mate and Xubuntu same date and no error.

Norbert (nrbrtx)
tags: added: impish
removed: eoan groovy
Revision history for this message
Leó Kolbeinsson (leok) wrote :

Confirm that this still occuring in Lubuntu Impish - tested daily ISO 2021-08-04
http://cdimage.ubuntu.com/lubuntu/daily-live/20210804/impish-desktop-amd64.iso

Leó Kolbeinsson (leok)
tags: added: kinetic
Revision history for this message
Leó Kolbeinsson (leok) wrote :

Confirm this is still occuring in Lubuntu Kinetic - tested daily 19-05-2022

Machine tested Lenovo YG SL7 in live session.
http://iso.qa.ubuntu.com/qatracker/milestones/433/builds/248375/testcases/1303/results

Revision history for this message
KGIII (uninvolved) wrote :

Yup, still occurring in Kinetic.

Ran a quick test on bare metal and in a virtual machine.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers