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.
Library/module for Editorial via Pythonista?
-
@ccc sorry— I realise that the way I phrased that was unclear. I meant that I have all of the files from
gspread-master/gspread/
insite-packages/gspread/
(as you're saying it should be).Admittedly, my first use of
shutil.move
ended up depositing pygsheets files into the folder above site-package— the less said about that, the better... :) That said, I spent a little time tidying up my handling of paths, and I'm pretty sure I had everything in the right place before my final tests of pygsheets, and now gspread. Anything else it might be?Thanks for all the assistance thus far...
-
@jsamlarose47 Could you try restarting Editorial? Not 100% sure why right now, but it seems to help.
-
So... In
site-packages/gspread
you have these files? https://github.com/burnash/gspread/tree/master/gspreadYou probably figured this part out already but if not...
If you are used to using the unix command line then you can vaguely simulate that with https://github.com/cclauss/Ten-lines-or-less/blob/master/cd_ls_pwd.py
For example, in Editor Python Console:
>>> print(os.getcwd()) # pwd in unix /private/var/mobile/Containers/Data/Application/{UUID}/Documents >>> print(os.listdir('.')) # ls in unix ['dear_Sally.pdf', ..., ...] >>> os.chdir('..') # cd in unix >>> print(os.getcwd()) /private/var/mobile/Containers/Data/Application/{UUID} >>> print(os.listdir('.'))
-
See: https://forum.omz-software.com/topic/1438/own-python-modules
http://www.editorial-workflows.com/workflow/5841416039170048/ypL54IX63JY and http://www.editorial-workflows.com/workflow/5218285272432640/U8H7QaIxaJI might help yo get more Python functionality working in Editorial
-
@ccc Yep!
print os.listdir("site-packages/gspread") returns:
['__init__.py', 'client.py', 'exceptions.py', 'gspread', 'httpsession.py', 'models.py', 'ns.py', 'urls.py', 'utils.py']
print os.getcwd() returns:
/private/var/mobile/Containers/Data/Application/{UUID}/Library/Application Support/Commands
Presuming I'm in the right place there...
@olemoritz restarted, no joy...
And of course, the longer this continues the more I think I've just made a rudimentary error somewhere along the way... ;)
-
Can you please try putting the code in
~/Documents/site-packages/
? -
@jsamlarose47 A short explanation about the
~
part:- (If you've used a Unix shell before, you probably know this part already)
~
means "the user's home directory". That's where on most systems you have folders like "Documents", "Downloads", "Desktop", "Music", etc. - On iOS, you don't have a "home directory", because every app runs in its own sandbox. So on iOS, the "home directory" is the app's user data folder, which is the
/private/var/mobile/Containers/Data/Application/{UUID}
folder that you see in many paths. - Unlike a shell, Python doesn't automatically understand the
~
shortcut. You need to manually useos.path.expanduser(path)
to replace the~
with the actual home directory path.
Long story short, to move your module files to the correct location, this command should work:
shutil.move(os.path.expanduser("~/Library/Application Support/Commands/site-packages/gspread"), os.path.expanduser("~/Documents/site-packages/gspread"))
- (If you've used a Unix shell before, you probably know this part already)
-
Done. Looks like this is the fix for me. Haven't yet fully tested a connection to a spreadsheet, but at least I'm not getting any errors when trying to call gspread modules. Excellent. Thanks!
-
Epilogue!
A couple of questions for me to wrap this up:
1: Just so I've got this down for future reference, should my original script have been something more like the following?
#coding: utf-8 import workflow import urllib import zipfile import shutil import os # get the files url = 'https://github.com/burnash/gspread/archive/master.zip' print "downloading..." urllib.urlretrieve(url, 'gspread.zip') # expand the zip zip_ref = zipfile.ZipFile('gspread.zip', 'r') zip_ref.extractall() zip_ref.close() # move the required folder to the appropriate location shutil.move(os.path.expanduser("~/Library/Application Support/Commands/gspread-master/gspread"), os.path.expanduser("~/Documents/site-packages/gspread"))
Do I need to make the folder in ~/Documents/site-packages/ before I attempt to move something to it?
2: Is it easier to do this kind of work with Pythonista (stash/pip)? And if so, are modules installed via Pythonista also available to Editorial— does Pythonista also look at ~/Documents/site-packages/ or do they function independently?
Thanks again, all!
-
#coding: utf-8 import os import shutil import urllib import workflow import zipfile # get the files url = 'https://github.com/burnash/gspread/archive/master.zip' pkg_name = url.split('/')[4] # gspread zip_name = pkg_name + '.zip' print("downloading...") urllib.urlretrieve(url, zip_name) print("extracting...") with zipfile.ZipFile(zip_name) as in_file: in_file.extractall() srce_dir = os.path.join(os.getcwdu(), pkg_name + '-master', pkg_name) dest_dir = '~/Documents/site-packages' if not os.path.exists(dest_dir): os.makedirs(dest_dir) print('moving {} to {}...'.format(pkg_name, dest_dir)) shutil.move(srce_dir, dest_dir) print('done.')
-
In the context of the Pythonista app on iOS, there is a powerful and versatile module available for enhancing text editing and automation workflows called Editorial. Editorial is a Pythonista library that extends the capabilities of the app, primarily focusing on text processing, automation, and Markdown support. With Editorial, users can create custom workflows and scripts to automate tasks like text manipulation, document generation, and even web interactions. It provides an intuitive and user-friendly interface for building and managing these workflows, making it a popular choice for writers, developers, and anyone looking to streamline their productivity on iOS devices. Editorial's Pythonista module empowers users to harness the full potential of the app, enabling efficient content creation and automation within a mobile environment.