Don't have permission to exec library in cache directory
-
@pavelprosto Those denials are about libertine dbus service, not executing files in the cache directory; so you can ignore them.
-
@dobey There were no other messages
-
@dobey
I'm not a dev, but that made me wonder : why a "native" uTouch click app would trigger libertine? -
@pavelprosto said in Don't have permission to exec library in cache directory:
Because this is a QML + Python project.
I included transmission in the project, everything exactly turns out this error.Sure, but you can build separate click packages for each architecture, which pulls the approriate transmission binaries in, and will reduce the size of your package versus shipping the same thing on all architectures.
Also, please can you state the exact command line which your app is trying to run with
subprocess.Popen
here? I see in your code that you're raising an exception which includes that, but I have not seen that posted here. Also, it looks like you're definingCACHEPATH
based on the path of__file__
which should I guess be pointing at the installed path of your package. -
@dobey command:
transmission-cli --config-dir "/home/phablet/.cache/transmission.pavelprosto/" -p 51414 -w "/home/phablet/.cache/transmission.pavelprosto/Download/" -d 1024 -u 256 -ep "/home/phablet/.cache/transmission.pavelprosto/manjaro-kde-20.2.1-210103-linux59.iso.torrent"
Environment:
"HOME" : "/home/phablet/.cache/transmission.pavelprosto/"
"PWD" : "/home/phablet/.cache/transmission.pavelprosto/"
"TMPDIR" : "/home/phablet/.cache/transmission.pavelprosto/tmp"
"PATH" : "/home/phablet/.cache/transmission.pavelprosto//transmission/bin"
"LD_LIBRARY_PATH" : "/home/phablet/.cache/transmission.pavelprosto/transmission/lib/"
"PKG_CONFIG_PATH" : "/home/phablet/.cache/transmission.pavelprosto/transmission/lib/pkgconfig" -
@keneda I also find it strange. libertine is not used in my program, where it came from, I don't understand
-
@pavelprosto OK. So, yes, apps cannot execute things in the cache or config directories for the app, but can execute things from the app's data directory
~/.local/share/${APP_PKG_NAME}/
instead.Also, cache is things expected to be OK for the user to remove and have the app still working. I suspect your app shouldn't be unpacking transmission into the cache directory on every start.
Rather, my best suggestion is still to include the transmission binaries in the click package itself, and have them installed alongside your app's python and QML.
lib/${ARCH_TRIPLET}/bin
inside your click package, is already in the${PATH}
for your app, andlib/${ARCH_TRIPLET}
already part of${LD_LIBRARY_PATH}
, so you don't need to mess with the environment like that, either. -
@dobey THANK YOU VERY MUCH!
It is fantastic! Everything works with safe permission
I finish the final touches and publish in OpenStore -
If someone needs to create a front-end wrapper for a binary console program, here's how it can be implemented
create global environment
glob.pyimport os APP_PKG_NAME = os.path.abspath(__file__) APP_PKG_NAME = APP_PKG_NAME[APP_PKG_NAME.find(".com/")+5:] APP_PKG_NAME = APP_PKG_NAME[:APP_PKG_NAME.find("/")] SCRIPTPATH = os.path.abspath(__file__) SCRIPTPATH = SCRIPTPATH[:SCRIPTPATH.rfind('/')] CACHEPATH = "/home/phablet/.cache/"+APP_PKG_NAME DATAPATH = "/home/phablet/.local/share/"+APP_PKG_NAME CONFIGPATH = "/home/phablet/.config/"+APP_PKG_NAME DOWNLOADPATH = CACHEPATH+"/Download" TMPPATH = CACHEPATH+"/tmp" RESUMEPATH = CACHEPATH+"/resume/" TORRENTSPATH = CACHEPATH+"/torrents/" MY_ENV = {"HOME" : CACHEPATH } MY_ENV["PWD"] = CACHEPATH MY_ENV["TMPDIR"] = CACHEPATH+"/tmp" MY_ENV["PATH"] = DATAPATH+"/transmission/bin" MY_ENV["LD_LIBRARY_PATH"] = DATAPATH+"/transmission/lib/" MY_ENV["PKG_CONFIG_PATH"] = DATAPATH+"/transmission/lib/pkgconfig" if not os.path.exists(DATAPATH): try: os.makedirs(DATAPATH) except Exception as e: print("Can't create DATAPATH dir:\n"+DATAPATH) print(e) if not os.path.exists(CONFIGPATH): try: os.makedirs(CONFIGPATH) except Exception as e: print("Can't create CONFIGPATH dir:\n"+CONFIGPATH) print(e) if not os.path.exists(CACHEPATH): try: os.makedirs(CACHEPATH) except Exception as e: print("Can't create CACHEPATH dir:\n"+CACHEPATH) print(e) if not os.path.exists(DOWNLOADPATH): try: os.makedirs(DOWNLOADPATH) except Exception as e: print("Can't create DOWNLOAD dir:\n"+DOWNLOADPATH) print(e) if not os.path.exists(TMPPATH): try: os.makedirs(TMPPATH) except Exception as e: print("Can't create TMP dir:\n"+TMPPATH) print(e)
Correct location of all files is very important!!!
DATAPATH: contains all executables and libraries
CONFIGPATH: contains the settings for your application. But not settings for a binary console program, its settings must be stored in CACHEPATH
CACHEPATH: contains all files resulting from program execution.
Now you will be able to launch and communicate with the console program through your environment:... import subprocess import re import shlex import glob ... CMD="transmission-show" def strip_color(s): return re.sub('\x1b\\[(K|.*?m)', '', s) def _process(command_string, path=""): cmd_args = shlex.split(command_string) try: PROCESS = subprocess.Popen(cmd_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=False, executable=None, env=glob.MY_ENV, cwd=path) except Exception as e: yield strip_color(str(e)) else: for stdout_line in iter(PROCESS.stdout.readline, ''): yield strip_color(stdout_line) PROCESS.stdout.close() return_code = PROCESS.wait() if return_code: raise subprocess.CalledProcessError(return_code, command_string) ... for stdout_line in _process(CMD+" \""+FILENAME+"\"", glob.CACHEPATH): print(stdout_line) ...
-
@pavelprosto said in Don't have permission to exec library in cache directory:
If someone needs to create a front-end wrapper for a binary console program, here's how it can be implemented
Have you thought about joining forces with @aarontheissueguy and creating a git*b project for the template?
-
@cibersheep Yes,I want to write a guide. But first I need to make sure it works for all console programs.
I tried, add the previous guides in github
https://docs.ubports.com/en/latest/appdev/guides/index.htmlBut something didn't work out for me. I try will do this in spare time