Import Scripts written on Mac/PC to Pythonista?
Is there any convenient way to import/move/copy a script written on a 'proper' computer into Pythonista?
- "Open in" from Dropbox or my Samba client does not work; meanwhile I noticed a corresponding post on this site that explains that this is something Apple does not allow...
- Furthermore, there is no import dialogue somewhere in the Pythonista app. (But I can EXPORT stuff, ...)
- And it seems that Pythonista does not offer to import files via iTunes.
I do not see a different option than mailing me a script and copy/paste this into Pythonista as a text. Well, that would be ridiculous...
I'll point out a few other options:
- Use gists. Pythonista has a proper Export to Gist function, and you can export an entire folder.
For importing, while it is not built in, the action menu provides the next best thing.
gistcheck offers bidirectional gist including multiple file support. Note in particular the bookmarklet, which lets you effectively do "1-click" imports from gists that you browse to in safari, or lets you sync existing gists (pull or commit). The syncing methods probably only work for single py gists.
- Use github and git. There are several methods to import from github: GitHubGet offers a bookmarklet similar to gistcheck. gitrepo offers a repo browser.
As for exporting, current options are the graphical gitview, and the git command found within stash or shellista. The stash version is where current development is happening.
Maybe this is relevant to put here since dropboxsync was discussed here several times.
I tried syncing from the latest beta on a slow ass old iPad 3 and I got a strange error:
dropbox.rest.ErrorResponse:  u'This file is no longer available due to a takedown request under the Digital Millennium Copyright Act by Microsoft.'
Not in local
Not in local Downloading: lxml-master/doc/licenses/BSD.txt Making Directory: lxml-master/doc/licenses Not in local Downloading: lxml-master/doc/licenses/GPL.txt Traceback (most recent call last): File "/var/mobile/Containers/Data/Application/D4FFCC41-C218-4673-8C39-5C98F78606B0/Documents/DropboxSync.py", line 167, in <module> state.execute_delta(client) File "/var/mobile/Containers/Data/Application/D4FFCC41-C218-4673-8C39-5C98F78606B0/Documents/DropboxSync.py", line 34, in execute_delta self.download(client, path) File "/var/mobile/Containers/Data/Application/D4FFCC41-C218-4673-8C39-5C98F78606B0/Documents/DropboxSync.py", line 62, in download remote, meta = client.get_file_and_metadata(os.path.join('/',path)) File "/private/var/mobile/Containers/Bundle/Application/E499756B-A6C0-433A-9F21-44BBCB8641E7/Pythonista.app/pylib/site-packages/dropbox/client.py", line 415, in get_file_and_metadata file_res = self.get_file(from_path, rev) File "/private/var/mobile/Containers/Bundle/Application/E499756B-A6C0-433A-9F21-44BBCB8641E7/Pythonista.app/pylib/site-packages/dropbox/client.py", line 392, in get_file return self.rest_client.request("GET", url, headers=headers, raw_response=True) File "/private/var/mobile/Containers/Bundle/Application/E499756B-A6C0-433A-9F21-44BBCB8641E7/Pythonista.app/pylib/site-packages/dropbox/rest.py", line 253, in request return cls.IMPL.request(*n, **kw) File "/private/var/mobile/Containers/Bundle/Application/E499756B-A6C0-433A-9F21-44BBCB8641E7/Pythonista.app/pylib/site-packages/dropbox/rest.py", line 186, in request raise ErrorResponse(r) dropbox.rest.ErrorResponse:  u'This file is no longer available due to a takedown request under the Digital Millennium Copyright Act by Microsoft.'
Any thoughts what this means? Millennium copyright Act?!
The fatherland authorities in the USA
preventpublic data services from hosting copyrighted works. In this case, Microsoft has claimed that the file in question contains copyrighted works so that file has been deleted from the public data service in question (DropBox).
DropboxSync should be put into a Repo because it is impossible to send in Pull Requests to fix issues like this in Gist-based code.
it is hilarious that Microsoft is claiming ownership of GPL.txt! there should be a way to contact Dropbox and contest this takedown (GPL.txt is most definitely not owned by ms)
I wrote to Dropbox. Only via feedback option in the iOS app. But I did ask them to take corrective action or provide me a link to justify the position they have taken. And to update me on the resolution. If I get one from them, I will post it here
assuming this is your account, you should have received an email with the notification, and a link to file a counter notification
Thanks guys. It is ironic isn't it that GPL.txt is the file...
Anyway I didn't receive any emails with regards to this error. Basically I deleted all of Lxml-master folder containing that file from all devices before re syncing everything.
I haven't received any response as yet, but I think it will take a few days if they are going to respond at all. It was my account @JonB, paid account also. I will look further, could be in one of my various spam folders.
@ccc Late finding this (checking referral logs for once), I've put the Dropbox Sync script into a repo here: https://github.com/dhutchison/PythonistaScripts . If you are able to fix the issue it would be much appreciated!
I found a pretty simple way to import files from DropBox to Pythonista using the WorkFlow app.
Sounds strange, but i was wondering about Pythonistas new script -> "import photo" option. Then i renamed my script on my mac to ".jpg" . That should open all ways to transfer the file (photo) between apps on iPhone regardless from Dropbox and Co. I sent myself an email, imported the photo into my Photo App and then created new script in Pythonista with "import photo" -> rename from jpg to py and done. Maybe someone like me stumbles over the same problem not wanting to install more apps on iphone.
You can import any file type into pythonista, you have just to press the share button in your source app, then select pythonista and then import file.
@Ralph432 Could you post the script that you wrote to do the "import photo" & rename?
@zipit I'm clearly missing something. I emailed a Python script to myself, hit 'download', then 'share', then 'run Pythonista script' ... but none of the options say anything like 'import' or 'save' - or even 'run' for that matter. I see icons for "All Scripts', 'Scratchpad' and 'Console', but none of them appear to lead me to a place where i can import my script to Pythonista.
Filenames that end in
.pyare treated differently than all other files to be compliant with Apple's app review guidelines which put constraints on executable code. The workaround is to rename your file
y) on your Mac before emailing it and then on your iOS device, add the
yback onto the end of the filename.
The simplest solution would be to copy and paste the code as text. The way I do it is as follows...
Copy/paste your Python script in rich text format or some other text format that retains formatting and save it to Dropbox.
Send the file to the Pages app (and allow it to convert it to Pages format if necessary).
In Pages, select all and copy the text.
In a blank script in Pythonista, paste the text. This text should run as a script.
I also find it rather stupid that Apple would block importing .py files given you can create any sort of code on your own iOS device and even, with some rigmarole, import scripts via text copy and paste. Not cool, Apple, lol.
Pretty complicated. The simplest solution is:
- Copy script on Mac to clipboard (
- Open Pythonista
- Create empty script
Cmd V(if you have external keyboard) or tap and select Paste if not
Read macOS Sierra: Copy and paste across devices. Apple doesn't check clipboard content, you can copy & paste Python code. Works pretty well and I use it several times a week.
- Copy script on Mac to clipboard (
You can also use the free iOS app CloudClip with its Mac OS companion CloudClip Manager : http://www.thinkbitz.com/cloudclip/
It's like the macOS Sierra functionality 'Copy and paste across iOS and Mac OS devices' but this can be done on an older version of Mac OS.
Rossi the Hutt
- Save your script in your iCloud Drive on your Mac (I am sure Google Drive/One Drive works similarly).
- Find the script using the Files (iOS 11) app on your iPad and open it. Hold your finger down to highlight the first word and drag down to the bottom to highlight the whole script. Copy.
- Open the Pythonista app. Open a new script in Pythonista and hit the little clip board button to paste.
The latest beta of Pythonista includes iCloud Support. So this issue will go away if you have iCloud. I have no idea of the timeline for this beta to get into the App Store. I dont understand the internals of it, but it does work like a connected drive. So no copy and paste required. I run scripts directly from iCloud. But I suspect, under the hood there is a sync happening and that the files are local. I am just guessing. But the main point is that it just works. But look its still beta, there are some things to work out.
I hope I am not doing the wrong thing by posting info on beta program stuff. Especially as I have no idea of the timeline it will make it into the AppStore version. But its super cool and worth the wait. Its a game changer in my view. But have to be mindful, takes time to test these things and get them approved etc...