def handle_noargs(self, **options): self.logger = logging.getLogger('collectreqs') self.logger.setLevel(logging.INFO) console = logging.StreamHandler() console.setLevel(logging.INFO) console.setFormatter(logging.Formatter('%(message)s')) self.logger.addHandler(console) # HACK: we expect the test cases to spout warnings, don't want the user to see them and get upset if os.environ.has_key('TEST_SUPPRESS_STDERR'): console.setLevel(logging.ERROR) siteDir = commandUtil.getSiteDir() self.logger.debug('siteDir: %s' % siteDir) outName = '%s/build/management/allRequirements.txt' % siteDir subReqFileList = ( glob('%ssubmodules/*/requirements.txt' % siteDir) + glob('%sapps/*/management/requirements.txt' % siteDir) + glob('%smanagement/siteRequirements.txt' % siteDir)) builder = Builder() builder.applyRule(outName, subReqFileList, lambda: self.collect(outName, subReqFileList))
def handle(self, *args, **options): verbosity = int(options.get('verbosity', 0)) force = options.get('force', False) siteDir = getSiteDir() srcDir = os.path.join(siteDir, 'apps', 'geocamUtil', 'management', 'githooks') hookFiles = os.listdir(srcDir) dotGitDirs = ['%s.git' % siteDir] + glob.glob('%s.git/modules/submodules/*' % siteDir) for dotGitDir in dotGitDirs: tgtDir = os.path.join(dotGitDir, 'hooks') if not os.path.exists(tgtDir): dosys('mkdir -p %s' % tgtDir, verbosity) srcRelTgt = os.path.relpath(os.path.realpath(srcDir), os.path.realpath(tgtDir)) for f in hookFiles: tgtPath = os.path.join(tgtDir, f) if os.path.exists(tgtPath): if force: dosys('rm -f %s' % tgtPath, verbosity) else: continue srcPath = os.path.join(srcRelTgt, f) dosys('ln -s %s %s' % (srcPath, tgtPath), verbosity)
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): verbosity = int(options.get('verbosity', 0)) force = options.get('force', False) siteDir = getSiteDir() srcDir = os.path.join(siteDir, 'apps', 'geocamUtil', 'management', 'githooks') hookFiles = os.listdir(srcDir) dotGitDirs = ['%s.git' % siteDir] + glob.glob( '%s.git/modules/submodules/*' % siteDir) for dotGitDir in dotGitDirs: tgtDir = os.path.join(dotGitDir, 'hooks') if not os.path.exists(tgtDir): dosys('mkdir -p %s' % tgtDir, verbosity) srcRelTgt = os.path.relpath(os.path.realpath(srcDir), os.path.realpath(tgtDir)) for f in hookFiles: tgtPath = os.path.join(tgtDir, f) if os.path.exists(tgtPath): if force: dosys('rm -f %s' % tgtPath, verbosity) else: continue srcPath = os.path.join(srcRelTgt, f) dosys('ln -s %s %s' % (srcPath, tgtPath), verbosity)
def handle(self, *args, **options): verbosity = int(options.get('verbosity', 0)) compress = options.get('compress', False) siteDir = getSiteDir() staticRoot = getattr(settings, 'STATIC_ROOT', '%sbuild/static' % siteDir) # for cssDir in getattr(settings, 'GEOCAM_UTIL_PREPCSS_DIRS'): # fullDir = os.path.join(staticRoot, cssDir) # ret = os.chdir(fullDir) # if ret != 0: # if verbosity > 1: # print >> sys.stderr, ret # if verbosity > 1: # print 'about to compass %s' % fullDir # dosys('compass clean ', verbosity) # dosys('compass compile ', verbosity) # if verbosity > 1: # print 'done with compass' if compress: for compressFile in getattr(settings, 'GEOCAM_UTIL_COMPRESSCSS_FILES'): fullFile = os.path.join(staticRoot, compressFile) if verbosity > 1: print 'about to compress %s' % fullFile dosys('yuglify %s' % fullFile, verbosity) if verbosity > 1: print 'done compressing %s' % fullFile
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(self, *args, **options): siteDir = commandUtil.getSiteDir() builder = Builder() context = dict(((k, getattr(settings, k)) for k in dir(settings) if not k.startswith("_"))) context.update(dict(USER=os.getenv("USER"))) srcs = glob("%smanagement/preptemplates/*" % siteDir) for src in srcs: dst = "%sbuild/preptemplates/%s" % (siteDir, os.path.basename(src)) builder.applyRule(dst, [src], lambda: fillTemplate(src, dst, context))
def handle_noargs(self, **options): if not commandUtil.getConfirmationUseStatus('installreqs', self.help): return needSudo = not os.environ.has_key('VIRTUALENV') if needSudo: sudoStr = 'sudo ' else: sudoStr = '' siteDir = commandUtil.getSiteDir() dosys('%spip install -r %smanagement/requirements.txt' % (sudoStr, siteDir))
def handle_noargs(self, **options): siteDir = commandUtil.getSiteDir() builder = Builder() context = dict(((k, getattr(settings, k)) for k in dir(settings) if not k.startswith('_'))) context.update(dict(USER=os.environ['USER'])) srcs = glob('%smanagement/preptemplates/*' % siteDir) for src in srcs: dst = '%sbuild/preptemplates/%s' % (siteDir, os.path.basename(src)) builder.applyRule(dst, [src], lambda: fillTemplate(src, dst, context))
def handle(self, *args, **options): verbosity = int(options.get('verbosity', 0)) siteDir = getSiteDir() staticDir = getattr(settings, 'STATIC_ROOT', '%sbuild/static' % siteDir) bootstrapDir = os.path.join(staticDir, 'bootstrap') ret = os.chdir(bootstrapDir) if ret != 0: if verbosity > 1: print >> sys.stderr, ret if verbosity > 1: print 'about to grunt dist-css for bootstrap' dosys('grunt dist-css ', verbosity) if verbosity > 1: print 'done with grunt dist-css for bootstrap'
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
def handle(self, *args, **options): verbosity = int(options.get('verbosity', 0)) appsRoot = os.path.join(getattr(settings, 'PROJ_ROOT'), 'apps') siteDir = getSiteDir() staticRoot = getattr(settings, 'STATIC_ROOT', '%sbuild/static' % siteDir) fullCommand = self.getCommandPrefix() for entry in getattr(settings, 'XGDS_BROWSERIFY'): for source_filename in entry['source_filenames']: fullCommand += os.path.join(appsRoot, source_filename) + ' ' fullCommand += '-o ' + os.path.join(staticRoot, entry['output_filename']) if verbosity > 1: print 'about to browserify %s' % entry['output_filename'] dosys(fullCommand, verbosity) if verbosity > 1: print 'done with browserify' fullCommand = self.getCommandPrefix()
def handle_noargs(self, **options): self.logger = logging.getLogger('collectreqs') self.logger.setLevel(logging.INFO) console = logging.StreamHandler() console.setLevel(logging.INFO) console.setFormatter(logging.Formatter('%(message)s')) self.logger.addHandler(console) # HACK: we expect the test cases to spout warnings, don't want the user to see them and get upset if os.environ.has_key('TEST_SUPPRESS_STDERR'): console.setLevel(logging.ERROR) siteDir = commandUtil.getSiteDir() self.logger.debug('siteDir: %s' % siteDir) outName = '%s/build/management/allRequirements.txt' % siteDir subReqFileList = (glob('%ssubmodules/*/requirements.txt' % siteDir) + glob('%sapps/*/management/requirements.txt' % siteDir) + glob('%smanagement/siteRequirements.txt' % siteDir)) builder = Builder() builder.applyRule(outName, subReqFileList, lambda: self.collect(outName, subReqFileList))
def setUp(self): self.siteDir = commandUtil.getSiteDir() self.ps1 = '%sbuild/app1/prepStatus.txt' % self.siteDir self.ps2 = '%sbuild/app2/prepStatus.txt' % self.siteDir
def setUp(self): self.siteDir = commandUtil.getSiteDir() self.ptDir = '%s/build/preptemplates/' % self.siteDir
def setUp(self): self.siteDir = commandUtil.getSiteDir() self.rfile = '%s/build/management/appRequirements.txt' % self.siteDir os.system('rm -f %s' % self.rfile) os.environ['TEST_SUPPRESS_STDERR'] = '1'
#!/usr/bin/env python # __BEGIN_LICENSE__ # Copyright (C) 2008-2010 United States Government as represented by # the Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # __END_LICENSE__ import sys import os from geocamUtil.management.commandUtil import getSiteDir CONFIG_FILE = os.path.join(getSiteDir(), 'management', 'pylintrc.txt') DEFAULT_FLAGS = '-i y -r n -f parseable' def dosys(cmd): print 'running: %s' % cmd ret = os.system(cmd) if ret != 0: print 'warning: command exited with non-zero return value %d' % ret return ret def runpylint(paths): if not paths: paths = ['.'] # give helpful error if pylint is not installed ret = os.system('pylint --help > /dev/null') if ret != 0:
# CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. #__END_LICENSE__ # stop pylint from warning us that we "aren't using" imported test cases # pylint: disable=W0611 from geocamUtil.models.timestampDescriptorTest import TimestampDescriptorTest from geocamUtil.MultiSettingsTest import MultiSettingsTest from geocamUtil.anyjsonTest import AnyJsonTest from geocamUtil.models.UuidFieldTest import UuidFieldTest from geocamUtil.models.ExtrasFieldTest import ExtrasFieldTest from geocamUtil.models.jsonFieldTest import JsonFieldTest from geocamUtil.BuilderTest import BuilderTest from geocamUtil.InstallerTest import InstallerTest from geocamUtil.storeTest import StoreTest from geocamUtil.icons.rotateTest import IconsRotateTest from geocamUtil.icons.svgTest import IconsSvgTest # commandsTest is destructive and should only be run in the example site for geocamUtil from geocamUtil.management import commandUtil siteDir = commandUtil.getSiteDir() print 'siteDir:', siteDir if siteDir.endswith('geocamUtilWeb/example/'): from geocamUtil.management.commandsTest import (CollectReqsTest, InstallReqsTest, PrepTemplatesTest, PrepAppsTest, CollectMediaTest)
#!/usr/bin/env python # __BEGIN_LICENSE__ # Copyright (c) 2015, United States Government, as represented by the # Administrator of the National Aeronautics and Space Administration. # All rights reserved. # __END_LICENSE__ import sys import os from geocamUtil.management.commandUtil import getSiteDir, lintignore CONFIG_FILE = os.path.join(getSiteDir(), "management", "gjslintFlags.txt") THIS_DIR = os.path.dirname(os.path.realpath(__file__)) DEFAULT_FLAGS = "--unix_mode" def dosys(cmd, verbosity): if verbosity > 1: print >>sys.stderr, "running: %s" % cmd ret = os.system(cmd) if verbosity > 1: if ret != 0: print >>sys.stderr, "warning: command exited with non-zero return value %d" % ret return ret def rungjslint(paths, verbosity=1): if verbosity > 0: print >>sys.stderr, "### gjslint"
#!/usr/bin/env python # __BEGIN_LICENSE__ # Copyright (C) 2008-2010 United States Government as represented by # the Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # __END_LICENSE__ import sys import os import tempfile from geocamUtil.management.commandUtil import getSiteDir CONFIG_FILE = os.path.join(getSiteDir(), 'management', 'gjslintFlags.txt') THIS_DIR = os.path.dirname(os.path.realpath(__file__)) DEFAULT_FLAGS = '--unix_mode' def dosys(cmd): print 'running: %s' % cmd ret = os.system(cmd) if ret != 0: print 'warning: command exited with non-zero return value %d' % ret return ret def rungjslint(paths): if not paths: paths = ['.'] # give helpful error message if jsl is not installed
def setUp(self): self.siteDir = commandUtil.getSiteDir() self.bstaticDir = '%sbuild/static/' % self.siteDir
def handle_noargs(self, **options): print 'running app1 prep command' siteDir = commandUtil.getSiteDir() commandUtil.writeStatusFile('%sbuild/app1/prepStatus.txt' % siteDir, 'DONE')
# __BEGIN_LICENSE__ # Copyright (C) 2008-2010 United States Government as represented by # the Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # __END_LICENSE__ from geocamUtil.MultiSettingsTest import * from geocamUtil.anyjsonTest import * from geocamUtil.models.UuidFieldTest import * from geocamUtil.models.ExtrasFieldTest import * from geocamUtil.BuilderTest import * from geocamUtil.InstallerTest import * from geocamUtil.icons.rotateTest import * from geocamUtil.icons.svgTest import * # commandsTest is destructive and should only be run in the example site for geocamUtil from geocamUtil.management import commandUtil siteDir = commandUtil.getSiteDir() print 'siteDir:', siteDir if siteDir.endswith('geocamUtilWeb/example/'): from geocamUtil.management.commandsTest import *
def setUp(self): self.siteDir = commandUtil.getSiteDir() self.bmediaDir = '%sbuild/media/' % self.siteDir
import os import re import sys from glob import glob from geocamUtil.management.commandUtil import getSiteDir ###################################################################### # CHECKOUT_DIR, SCRIPT_NAME, USING_DJANGO_DEV_SERVER -- these are not # understood by Django but are used a lot below to calculate other # settings # can override CHECKOUT_DIR by setting the environment variable before # importing baseSettings DEFAULT_CHECKOUT_DIR = getSiteDir() CHECKOUT_DIR = os.environ.get('CHECKOUT_DIR', DEFAULT_CHECKOUT_DIR) SCRIPT_NAME = os.environ['DJANGO_SCRIPT_NAME'] if not SCRIPT_NAME.endswith('/'): SCRIPT_NAME += '/' USING_DJANGO_DEV_SERVER = ('runserver' in sys.argv) if USING_DJANGO_DEV_SERVER: # django dev server deployment won't work with other SCRIPT_NAME settings SCRIPT_NAME = '/' ###################################################################### # This section is for variables understood by Django.
# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. #__END_LICENSE__ import sys import os import re import tempfile from geocamUtil.management.commandUtil import getSiteDir STRIP_COMMENT = re.compile(r'#.*$') CONFIG_FILE = os.path.join(getSiteDir(), 'management', 'jslrc.txt') DEFAULT_FLAGS = '-nologo -nofilelisting' def dosys(cmd): print 'running: %s' % cmd ret = os.system(cmd) if ret != 0: print 'warning: command exited with non-zero return value %d' % ret return ret def runjsl(paths): if not paths: paths = ['.']
#!/usr/bin/env python # __BEGIN_LICENSE__ # Copyright (C) 2008-2010 United States Government as represented by # the Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # __END_LICENSE__ import sys import os import re from geocamUtil.management.commandUtil import getSiteDir STRIP_COMMENT = re.compile(r'#.*$') CONFIG_FILE = os.path.join(getSiteDir(), 'management', 'pep8Flags.txt') DEFAULT_FLAGS = '--ignore=E501 --show-pep8 --repeat' def dosys(cmd): print 'running: %s' % cmd ret = os.system(cmd) if ret != 0: print 'warning: command exited with non-zero return value %d' % ret return ret def readFlags(path): f = file(path, 'r') flags = [] for line in f: line = re.sub(STRIP_COMMENT, '', line)
#!/usr/bin/env python # __BEGIN_LICENSE__ #Copyright (c) 2015, United States Government, as represented by the #Administrator of the National Aeronautics and Space Administration. #All rights reserved. # __END_LICENSE__ import sys import os import re from geocamUtil.management.commandUtil import getSiteDir, lintignore, pipeToCommand STRIP_COMMENT = re.compile(r'#.*$') CONFIG_FILE = os.path.join(getSiteDir(), 'management', 'pep8Flags.txt') DEFAULT_FLAGS = '--ignore=E501 --show-source --show-pep8 --repeat' def dosys(cmd, verbosity): if verbosity > 1: print >> sys.stderr, 'running: %s' % cmd ret = os.system(cmd) if verbosity > 1: if ret != 0: print >> sys.stderr, 'warning: command exited with non-zero return value %d' % ret return ret def readFlags(path): f = file(path, 'r') flags = []
#!/usr/bin/env python # __BEGIN_LICENSE__ # Copyright (C) 2008-2010 United States Government as represented by # the Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # __END_LICENSE__ import sys import os import re import tempfile from geocamUtil.management.commandUtil import getSiteDir STRIP_COMMENT = re.compile(r"#.*$") CONFIG_FILE = os.path.join(getSiteDir(), "management", "jslrc.txt") DEFAULT_FLAGS = "-nologo -nofilelisting" def dosys(cmd): print "running: %s" % cmd ret = os.system(cmd) if ret != 0: print "warning: command exited with non-zero return value %d" % ret return ret def runjsl(paths): if not paths: paths = ["."]