@cvp As a follow up to this, it ran fine with the pre-defined file paths when I ran it within Pythonista, but I still get a permission error when I try to run it from the files app itself as a shortcut. Can these kinds of operations only be done from within the Pythonista app?
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Latest posts made by itsseanl
-
RE: Noob seeks Help with shutil Permissions Error
-
RE: Noob seeks Help with shutil Permissions Error
@cvp amazing! Thanks so much. I’m blown away every day by the cool things I’m discovering that I can do from the iPad
-
Noob seeks Help with shutil Permissions Error
Hey all!
This is my first time using the Pythonista App, and pretty much my first time coding in Python so I’m kind of coming at this with zero knowledge other than some general coding experience.
Anyway, I just recently set up a local SMB server and thought it would be cool to try out either Pythonista or scriptable to easily copy Local iPad files over to my server. I had some issues with scriptable so here I am :)
I used appex.get_file_url() to get a file path for testing, and am just plugging it in to shutil copyfile() to get a demo of copy/paste functionality, but I’m being met with a permissions error!
Here’s my code
import ui, appex, clipboard, shutil # filePath = appex.get_file_path() filePath = '/private/var/mobile/Containers/Shared/AppGroup/*long string idk if its sensitive so removed*/File Provider Storage/debug.log' testdst = '/private/var/mobile/Containers/Shared/AppGroup/*long string idk if its sensitive so removed*/File Provider Storage/debugcopy.log' shutil.copyfile(filePath, testdst)
On running this, I get the following error:
Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/*longstring*/Pythonista3/Documents/copypastefile.py", line 9, in <module> shutil.copyfile(filePath, testdst) File "/var/containers/Bundle/Application/*longstring*/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/shutil.py", line 121, in copyfile with open(src, 'rb') as fsrc: PermissionError: [Errno 1] Operation not permitted: '/private/var/mobile/Containers/Shared/AppGroup/* long sting */File Provider Storage/debug.log'
Is this just a limitation of Pythonista (no access to files app)? Do I need to reformat the file paths? I literally just copy pasted the output of my test get_file_path() call which I ran through the “run Pythonista script” option after selecting a file I had sitting in the files app.
Anyways, I’ve been on a real DIY kick lately and I’m hoping I can integrate Pythonista and learn a bit of a new language along the way!
Thanks for any help