Thank you for reporting this...
I've noticed that my various Sidebar workflows have not been working for a while in the beta, and this would explain why.
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.
Thank you for reporting this...
I've noticed that my various Sidebar workflows have not been working for a while in the beta, and this would explain why.
I said:
At some point recently, Editorial's Python has gone from saying
sys.platform
isunknown
to now sayingiphoneos
.
In beta 130010, it now says sys.platform
is ios
. Which means I have to re-copy my site-packages over...
On the up-side, it was really useful that the traceback was shown in the console - thanks very much indeed for this - it made the problem immediately clear... :)
(If this changes again, please could you put it in the TestFlight release notes, as it's a lot easier to update the site-packages in advance of the change in value....)
Yes, a thousand times yes!
I'd love to see this, or any other way of quickly navigating to favourite locations... :)
Thanks... In scripts, I'm only ever reading from files in the Dropbox directory, not writing to them... (The only time I ever write to them, I open them in the Editorial editor and change the contents there...)
Would you consider mentioning prominently in the notes for the next version of Editorial that the result of sys.platform
has changed, please, to help others out?
Getting this sorted out is a huge relief for me, given my dependence on Editorial - thanks for the import traceback; traceback.print_last()
tip!
Thank you. That allowed me to understand the problem.
I was calling a helper function I'd written, and put in site-packages
this starts with this:
def dropbox_directory():
if sys.platform == 'win32':
return os.getenv('MY_DROPBOX_DIR')
elif sys.platform == 'unknown':
....
At some point recently, Editorial's Python has gone from saying sys.platform
is unknown
to now saying iphoneos
.
I hadn't coded for else raise an exception
so various such helper functions now return None
.... and depending on where the function is called from, I get different kinds of error messages about things that don't work with None
...
My only problem now is how to get the fixed scripts over to Editorial, as the Workflow I use to import site-packages
is itself broken... I guess I'll have to initially edit the relevant Workflow to put in hard-code values instead of calling helpers.
Is there a recommended way to access the Dropbox directory inside Editorial?
The code I had isn't very pretty, having evolved over a few different versions of Editorial:
def dropbox_directory():
if sys.platform == 'win32':
return os.getenv('MY_DROPBOX_DIR')
elif sys.platform == 'unknown':
# Find the absolute path of the Dropbox folder, relative to the Workflows folder:
# TODO Try using os.chdir(expanduser('~/Documents/')) instead
# TODO The /private probably doesn't matter, now that I'm only showing the filename
import editor
commands_dir = editor.get_workflows_path()
dropbox_dir = os.path.realpath(commands_dir + '/../Dropbox/')
private_suffix = '/private'
if dropbox_dir.startswith(private_suffix):
dropbox_dir = string.replace(dropbox_dir, private_suffix, '', 1)
return dropbox_dir
@omz Are there any particular requirements for the files in site-packages
as to line-endings, character encodings or similar, please?
The path is fine - the import commands work - the problem seems to be with what is imported.
Hi Ole,
I've only just seen your question...
I get this (with some added line wrapping):
>>> import sys
>>> sys.path
['/var/mobile/Containers/Data/Application/3132ED2D-F6DF-4976-8984-2AFE7BE75247/Library/Application Support/Commands',
'/var/mobile/Containers/Data/Application/3132ED2D-F6DF-4976-8984-2AFE7BE75247/Documents/site-packages-2',
'/var/mobile/Containers/Data/Application/3132ED2D-F6DF-4976-8984-2AFE7BE75247/Documents/site-packages',
'/var/containers/Bundle/Application/A35D4C58-A130-4CC8-94EB-3DDAAAE4F464/Editorial.app/Frameworks/PythonistaKit.framework/pylib',
'/var/containers/Bundle/Application/A35D4C58-A130-4CC8-94EB-3DDAAAE4F464/Editorial.app/Frameworks/PythonistaKit.framework/pylib/site-packages',
'/var/containers/Bundle/Application/A35D4C58-A130-4CC8-94EB-3DDAAAE4F464/Editorial.app/Frameworks/PythonistaKit.framework/pylib/site-packages/PIL_compat']
Just to note that the problem is still present in 1.3 (130006)
and 1.3 (130007)
PS It's Editorial Version 1.3 (130005)
When I upgraded to the current Editorial beta, I found that any of my scripts that imported other scripts from site-packages were failing. Ole gave my the following lines to add to all my Python code in Workflows...
import os, sys
sys.path.insert(0, os.path.expanduser('~/Documents/site-packages'))
I thought that this had worked, but whenever I invoke any workflow that calls other ones, I get this error:
"Workflow Error
An error occurred in the action "Run Python Script": Line 10: Attribute Error:
'NoneType' object has no attribute 'endswith'"
Here is an example Python worflow script:
import os, sys
sys.path.insert(0, os.path.expanduser('~/Documents/site-packages'))
import console
import editorial_workflows
console.clear()
editorial_workflows.document_and_check_workflows()
None of the code I'm calling contains 'endswith', so I'm guessing that the error is coming from code inside Editorial?
I'd be really grateful for any workaround, as I'm about to make really heavy use of Editorial for a week, and will really miss my workflows.
(My last resort is to go back to Editorial from the AppStore - but I'd miss split-screen)
I'm pretty sure that I've added and edited files in Dropbox whilst off-line, and the changes have been synced by Editorial, so I believe what you did should have worked.
Once thing to try is, in Editorial:
The UI says "This will show a backup of files that were deleted as being removed from Dropbox during sync". With any luck, you'll be able to see and copy your files out of there.
Another thing to try is to use the Dropbox web interface to see the history of all changes in your account. That way, if Dropbox saw the files and then there were deleted, you'll be able to recover them via the Dropbox Web UI.
Good luck.
Clare
That's great news - thank you.
Would there be any chance of also having editor.set_selected_folder, please?
There are a few key folder hierarchies that I go to many times a day, and it would be wonderful to be able to create a few workflows, to go to the most frequent in single clicks.
(The first one I'd write would be 'Go to the root of Dropbox' - I'm often 6 or 7 levels down from the root, and it gets a bit tedious getting to the top, one folder at a time!)
Thanks @peterh and @ccc for the suggestions. I'm aware of these features and use them heavily, but this question is specifically about sharing python code via import - which @rvolta's do allow.
Are there any Editorial tips & tricks to allow to share one's own Python functions between multiple Editorial workflows, please?
Over time, I've ended up with nearly 170 workflows, and several of these are 'sets that do similar things', with a lot of Python helper functions in common with each other.
The developer in me finds this quite painful! If I want to change some behaviour in a helper function, I have to find all the copies and update them. And it makes it harder to find the small bits of interest in each workflow.
Characteristics I think this needs the shared code needs to be:
import
(I realise that doing this would make it impossible to just upload the resultant workflows to the Editorial Workflow Directory, to use on other devices - but I could like with that)
Thanks in advance,
Clare
Does anyone out there know if these workflows are compatible with the Editorial beta, please?
(I saw a message somewhere that it had only been tested with the current app-store version, but it would be good to know if that info is now out-of-date)
Wow - that looks amazing!
Thank you very much, I'll give it a go.
Clare
Using "Beta 112012", I'm finding that my Editorial backups have an ever-growing Documents/.DropboxTrash
folder, which mostly contains previous backups - so is increasing in size rapidly.
My backups have been ca 600 KB for months, but in the last week, have grown to 1.7MB and then to 3.1 MB.
Is there a way in Editorial to empty the Dropbox trash in Editorial, please?
(I realise that I could write a Python workflow to do so, but deleting files in the bowels of Editorial's directory structure makes me nervous!)
Thanks, Geezer.
I'm on iOS 8.1.3 - I was actually downloading the 8.3 update and then saw your message, and so cancelled the download.
I found a way in the end...
[Device Name]/Apps/Editorial/Documents/.DropboxTrash
My backups are down to ca 600 KB again.
(This also allowed me to delete a Local File called .md
- i.e. no file basename - that had been irritating me for a while)