Bug 399229 - remove Dolphin's Ruby dependency by converting service menu installation scripts to Python
Summary: remove Dolphin's Ruby dependency by converting service menu installation scri...
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 18.04.3
Platform: Fedora RPMs Linux
: NOR minor
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2018-09-30 02:13 UTC by skierpage
Modified: 2019-07-14 22:43 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 19.08.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description skierpage 2018-09-30 02:13:20 UTC
SUMMARY
I was trying to cut down on my 4,000+ Fedora packages and noticed the Ruby interpreter was present. Dolphin's two scripts servicemenuinstallation and service-me-nude-installation are written in Ruby and are the only reason Ruby is required in the Fedora KDE spin. It would be nice if they were ported to Python (Python 3 is definitely installed by default in Fedora and Ubuntu 18.04 desktop and server).

STEPS TO REPRODUCE
1. In a terminal enter `file /usr/bin/servicemenu*`

OBSERVED RESULT
Two Ruby scripts. Installing and uninstalling services in Dolphin's Action menu via Control > Configure Dolphin... > Services > Download New Services... invokes them.

EXPECTED RESULT
Would be nice if the two scripts were in Python.

Note the downstream bug report https://bugs.launchpad.net/ubuntu/+source/kde-baseapps/+bug/706900/ has a WIP Python 2 implementation of servicemenuinstallation attached.

SOFTWARE VERSIONS
KDE Plasma Version: 5.13.4
KDE Frameworks Version: 5.49.0
Qt Version: 5.11.1

ADDITIONAL INFORMATION
Converting the scripts to Python3, plus writing tests for installing and de-installing items from the service menu, seems like a great first bug or Google Code-In project.
Comment 1 Peter 2018-10-08 10:20:28 UTC
I've currently rewritten servicemenudeinstallation in Python 3 and am just testing it out further. Hope to have this finished by next week and put it in place for systems testing. It seems like a good first project and so I might need some help submitting / cleaning up.
Comment 2 Nate Graham 2018-10-08 17:40:31 UTC
Neato, let me know if you need a hand submitting it as a patch using http://phabricator.kde.org/.

The documentation is here: https://community.kde.org/Infrastructure/Phabricator
Comment 3 Peter 2018-10-27 03:45:39 UTC
Sorry it's taking me longer than expected. I'm just trying to double-check my Python script but can't seem to invoke even the original /usr/bin/servicemenudeinstallation through Control->Configure Dolphin->Services->Download New Services. I install a plugin and then uninstall it which should log to a file and also create a kdialog. Nothing seems to be happening. I've modified the original Ruby servicemenudeinstallation. How can I check where it's being called from? Can't find anything in TechBase and I've grepped the whole system for the /usr/bin/servicemenudeinstallation (dirty, I know).
Comment 4 Elvis Angelaccio 2018-10-27 10:13:03 UTC
It should call the script from /usr/bin/. I guess you should check whether you have some syntax errors in the changes you've done.
Comment 5 Peter 2018-10-29 06:56:38 UTC
You are correct. Syntax issues with my code. This is a little bit embarrassing haha. The only concern I have is that Dolphin still shows the Uninstall as successful, when quite clearly the program has failed. I'll keep going and finish this up.
Comment 6 Peter 2018-10-30 05:29:35 UTC
I'm coming to the realization that none of these scripts work particularly well. I have not been able to install (or uninstall) any of the downloaded Services (most downloads) for Dolphin. `.desktop` files fail at the `qtpaths --writable-path GenericDataLocation` on my fresh install of KDE Neon, and will also try going into a directory that doesn't exist. I believe this was written for KDE4 and hasn't really been updated for Plasma5. Can someone please confirm my findings? 

/usr/bin/servicemenuinstallation fails at `$servicedir = `qtpaths --writable-path GenericDataLocation`.strip!  + "/kservices5/ServiceMenus/"`

/usr/bin/servicemenudeinstallation fails at the same line of code (if the file is a .desktop) or will fail at `dd = Dir.new(dir)` (as the folder does not exist)

Happy to rewrite for new plugin support. Just need to make sure this isn't just me
Comment 7 Elvis Angelaccio 2018-11-02 11:08:20 UTC
(In reply to Peter from comment #6)
> I'm coming to the realization that none of these scripts work particularly
> well. I have not been able to install (or uninstall) any of the downloaded
> Services (most downloads) for Dolphin. `.desktop` files fail at the `qtpaths
> --writable-path GenericDataLocation` on my fresh install of KDE Neon, and
> will also try going into a directory that doesn't exist. I believe this was
> written for KDE4 and hasn't really been updated for Plasma5. Can someone
> please confirm my findings? 

No, it was updated for Plasma 5. I just tried with a couple of services, one was installed and the other was not. I think the problem might be in the service itself.

> 
> /usr/bin/servicemenuinstallation fails at `$servicedir = `qtpaths
> --writable-path GenericDataLocation`.strip!  + "/kservices5/ServiceMenus/"`

This folder should be created at the beginning of servicemenuinstallation.

> 
> /usr/bin/servicemenudeinstallation fails at the same line of code (if the
> file is a .desktop) or will fail at `dd = Dir.new(dir)` (as the folder does
> not exist)
> 
> Happy to rewrite for new plugin support. Just need to make sure this isn't
> just me

The script can definitely be improved. It would be nice if it were at least logging failures somewhere.
Comment 8 Alexander Potashev 2019-05-08 20:06:17 UTC
Here is a re-implementation of the scripts in Rust -> https://phabricator.kde.org/D21025 , it may be helpful for those who decide to rewrite it in C++: you might want to reuse the code structure.
Comment 9 Alexander Potashev 2019-06-18 08:30:43 UTC
Rewritten in C++: https://phabricator.kde.org/D21878
Comment 10 Alexander Potashev 2019-07-14 22:39:28 UTC
Git commit 1aaafe178c77e234e08565cc24f58887a7d5e0be by Alexander Potashev.
Committed on 14/07/2019 at 22:39.
Pushed by aspotashev into branch 'master'.

Rewrite servicemenu helper utility in C++

Summary:
     - Also support MIME type "application/x-compressed-tar".
     - Update tests in Ruby, remove SimpleCov.

Test Plan: Ruby tests passed

Reviewers: sitter, elvisangelaccio, ngraham

Reviewed By: elvisangelaccio

Subscribers: cfeck, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D21878

M  +2    -2    src/CMakeLists.txt
M  +2    -2    src/settings/services/servicemenu.knsrc
D  +0    -72   src/settings/services/servicemenudeinstallation
D  +0    -136  src/settings/services/servicemenuinstallation
A  +9    -0    src/settings/services/servicemenuinstaller/CMakeLists.txt
A  +2    -0    src/settings/services/servicemenuinstaller/Messages.sh
A  +387  -0    src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp     [License: GPL (v2/3)]
M  +4    -4    src/settings/services/test/service_menu_deinstallation_test.rb
M  +4    -4    src/settings/services/test/service_menu_installation_test.rb
M  +0    -69   src/settings/services/test/test_helper.rb
M  +0    -6    src/tests/CMakeLists.txt

https://commits.kde.org/dolphin/1aaafe178c77e234e08565cc24f58887a7d5e0be