KnowZero / Krita-PythonPluginDeveloperTools

Python plugin for Krita that assists with making python plugins for Krita
48 stars 2 forks source link

no write permission for some function when plugin was installed in system path #3

Closed zerobikappa closed 1 year ago

zerobikappa commented 1 year ago

Recently I packaged this plugin in Archlinux AUR but encountered some permission issue when install this plugin in system path. In Linux system, Krita stores plugins in /usr/share/krita/pykrita/, which requires user has sudo permission to write/download files in it. Here are the relevant codes in source file: https://github.com/KnowZero/Krita-PythonPluginDeveloperTools/blob/46a671aa5a5353917056a4198699d77e47e13402/plugindevtools/PluginDevTools/GetKritaAPI.py#L86 https://github.com/KnowZero/Krita-PythonPluginDeveloperTools/blob/46a671aa5a5353917056a4198699d77e47e13402/plugindevtools/PluginDevTools/GetKritaAPI.py#L104 https://github.com/KnowZero/Krita-PythonPluginDeveloperTools/blob/46a671aa5a5353917056a4198699d77e47e13402/plugindevtools/PluginDevTools/PluginDevToolsDocker.py#L172 https://github.com/KnowZero/Krita-PythonPluginDeveloperTools/blob/46a671aa5a5353917056a4198699d77e47e13402/plugindevtools/PluginDevTools/PluginDevToolsDocker.py#L320 https://github.com/KnowZero/Krita-PythonPluginDeveloperTools/blob/46a671aa5a5353917056a4198699d77e47e13402/plugindevtools/PluginDevTools/PluginDevToolsDocker.py#L542

As a workaround, I changed the storage path to ~/.cache/krita/ (krita always make a directory here to store QML cache). Would you consider to change the storage path elsewhere? I suggest to save the cache file in ~/.cache/krita/ for Linux system and %temp%/krita/ for Windows system.

KnowZero commented 1 year ago

From what I remember from Windows, the temp folder can end up being cleaned up since its usage is temporary. Since it isn't transitional, it probably should be in the %APPDATA%

Overall, I think to be consistent with Krita's way of doing things, the best place to place it would be the user's resource folder. It would honor the user's preference and this way let us say a user wants to copy Krita to an offline computer, they won't be looking around through source code where their data is.

Does that work out for you?

Edit: I pushed a patch, see if it works fine now

Diamondtroller commented 1 year ago

@zerobikappa Krita doesn't use /usr/share/krita/. Files in /usr/share/ are defaults that get copied into your user configuration. Krita uses user's configuration in ~/.local/share/Krita/ usually which is writeable.

zerobikappa commented 1 year ago

@KnowZero I only use Linux so I am not sure where does Krita store the plugins in Windows platform. For Linux user, rather than manually clone from project website then place it into resource folder, it is much easier to install plugins with package manager. Just in case if Krita team accept this plugin as an official plugin (I really hope to see that in future), it should be able to be stored in system path, same as other official plugins in /usr/share/krita/pykrita/.

I applied your patches but some problem still exist: (1) It can successfully save the API file into ~/.local/share/krita/pykrita/PluginDevTools. But when I restart Krita, the plugin failed to load API info from the previous downloaded file. (2) It still create the temporary script file in system path:

Original exception was:
Traceback (most recent call last):
  File "/usr/share/krita/pykrita/PluginDevTools/PluginDevToolsDocker.py", line 625, in tempScriptFile
    f = open(tempFile.toLocalFile(),'w+')
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/usr/share/krita/pykrita/PluginDevTools.console.temp.py'
KnowZero commented 1 year ago

Sorry about that, I only ended up committing the GetKritaAPI.py but not the PluginDevToolsDocker.py, fixed both should hopefully be fine now

zerobikappa commented 1 year ago

@KnowZero Thank you! It works now.