-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Two new dev scripts to copy generated examples images to/from a shared
dropbox location so that they can be used with readthedocs
- Loading branch information
1 parent
4af4233
commit edc1519
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
''' | ||
This script copies the examples_images to a zipfile in a dropbox location | ||
so that it can be read by download_examples_images_from_dropbox.py. This | ||
should be run after a successful run of run_examples.py. | ||
''' | ||
|
||
import os, sys, zipfile, glob | ||
|
||
__all__ = ['copy_examples_images_to_dropbox'] | ||
|
||
# add your dropbox location here | ||
possible_dropbox_directories = [ | ||
'~/Dropbox/Projects/Shared Brian/Documentation example images', | ||
] | ||
|
||
def copy_examples_images_to_dropbox(): | ||
|
||
zipname = None | ||
for dirname in possible_dropbox_directories: | ||
dirname = os.path.expanduser(dirname) | ||
if os.path.exists(dirname): | ||
zipname = os.path.join(dirname, 'doc_example_images.zip') | ||
|
||
if zipname is None: | ||
print 'Cannot find Dropbox directory' | ||
return | ||
|
||
imgs = glob.glob('../../../docs_sphinx/examples_images/*.png') | ||
|
||
with zipfile.ZipFile(zipname, 'w') as z: | ||
for f in imgs: | ||
base, fname = os.path.split(f) | ||
z.write(f, fname) | ||
|
||
|
||
if __name__=='__main__': | ||
copy_examples_images_to_dropbox() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
''' | ||
Script to download and extract saved examples images from a shared Dropbox | ||
file location. This is used for the documentation system. Images generated | ||
on one developer's computer are copied to a dropbox file (by the script | ||
copy_examples_images_to_dropbox.py) and then readthedocs script can just | ||
download the images (which can take a couple of hours to generate so that | ||
wouldn't work directly on readthedocs). | ||
''' | ||
|
||
import os, zipfile, urllib2 | ||
|
||
zipfile_url = 'https://www.dropbox.com/s/uqb44b9t1gpvy61/doc_example_images.zip?dl=1' | ||
|
||
def download_examples_images_from_dropbox(): | ||
outputdir = '../../../docs_sphinx/examples_images' | ||
if not os.path.exists(outputdir): | ||
os.mkdir(outputdir) | ||
outfname = os.path.join(outputdir, 'doc_example_images.zip') | ||
f = urllib2.urlopen(zipfile_url) | ||
open(outfname, 'wb').write(f.read()) | ||
z = zipfile.ZipFile(outfname, 'r') | ||
z.extractall(outputdir) | ||
|
||
if __name__=='__main__': | ||
download_examples_images_from_dropbox() | ||
|