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.
Editing external files
-
I have a script which appends to a file and I would like to use this script from multiple Pythonista enabled devices. The problem is that I also sync these devices to Dropbox so the last device to sync determines the version of the file that I edit. I would like the file to be stored externally. Can anyone point me to a snippet which opens,reads, writes an external file (on Dropbox or web server)?
-
If it is just you adding the lines, and you do not require an actual file object, you could use this old thing to use Apple Reminders as a back-end, with syncing managed by Apple, probably quickly enough so that you are always adding to the latest version. Has worked for me.
-
After thinking this through a bit more, I think that what I need is basically a logging function. Perhaps I could use a logging server to house the file. For this particular application, I am not actually editing the file so I don't need to read it, I just need a way to append to an external file. This seems to be precisely what sys logging daemons are for. I could probably write something simple for the server (listen on a port and append whatever comes in to a file) but I am sure something like that already exists for the client and server. Any pointers?
-
Perhaps this is all I need? http://omz-software.com/pythonista/docs/library/socketserver.html#module-socketserver
-
@ihf, makes sense.
If you do not have a convenient server lying around, you could just use a serverless function and some free cloud storage.
E.g. here’s code that lets you create and manage an AWS Lambda service directly from Pythonista. The Lambda function code could e.g. dump your log entries into an AWS DynamoDB.
See this forum post for a usage example.