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.
SCP and transferring files
-
I wanted to transfer some files to be used with Pythonista and I tried my old scp script (also the ope in Stash) and I'm getting an error about asbytes in paramiko. It's possible my paramiko is corrupted. Is this working for others?
Also, is there a way to use the Files app to get files and make them accessible to Pythonista?
-
@ihf said
I wanted to transfer some files to be used with Pythonista and I tried my old scp script (also the ope in Stash) and I'm getting an error about asbytes in paramiko. It's possible my paramiko is corrupted. Is this working for others?
There are some recent topics in this forum showing that there is a problem with Paramiko with the Pythonista beta
Also, is there a way to use the Files app to get files and make them accessible to Pythonista?
You can open external folder of Files in Pythonista explorer
-
@cvp thank you. I tried that and when I get to the file that I’m interested in bringing over to pythonista it is grayed out (it is a .db file). If I long press it I get the option ro download which it appears to do but how do I now move it to pythonista as it does not appear in the file list. Also, if I open an external .py file in the editor, how do I add it to the iPad files since it seems to go away if I close and re-open Pythonista.
-
- you said
If I long press it I get the option ro download which it appears to do but how do I now move it to pythonista as it does not appear in the file list
First thing to know: where is this file, in iCloud Drive? On an USB key? On a SMB drive?
Then, if iCloud Drive, does the file have a small cloud at top right ? If yes, you have to download it fitst, either via long press then download, either by tapping it.
As soon the file is locally downloaded, you could see it in Pythonista "open external ".
- you said
since it seems to go away if I close and re-open Pythonista.
When you do an "open external" folder, you have to open it (button top right) then it will stay permanent in the Pythonista left explorer.
- there is also the way to use Split View: Files at left and Pythonista explorer at right, and you drag and drop a Files file to a Pythonista folder
-
@cvp I go to external files , Open…, Folder…, select “Secure Term”, navigate to the folder with the files of interest, click open and I get
Error, The file “xyx” could not be loaded. If I instead select Open… File, I see fh efile which is dimmed and I don’t see a way to bring it into Pythonista. -
@ihf You have to click "open", on a folder, not on a file, did you do that? If it works, next time, you will see at left, under "open..." the name of this folder.
You can really access folders on real drives (local, iCloud Drive, usb drive), not on FTP drives, OneDrive, Google Drive and so on.
-
@cvp that must be the problem. I am getting to the file/folder via Nextcloud. From what you were saying, I can’t do that. I can move the files I need to iCloud from Nextcloud. I can then open iCloud as an external folder, but how do I then get the files I want to use with my script to the location that contains the script?
-
@ihf Assume you have a folder MyFolder in iCloud Drive and that you have open this folder as external.
You can get a file xxx.dat in this folder with path/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/MyFolder/xxx.dat
-
@cvp OK, I can do that within the script, but I take it there is no way within the UI to copy a folder or file from the external to the local?
-
@ihf you can write a local Pythonista script to copy an external file to a local file
import shutil shutil.copy('/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/MyFolder/xxx.dat', 'local.dat')
And if you use Split View, you can drag and drop a folder from Files App to Pythonista explorer
-
@cvp Yes, the script will move the file. However, when I do a split view on the iPad and try to drag a file, it shows the + but nothing is actually copied to Pythonista.
-
@ihf a file of which type or a folder?
And be careful, if the target position is on a folder name, the copy is done into the folder, not in the root
For example, in my blue rectangle at right is on a folder, and you end the drag, the folder is copied as a sub-folder and you don't see it unless if you open the folder where the drag is fallen (not sure I'm clear enough)
You know that you can find a file or folder or sub-folder in Pythonista explorer, assumed that you don't see that the copy has to be done
-
The file is a .db file. I knew about the search capability, and that’s how I have been confirming that it is not been copied over.
-
@ihf I just copy a .db file in Split View from Files/iCloud Drive to Pythonista local, without any problem.
-
@cvp Thanks for your help. I finally got it to work.I used the Files app to copy files from Nextcloud to iCloud and then use Files app to move them from iCloud to Pythonista space.
-
@ihf did you try to directly drag and drop from original NextCloud to Pythonista ?
-
@cvp Yes, that does work although for some reason some of the directories on my Nextcloud instance are showing as empty when they are not. However, that's not a Pythonista issue. Am I correct that this transfer from Files app to Pythonista can only be done directly on an iPad running in split view or is there a way to do it on the iPhone?
-
@ihf Split View only works on iPad. At least actually, even not on big iPhones.
Did you try to import a file from anywhere in Files App to local Pythonista (root) by sharing it?
Try to share a Files App file to this Pythonista script. It is quick, without any UI and should work on iPhone.
import appex import console import shutil import os #import urllib.request, urllib.parse, urllib.error def main(): # called by sharing action if not appex.is_running_extension(): console.hud_alert('Has to run in appex mode','error') return # Sharing: receive file to store in local folder fil = appex.get_file_path() local_file = os.path.basename(fil) local_path = os.path.join(os.path.expanduser("~"),'Documents/') local_path = os.path.join(local_path,local_file) shutil.copy(fil,local_path) appex.finish() if __name__ == '__main__': main()
I guess that you know how to configure a script to be visible in the Pythonista share sheet.
-
@ihf In Pythonista, you can also import a Files file via +/import/Files/.../open
I've tried with a Google Drive file and it works. But I can't test with NextCloud
-
@cvp thanks so much! Both the script from the share sheet as well as the import function (which I never even thought to try) worked with Nextcloud