def handle_noargs(self, **options): up = os.path.dirname appDir = up(up(up(os.path.abspath(__file__)))) print 'appDir:', appDir builder = Builder() # render svg to png if settings.GEOCAM_LENS_RENDER_SVG_ICONS: svgGlob = '%s/media_src/icons/*.svg' % appDir svgOutput = '%s/build/media/geocamLens/icons/map/' % appDir logging.debug('svgIcons %s %s' % (svgGlob, svgOutput)) for imPath in glob(svgGlob): svg.buildIcon(builder, imPath, outputDir=svgOutput) # link static stuff into build/media inst = Installer(builder) inst.installRecurseGlob('%s/static/*' % appDir, '%s/build/media' % appDir) # rotate pngs rotGlob = '%s/build/media/geocamLens/icons/map/*Point.png' % appDir rotOutput = '%s/build/media/geocamLens/icons/mapr' % appDir logging.debug('rotateIcons %s %s' % (rotGlob, rotOutput)) for imPath in glob(rotGlob): rotate.buildAllDirections(builder, imPath, outputDir=rotOutput)
def handle(self, *args, **options): up = os.path.dirname appDir = up(up(up(os.path.abspath(__file__)))) print 'appDir:', appDir builder = Builder() # render svg to png svgOutput = '%s/build/static/geocamLens/icons/map/' % appDir if settings.GEOCAM_LENS_RENDER_SVG_ICONS: svgGlob = '%s/media_src/icons/*.svg' % appDir logging.debug('svgIcons %s %s', svgGlob, svgOutput) for imPath in glob(svgGlob): svg.buildIcon(builder, imPath, outputDir=svgOutput) # link static stuff into build/media inst = Installer(builder) inst.installRecurseGlob('%s/static/*' % appDir, '%s/build/static' % appDir) # make highlighted versions of icons dstGlob = svgOutput + '*.png' logging.debug('highlightIcons %s', dstGlob) for dst in glob(dstGlob): if 'Highlighted' in dst: continue dstHighlighted = os.path.splitext(dst)[0] + 'Highlighted.png' halo.addHalo(builder, dst, dstHighlighted) # rotate pngs rotGlob = '%s/build/static/geocamLens/icons/map/*Point*.png' % appDir rotOutput = '%s/build/static/geocamLens/icons/mapr' % appDir logging.debug('rotateIcons %s %s', rotGlob, rotOutput) for imPath in glob(rotGlob): rotate.buildAllDirections(builder, imPath, outputDir=rotOutput)
def handleImportPaths(self, impPaths, options): inst = Installer() siteDir = commandUtil.getSiteDir() # make new-style static and media setup staticRoot = getattr(settings, 'STATIC_ROOT', '%sbuild/static' % siteDir) if not os.path.exists(staticRoot): os.makedirs(staticRoot) #if not os.path.exists(settings.MEDIA_ROOT): # mediaRootNoTrailingSlash = re.sub('/$', '', settings.MEDIA_ROOT) # os.symlink(staticRoot, mediaRootNoTrailingSlash) # install admin media djangoDir = os.path.dirname(os.path.realpath(django.__file__)) adminMediaDir = os.path.join(djangoDir, 'contrib', 'admin', 'media') inst.installRecurse(adminMediaDir, os.path.join(staticRoot, 'admin')) for impPath in impPaths: logging.debug('collectmedia app %s', impPath) appMod = __import__(impPath, fromlist=['dummy']) appPath = os.path.dirname(appMod.__file__) tryMediaPaths = ['%s/build/static' % appPath, '%s/build/media' % appPath, # legacy support '%s/static' % appPath] for mediaPath in tryMediaPaths: logging.debug('collectmedia app %s: checking for media in %s', impPath, mediaPath) if os.path.exists(mediaPath): inst.installRecurseGlob('%s/*' % mediaPath, '%sbuild/static' % siteDir) break
def handleImportPaths(self, impPaths, options): for impPath in impPaths: logging.debug('collectbinaries app %s', impPath) appMod = __import__(impPath, fromlist=['dummy']) appPath = os.path.dirname(appMod.__file__) binPath = '%s/bin' % appPath logging.debug('collectbinaries app %s: checking for binaries in %s', impPath, binPath) if os.path.exists(binPath): siteDir = commandUtil.getSiteDir() inst = Installer() inst.installRecurseGlob('%s/*' % binPath, '%sbuild/bin' % siteDir)
def handle_noargs(self, **options): up = os.path.dirname appDir = up(up(up(os.path.abspath(__file__)))) builder = Builder() # minify javascript files into geocamAwareMin.js srcDir = '%s/static/' % appDir srcPairs = [(srcDir + suffix, doMinify) for suffix, doMinify in JS_MODULES] minifyJs(builder, '%s/build/static/geocamAware/js/geocamAwareMin.js' % appDir, srcPairs) # link static stuff into build/static inst = Installer(builder) inst.installRecurseGlob('%s/static/*' % appDir, '%s/build/static' % appDir)
def generateNotebookDir(self, builder, appDir): assert settings.GEOCAM_UTIL_INSTALLER_USE_SYMLINKS, \ 'generateNotebookDir: very error-prone if not using symlinks' notebookDir = os.path.join(appDir, 'notebook') jupyterDir = os.path.join(notebookDir, 'jupyter') if not os.path.exists(jupyterDir): os.makedirs(jupyterDir) ipythonDir = os.path.join(notebookDir, 'ipython') ipythonProfileDir = os.path.join(ipythonDir, 'profile_default') if not os.path.exists(ipythonProfileDir): os.makedirs(ipythonProfileDir) # generate initial non-shared config files if not already present jupyterConfig = os.path.join(jupyterDir, 'jupyter_notebook_config.py') if not os.path.exists(jupyterConfig): jupyterConfigTemplate = os.path.join(appDir, 'management', 'templates', 'jupyter_notebook_config.py') shutil.copyfile(jupyterConfigTemplate, jupyterConfig) ipythonConfig = os.path.join(ipythonProfileDir, 'ipython_config.py') if not os.path.exists(ipythonConfig): ipythonConfigTemplate = os.path.join(appDir, 'management', 'templates', 'ipython_config.py') shutil.copyfile(ipythonConfigTemplate, ipythonConfig) # symlink the contents of the notebook directory under the <site>/var directory installer = Installer(builder) varNotebookDir = os.path.join(settings.VAR_ROOT, 'notebook') installer.installRecurse(notebookDir, varNotebookDir) # make the directory to hold notebook files, if it doesn't already exist dataDir = os.path.join(settings.DATA_ROOT, 'notebook') if not os.path.exists(dataDir): os.makedirs(dataDir) # symlink extra startup files (these files will be site-specific, not part of # the xgds_plot app) startupDir = os.path.join(varNotebookDir, 'ipython', 'profile_default', 'startup') for f in settings.XGDS_PLOT_NOTEBOOK_STARTUP_FILES: installer.installFile(f, startupDir)
def handleImportPaths(self, impPaths, options): inst = Installer() siteDir = commandUtil.getSiteDir() # make new-style static and media setup staticRoot = getattr(settings, 'STATIC_ROOT', '%sbuild/static' % siteDir) if not os.path.exists(staticRoot): os.makedirs(staticRoot) #if not os.path.exists(settings.MEDIA_ROOT): # mediaRootNoTrailingSlash = re.sub('/$', '', settings.MEDIA_ROOT) # os.symlink(staticRoot, mediaRootNoTrailingSlash) # install admin media djangoDir = os.path.dirname(os.path.realpath(django.__file__)) adminMediaDir = os.path.join(djangoDir, 'contrib', 'admin', 'media') inst.installRecurse(adminMediaDir, os.path.join(staticRoot, 'admin')) for impPath in impPaths: logging.debug('collectmedia app %s', impPath) appMod = __import__(impPath, fromlist=['dummy']) appPath = os.path.dirname(appMod.__file__) tryMediaPaths = [ '%s/build/static' % appPath, '%s/build/media' % appPath, # legacy support '%s/static' % appPath ] for mediaPath in tryMediaPaths: logging.debug('collectmedia app %s: checking for media in %s', impPath, mediaPath) if os.path.exists(mediaPath): inst.installRecurseGlob('%s/*' % mediaPath, '%sbuild/static' % siteDir) break
def handle(self, *args, **options): from django.db import models if args: # user specified apps to prep impPaths = args else: # user did not specify, default to all apps in INSTALLED_APPS from django.conf import settings impPaths = settings.INSTALLED_APPS for impPath in impPaths: logging.debug('collectmedia app %s' % impPath) appMod = __import__(impPath, fromlist=['dummy']) appPath = os.path.dirname(appMod.__file__) tryMediaPaths = ['%s/build/media' % appPath, '%s/static' % appPath] for mediaPath in tryMediaPaths: logging.debug('collectmedia app %s: checking for media in %s' % (impPath, mediaPath)) if os.path.exists(mediaPath): siteDir = commandUtil.getSiteDir() inst = Installer() inst.installRecurseGlob('%s/*' % mediaPath, '%sbuild/media' % siteDir) break