Permalink
Browse files

created site from template

  • Loading branch information...
0 parents commit 91a86a81a89c3382382cfa6e550e6153b043fcb0 @trey0 trey0 committed May 13, 2012
15 .gitignore
@@ -0,0 +1,15 @@
+*.pyc
+media/ugc
+docs/_build/
+src/
+pip-log.txt
+media/js/*.r*.js
+media/css/*.r*.css
+*DS_Store
+*.egg-info
+*~
+/sourceme.sh
+/dev.db
+/settings.py
+/sourcme.sh
+/build/
278 LICENSE
@@ -0,0 +1,278 @@
+NASA OPEN SOURCE AGREEMENT VERSION 1.3
+
+THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE,
+REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN
+COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE UNITED STATES GOVERNMENT AS
+REPRESENTED BY THE GOVERNMENT AGENCY LISTED BELOW ("GOVERNMENT AGENCY").
+THE UNITED STATES GOVERNMENT, AS REPRESENTED BY GOVERNMENT AGENCY, IS AN
+INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT DISTRIBUTIONS OR
+REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES,
+DISTRIBUTES, MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED
+HEREIN, OR ANY PART THEREOF, IS, BY THAT ACTION, ACCEPTING IN FULL THE
+RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT.
+
+Government Agency: NASA Ames Research Center
+Government Agency Original Software Designation: NASA Ames Research Center
+Government Agency Original Software Title: GeoCam
+User Registration Requested. Please Visit http://opensource.arc.nasa.gov/
+Government Agency Point of Contact for Original Software: Terry Fong
+
+DEFINITIONS
+
+
+A. "Contributor" means Government Agency, as the developer of
+ the Original Software, and any entity that makes a
+ Modification.
+B. "Covered Patents" mean patent claims licensable by a
+ Contributor that are necessarily infringed by the use or sale
+ of its Modification alone or when combined with the Subject
+ Software.
+C. "Display" means the showing of a copy of the Subject
+ Software, either directly or by means of an image, or any
+ other device.
+D. "Distribution" means conveyance or transfer of the Subject
+ Software, regardless of means, to another.
+E. "Larger Work" means computer software that combines Subject
+ Software, or portions thereof, with software separate from
+ the Subject Software that is not governed by the terms of
+ this Agreement.
+F. "Modification" means any alteration of, including addition
+ to or deletion from, the substance or structure of either the
+ Original Software or Subject Software, and includes
+ derivative works, as that term is defined in the Copyright
+ Statute, 17 USC 101. However, the act of including Subject
+ Software as part of a Larger Work does not in and of itself
+ constitute a Modification.
+G. "Original Software" means the computer software first
+ released under this Agreement by Government Agency with
+ Government Agency designation NASA Ames Research Center and
+ entitled GeoCam, including source code, object
+ code and accompanying documentation, if any.
+H. "Recipient" means anyone who acquires the Subject Software
+ under this Agreement, including all Contributors.
+I. "Redistribution" means Distribution of the Subject Software
+ after a Modification has been made.
+J. "Reproduction" means the making of a counterpart, image or
+ copy of the Subject Software.
+K. "Sale" means the exchange of the Subject Software for money
+ or equivalent value.
+L. "Subject Software" means the Original Software,
+ Modifications, or any respective parts thereof.
+M. "Use" means the application or employment of the Subject
+ Software for any purpose.
+
+ 1. GRANT OF RIGHTS
+
+ A. Under Non-Patent Rights: Subject to the terms and conditions
+ of this Agreement, each Contributor, with respect to its own
+ contribution to the Subject Software, hereby grants to each
+ Recipient a non-exclusive, world-wide, royalty-free license
+ to engage in the following activities pertaining to the
+ Subject Software:
+
+ 1. Use
+ 2. Distribution
+ 3. Reproduction
+ 4. Modification
+ 5. Redistribution
+ 6. Display
+
+ B. Under Patent Rights: Subject to the terms and conditions of
+ this Agreement, each Contributor, with respect to its own
+ contribution to the Subject Software, hereby grants to each
+ Recipient under Covered Patents a non-exclusive, world-wide,
+ royalty-free license to engage in the following activities
+ pertaining to the Subject Software:
+
+ 1. Use
+ 2. Distribution
+ 3. Reproduction
+ 4. Sale
+ 5. Offer for Sale
+
+ C. The rights granted under Paragraph B. also apply to the
+ combination of a Contributor's Modification and the Subject
+ Software if, at the time the Modification is added by the
+ Contributor, the addition of such Modification causes the
+ combination to be covered by the Covered Patents. It does
+ not apply to any other combinations that include a
+ Modification.
+
+ D. The rights granted in Paragraphs A. and B. allow the
+ Recipient to sublicense those same rights. Such sublicense
+ must be under the same terms and conditions of this
+ Agreement.
+
+ 2. OBLIGATIONS OF RECIPIENT
+
+ A. Distribution or Redistribution of the Subject Software must
+ be made under this Agreement except for additions covered
+ under paragraph 3H.
+
+ 1. Whenever a Recipient distributes or redistributes the
+ Subject Software, a copy of this Agreement must be
+ included with each copy of the Subject Software; and
+ 2. If Recipient distributes or redistributes the Subject
+ Software in any form other than source code, Recipient
+ must also make the source code freely available, and must
+ provide with each copy of the Subject Software
+ information on how to obtain the source code in a
+ reasonable manner on or through a medium customarily used
+ for software exchange.
+
+ B. Each Recipient must ensure that the following copyright
+ notice appears prominently in the Subject Software:
+
+ Copyright (C) 2006-2010 United States Government as represented by
+ the Administrator of the National Aeronautics and Space Administration.
+ All Rights Reserved.
+
+
+ C. Each Contributor must characterize its alteration of the
+ Subject Software as a Modification and must identify itself
+ as the originator of its Modification in a manner that
+ reasonably allows subsequent Recipients to identify the
+ originator of the Modification. In fulfillment of these
+ requirements, Contributor must include a file (e.g., a change
+ log file) that describes the alterations made and the date of
+ the alterations, identifies Contributor as originator of the
+ alterations, and consents to characterization of the
+ alterations as a Modification, for example, by including a
+ statement that the Modification is derived, directly or
+ indirectly, from Original Software provided by Government
+ Agency. Once consent is granted, it may not thereafter be
+ revoked.
+
+ D. A Contributor may add its own copyright notice to the Subject
+ Software. Once a copyright notice has been added to the
+ Subject Software, a Recipient may not remove it without the
+ express permission of the Contributor who added the notice.
+
+ E. A Recipient may not make any representation in the Subject
+ Software or in any promotional, advertising or other material
+ that may be construed as an endorsement by Government Agency
+ or by any prior Recipient of any product or service provided
+ by Recipient, or that may seek to obtain commercial advantage
+ by the fact of Government Agency's or a prior Recipient's
+ participation in this Agreement.
+
+ F. In an effort to track usage and maintain accurate records of
+ the Subject Software, each Recipient, upon receipt of the
+ Subject Software, is requested to register with Government
+ Agency by visiting the following website:
+ http://opensource.arc.nasa.gov/. Recipient's name and
+ personal information shall be used for statistical purposes
+ only. Once a Recipient makes a Modification available, it is
+ requested that the Recipient inform Government Agency at the
+ web site provided above how to access the Modification.
+
+ G. Each Contributor represents that that its Modification is
+ believed to be Contributor's original creation and does not
+ violate any existing agreements, regulations, statutes or
+ rules, and further that Contributor has sufficient rights to
+ grant the rights conveyed by this Agreement.
+
+ H. A Recipient may choose to offer, and to charge a fee for,
+ warranty, support, indemnity and/or liability obligations to
+ one or more other Recipients of the Subject Software. A
+ Recipient may do so, however, only on its own behalf and not
+ on behalf of Government Agency or any other Recipient. Such
+ a Recipient must make it absolutely clear that any such
+ warranty, support, indemnity and/or liability obligation is
+ offered by that Recipient alone. Further, such Recipient
+ agrees to indemnify Government Agency and every other
+ Recipient for any liability incurred by them as a result of
+ warranty, support, indemnity and/or liability offered by such
+ Recipient.
+
+ I. A Recipient may create a Larger Work by combining Subject
+ Software with separate software not governed by the terms of
+ this agreement and distribute the Larger Work as a single
+ product. In such case, the Recipient must make sure Subject
+ Software, or portions thereof, included in the Larger Work is
+ subject to this Agreement.
+
+ J. Notwithstanding any provisions contained herein, Recipient is
+ hereby put on notice that export of any goods or technical
+ data from the United States may require some form of export
+ license from the U.S. Government. Failure to obtain
+ necessary export licenses may result in criminal liability
+ under U.S. laws. Government Agency neither represents that a
+ license shall not be required nor that, if required, it shall
+ be issued. Nothing granted herein provides any such export
+ license.
+
+ 3. DISCLAIMER OF WARRANTIES AND LIABILITIES; WAIVER AND INDEMNIFICATION
+
+ A. No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT
+ ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR
+ STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT
+ THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY
+ IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY
+ WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY
+ WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE
+ SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER,
+ CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR
+ RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE,
+ SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM
+ USE OF THE SUBJECT SOFTWARE. FURTHER, GOVERNMENT AGENCY
+ DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-
+ PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND
+ DISTRIBUTES IT "AS IS."
+
+ B. Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL
+ CLAIMS AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS
+ AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF
+ RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY
+ LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING
+ FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON,
+ OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE,
+ RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED STATES
+ GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS
+ ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW.
+ RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE
+ IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
+
+
+ 4. GENERAL TERMS
+
+ A. Termination: This Agreement and the rights granted hereunder
+ will terminate automatically if a Recipient fails to comply
+ with these terms and conditions, and fails to cure such
+ noncompliance within thirty (30) days of becoming aware of
+ such noncompliance. Upon termination, a Recipient agrees to
+ immediately cease use and distribution of the Subject
+ Software. All sublicenses to the Subject Software properly
+ granted by the breaching Recipient shall survive any such
+ termination of this Agreement.
+
+ B. Severability: If any provision of this Agreement is invalid
+ or unenforceable under applicable law, it shall not affect
+ the validity or enforceability of the remainder of the terms
+ of this Agreement.
+
+ C. Applicable Law: This Agreement shall be subject to United
+ States federal law only for all purposes, including, but not
+ limited to, determining the validity of this Agreement, the
+ meaning of its provisions and the rights, obligations and
+ remedies of the parties.
+
+ D. Entire Understanding: This Agreement constitutes the entire
+ understanding and agreement of the parties relating to
+ release of the Subject Software and may not be superseded,
+ modified or amended except by further written agreement duly
+ executed by the parties.
+
+ E. Binding Authority: By accepting and using the Subject
+ Software under this Agreement, a Recipient affirms its
+ authority to bind the Recipient to all terms and conditions
+ of this Agreement and that that Recipient hereby agrees to
+ all terms and conditions herein.
+
+ F. Point of Contact: Any Recipient contact with Government
+ Agency is to be directed to the designated representative as
+ follows:
+
+ Terry Fong
+ Terry.Fong@nasa.gov
7 README.rst
@@ -0,0 +1,7 @@
+Fill me in
+
+.. o __BEGIN_LICENSE__
+.. o Copyright (C) 2008-2010 United States Government as represented by
+.. o the Administrator of the National Aeronautics and Space Administration.
+.. o All Rights Reserved.
+.. o __END_LICENSE__
0 __init__.py
No changes.
0 apps/__init__.py
No changes.
0 apps/placeholder.txt
No changes.
1 bin/placeholder.txt
@@ -0,0 +1 @@
+A place to put site-level scripts.
72 djangoWsgi.py
@@ -0,0 +1,72 @@
+# __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 os
+import sys
+import tempfile
+import re
+
+
+def getEnvironmentFromSourceMe(d='.'):
+ # pick up environment variables from sourceme
+ fd, varsFile = tempfile.mkstemp('djangoWsgiSourceMe.txt')
+ os.close(fd)
+
+ ret = os.system('bash -c "(source %s/sourceme.sh && printenv > %s)"' % (d, varsFile))
+ if ret != 0:
+ varsFile = '%s/vars.txt' % d
+ print >> sys.stderr, 'djangoWsgi.py: could not auto-generate environment from sourceme.sh, trying to fall back to manually generated file %s' % varsFile
+ # fallback: user can manually generate vars.txt file by sourcing sourceme.sh and running 'printenv > vars.txt'
+
+ varsIn = file(varsFile, 'r')
+ for line in varsIn:
+ line = line[:-1] # chop final cr
+ if '=' not in line or '=()' in line:
+ continue
+ var, val = line.split('=', 1)
+ os.environ[var] = val
+ varsIn.close()
+ try:
+ os.unlink(varsFile)
+ except OSError:
+ pass
+
+ # set up virtualenv if needed
+ if 'VIRTUAL_ENV' in os.environ:
+ activateFile = '%s/bin/activate_this.py' % os.environ['VIRTUAL_ENV']
+ execfile(activateFile, {'__file__': activateFile})
+
+ # add any new entries from PYTHONPATH to Python's sys.path
+ if 'PYTHONPATH' in os.environ:
+ envPath = re.sub(':$', '', os.environ['PYTHONPATH'])
+ sys.path = envPath.split(':') + sys.path
+
+
+def sendError(start_response, text):
+ start_response(text, [('Content-type', 'text/html')])
+ return ["""<html>
+ <head><title>%s</title></head>
+ <body><h1>%s</h1></body>
+</html>
+ """ % (text, text)]
+
+
+def downForMaintenance(environ, start_response):
+ import stat
+ import time
+ d = os.path.dirname(os.path.realpath(__file__))
+ downFile = os.path.join(d, 'DOWN_FOR_MAINTENANCE')
+ downMtime = os.stat(downFile)[stat.ST_MTIME]
+ downTimeString = time.strftime('%Y-%m-%d %H:%M %Z', time.localtime(downMtime))
+ return sendError(start_response, '503 Down for maintenance since %s' % downTimeString)
+
+thisDir = os.path.dirname(os.path.realpath(__file__))
+getEnvironmentFromSourceMe(thisDir)
+if os.path.exists(os.path.join(thisDir, 'DOWN_FOR_MAINTENANCE')):
+ application = downForMaintenance
+else:
+ from django.core.handlers.wsgi import WSGIHandler
+ application = WSGIHandler()
27 manage.py
@@ -0,0 +1,27 @@
+#!/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 os
+import sys
+
+# try to bootstrap before hooking into django management stuff
+if 'bootstrap' in sys.argv:
+ extraArgs = sys.argv[2:]
+else:
+ extraArgs = []
+ret = os.spawnl(os.P_WAIT, sys.executable, sys.executable,
+ '%s/management/bootstrap.py' % os.path.dirname(__file__),
+ *extraArgs)
+if ret != 0 or extraArgs:
+ sys.exit(ret)
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geocamBayCop.settings")
+
+ from django.core.management import execute_from_command_line
+
+ execute_from_command_line(sys.argv)
307 management/bootstrap.py
@@ -0,0 +1,307 @@
+#!/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__
+
+"""
+This bootstrap script does the first stage of prep work for a Django
+site that consists of multiple apps pulled in from separate repos via
+git submodules. The script does just enough so that our subsequent
+Django management commands will work -- they need Django to be installed
+and minimally configured, and they need the apps to be present
+and linked into the right place relative to the PYTHONPATH.
+
+This script is intended to be generic across sites. Please don't put
+any site-specific customizations in here. If you need to modify it,
+please check your changes into
+geocamDjangoSiteSkeleton/skel/bin/bootstrap.py so other sites can
+benefit. Normally we would put code like this in geocamUtil, but the
+whole reason we need a bootstrap step is to make sure things like
+geocamUtil are available...
+"""
+
+import os
+import sys
+from glob import glob
+import logging
+from random import choice
+import re
+
+DEFAULT_SITE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+SOURCEME_NAME = 'sourceme.sh'
+SETTINGS_NAME = 'settings.py'
+STATUS_PATH_TEMPLATE = 'build/management/bootstrap/%sStatus.txt'
+
+ACTIONS = (dict(name='gitInitSubmodules',
+ desc="Init and update submodules",
+ confirm=True),
+ dict(name='gitSubmodulesMasterBranch',
+ desc='Set submodules to be on their master branch for development',
+ confirm=True),
+ #dict(name='linkSubmodules',
+ # desc='Link submodules into apps directory',
+ # confirm=True),
+ dict(name='installSubModuleRequirements',
+ desc='Install Python modules listed in the requirements for each submodule',
+ confirm=True),
+ dict(name='installSiteRequirements',
+ desc='Install Python modules listed in the site-level requirements',
+ confirm=True),
+ dict(name='genSourceme',
+ needed='needSourceme',
+ desc='Create initial sourceme.sh file'),
+ dict(name='genSettings',
+ needed='needSettings',
+ desc='Create initial settings.py file'),
+ )
+ACTION_DICT = dict([(a['name'], a) for a in ACTIONS])
+
+
+def getConfirmation(opts, actionStr):
+ if opts.yes:
+ sys.stdout.write(actionStr + '? [Y/n] ')
+ print 'y'
+ return True
+ else:
+ while 1:
+ sys.stdout.write(actionStr + '? [Y/n] ')
+ response = raw_input().strip().lower()
+ if not response:
+ return True
+ elif response == 'y':
+ return True
+ elif response == 'n':
+ return False
+
+
+def dosys(cmd, continueOnError=False):
+ if cmd.startswith('sudo'):
+ # force print before user gets password prompt
+ print 'running: ' + cmd
+ else:
+ logging.info('Running: ' + cmd)
+ ret = os.system(cmd)
+ if ret != 0:
+ if continueOnError:
+ logging.warning('WARNING: Command returned non-zero return value %d' % ret)
+ else:
+ logging.error('ERROR: Command returned non-zero return value %d' % ret)
+ sys.exit(1)
+
+
+def writeFileMakeDir(path, text):
+ dir = os.path.dirname(path)
+ if not os.path.exists(dir):
+ os.makedirs(dir)
+ f = file(path, 'w')
+ f.write(text + '\n')
+ f.close()
+
+
+def fillTemplate(inputFile, outputFile, context):
+ if os.path.exists(outputFile):
+ logging.warning('WARNING: File %s exists, not overwriting. Move current version out of the way to regenerate' % outputFile)
+ return
+
+ logging.info('generating %s' % outputFile)
+
+ from django.template import Template, Context
+ from django.conf import settings
+ if not settings.configured:
+ settings.configure()
+ tmpl = Template(file(inputFile, 'r').read())
+ text = tmpl.render(Context(context))
+ file(outputFile, 'w').write(text)
+
+######################################################################
+# ACTION DEFINITIONS
+
+
+def gitInitSubmodules(opts):
+ dosys('git submodule init')
+ dosys('git submodule update')
+
+
+def gitSubmodulesMasterBranch(opts):
+ # avoid "(no branch)"
+ dosys('git submodule foreach git checkout master')
+
+
+def linkSubmodules(opts):
+ if not os.path.exists('apps'):
+ os.mkdir('apps')
+ # assumes each submodule app has a models dir or a models.py file
+ submoduleAppDirs = [os.path.dirname(d) for d in glob('submodules/*/*/models*')]
+ for src in submoduleAppDirs:
+ appName = os.path.basename(src)
+ relativeSrc = '../%s' % src
+ dst = 'apps/%s' % appName
+ if os.path.lexists(dst):
+ logging.debug(' %s -> %s skipped (already exists)' % (dst, relativeSrc))
+ else:
+ logging.debug(' %s -> %s' % (dst, relativeSrc))
+ os.symlink(relativeSrc, dst)
+
+
+def hasRequirements(reqsFile):
+ for line in file(reqsFile, 'r'):
+ if not re.match(r'^\s*(\#.*)?$', line):
+ return True
+ return False
+
+
+def installRequirements(reqsFile):
+ needSudo = 'VIRTUAL_ENV' not in os.environ
+ if needSudo:
+ sudoStr = 'sudo '
+ else:
+ sudoStr = ''
+ if hasRequirements(reqsFile):
+ dosys('%spip install -r %s' % (sudoStr, reqsFile))
+ else:
+ logging.info('requirements file %s is empty' % reqsFile)
+
+
+def installSubModuleRequirements(opts):
+ for reqs in glob('submodules/*/requirements.txt'):
+ installRequirements(reqs)
+
+
+def installSiteRequirements(opts):
+ installRequirements('management/siteRequirements.txt')
+
+
+def needSourceme(opts):
+ return not os.path.exists(SOURCEME_NAME)
+
+
+def genSourceme(opts):
+ fillTemplate('management/templates/%s' % SOURCEME_NAME,
+ SOURCEME_NAME,
+ dict(virtualEnvDir=os.environ.get('VIRTUAL_ENV', None),
+ parentDir=os.path.dirname(os.path.abspath(os.getcwd())),
+ appsDir=os.path.abspath('apps')
+ ))
+
+
+def needSettings(opts):
+ return not os.path.exists(SETTINGS_NAME)
+
+
+def genSettings(opts):
+ secretKey = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
+
+ fillTemplate('management/templates/%s' % SETTINGS_NAME,
+ SETTINGS_NAME,
+ dict(secretKey=secretKey))
+
+
+def needAction(opts, action):
+ statusFile = STATUS_PATH_TEMPLATE % action['name']
+ if os.path.exists(statusFile):
+ return file(statusFile, 'r').read().strip()
+ else:
+ return False
+
+######################################################################
+# TOP-LEVEL CODE
+
+
+def doAction(opts, action):
+ status = 'NEEDED'
+
+ # check if we need to do the action
+ neededName = action.get('needed', None)
+ if neededName:
+ # special check function defined for this action
+ neededFunc = globals()[neededName]
+ actionIsNeeded = neededFunc(opts)
+ if not actionIsNeeded:
+ status = 'NOT_NEEDED'
+ else:
+ # standard check function
+ checkStatus = needAction(opts, action)
+ if checkStatus:
+ status = checkStatus
+
+ if status != 'NEEDED':
+ if opts.retry:
+ logging.info('Would skip %s, status is %s, but running in retry mode' % (action['name'], status))
+ else:
+ logging.info('Skipping step %s, status is %s' % (action['name'], status))
+ return
+
+ # confirm with user
+ if (opts.retry or 'confirm' in action) and not getConfirmation(opts, action['desc']):
+ writeFileMakeDir(STATUS_PATH_TEMPLATE % action['name'], 'UNWANTED')
+ return
+
+ # do the action
+ actionFunc = globals()[action['name']]
+ actionFunc(opts)
+
+ # mark completion (unless special check function is defined)
+ if not neededName:
+ writeFileMakeDir(STATUS_PATH_TEMPLATE % action['name'], 'DONE')
+
+
+def doit(opts, args):
+ os.chdir(opts.siteDir)
+ if not opts.retry and os.path.exists('build/management/bootstrap/bootstrapStatus.txt'):
+ sys.exit(0)
+ print 'Bootstrapping...'
+
+ logging.basicConfig(level=(logging.WARNING - opts.verbose * 10),
+ format='%(message)s')
+
+ if args:
+ for arg in args:
+ if arg not in ACTION_DICT:
+ print >>sys.stderr, 'ERROR: there is no action %s' % arg
+ print >>sys.stderr, 'Available actions are: %s' % (' '.join([a['name'] for a in ACTIONS]))
+ sys.exit(1)
+ actions = [ACTION_DICT[arg] for arg in args]
+ else:
+ actions = ACTIONS
+
+ logging.info('Working in %s' % os.getcwd())
+ for action in actions:
+ doAction(opts, action)
+
+ # mark overall completion
+ writeFileMakeDir(STATUS_PATH_TEMPLATE % 'bootstrap', 'DONE')
+
+ print '\nFinished bootstrapping\n'
+
+ sys.path.insert(0, os.path.dirname(opts.siteDir))
+ from geocamBayCop.djangoWsgi import getEnvironmentFromSourceMe
+ getEnvironmentFromSourceMe()
+
+
+def main():
+ import optparse
+ parser = optparse.OptionParser('usage: %prog [action1 action2 ...]')
+ parser.add_option('-y', '--yes',
+ action='store_true', default=False,
+ help='Automatically answer yes to all confirmation questions')
+ parser.add_option('-s', '--siteDir',
+ default=DEFAULT_SITE_DIR,
+ help='Site directory to work in [%default]')
+ parser.add_option('-v', '--verbose',
+ action='count', default=1,
+ help='Increase verbosity, can specify multiple times')
+ parser.add_option('-q', '--quiet',
+ action='count', default=0,
+ help='Decrease verbosity, can specify multiple times')
+ parser.add_option('-r', '--retry',
+ action='store_true', default=False,
+ help='Ask user if they want to re-run steps marked as done')
+ opts, args = parser.parse_args()
+ opts.verbose -= opts.quiet
+ doit(opts, args)
+
+if __name__ == '__main__':
+ main()
124 management/jslrc.txt
@@ -0,0 +1,124 @@
+#
+# Configuration File for JavaScript Lint 0.3.0
+# Developed by Matthias Miller (http://www.JavaScriptLint.com)
+#
+# This configuration file can be used to lint a collection of scripts, or to enable
+# or disable warnings for scripts that are linted via the command line.
+#
+
+### Warnings
+# Enable or disable warnings based on requirements.
+# Use "+WarningName" to display or "-WarningName" to suppress.
+#
++no_return_value # function {0} does not always return a value
++duplicate_formal # duplicate formal argument {0}
++equal_as_assign # test for equality (==) mistyped as assignment (=)?{0}
++var_hides_arg # variable {0} hides argument
++redeclared_var # redeclaration of {0} {1}
++anon_no_return_value # anonymous function does not always return a value
++missing_semicolon # missing semicolon
++meaningless_block # meaningless block; curly braces have no impact
++comma_separated_stmts # multiple statements separated by commas (use semicolons?)
++unreachable_code # unreachable code
++missing_break # missing break statement
++missing_break_for_last_case # missing break statement for last case in switch
++comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
++inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
++useless_void # use of the void type may be unnecessary (void is always undefined)
++multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
++use_of_label # use of label
+-block_without_braces # block statement without curly braces
++leading_decimal_point # leading decimal point may indicate a number or an object member
++trailing_decimal_point # trailing decimal point may indicate a number or an object member
++octal_number # leading zeros make an octal number
++nested_comment # nested comment
++misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
+-ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement
+-empty_statement # empty statement or extra semicolon
+-missing_option_explicit # the "option explicit" control comment is missing
++partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag
++dup_option_explicit # duplicate "option explicit" control comment
++useless_assign # useless assignment
++ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
++ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
++missing_default_case # missing default case in switch statement
++duplicate_case_in_switch # duplicate case in switch statements
++default_not_at_end # the default case is not at the end of the switch statement
++legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
++jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
++useless_comparison # useless comparison; comparing identical expressions
++with_statement # with statement hides undeclared variables; use temporary variable instead
++trailing_comma_in_array # extra comma is not recommended in array initializers
++assign_to_function_call # assignment to a function call
++parseint_missing_radix # parseInt missing radix parameter
+
+
+### Output format
+# Customize the format of the error message.
+# __FILE__ indicates current file path
+# __FILENAME__ indicates current file name
+# __LINE__ indicates current line
+# __ERROR__ indicates error message
+#
+# Visual Studio syntax (default):
+#+output-format __FILE__(__LINE__): __ERROR__
+# Alternative syntax:
++output-format __FILE__:__LINE__: __ERROR__
+
+
+### Context
+# Show the in-line position of the error.
+# Use "+context" to display or "-context" to suppress.
+#
++context
+
+
+### Semicolons
+# By default, assignments of an anonymous function to a variable or
+# property (such as a function prototype) must be followed by a semicolon.
+#
++lambda_assign_requires_semicolon
+
+
+### Control Comments
+# Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for
+# the /*@keyword@*/ control comments and JScript conditional comments. (The latter is
+# enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason,
+# although legacy control comments are enabled by default for backward compatibility.
+#
++legacy_control_comments
+
+
+### JScript Function Extensions
+# JScript allows member functions to be defined like this:
+# function MyObj() { /*constructor*/ }
+# function MyObj.prototype.go() { /*member function*/ }
+#
+# It also allows events to be attached like this:
+# function window::onload() { /*init page*/ }
+#
+# This is a Microsoft-only JavaScript extension. Enable this setting to allow them.
+#
+-jscript_function_extensions
+
+
+### Defining identifiers
+# By default, "option explicit" is enabled on a per-file basis.
+# To enable this for all files, use "+always_use_option_explicit"
+-always_use_option_explicit
+
+# Define certain identifiers of which the lint is not aware.
+# (Use this in conjunction with the "undeclared identifier" warning.)
+#
+# Common uses for webpages might be:
+#+define window
+#+define document
+
+
+### Files
+# Specify which files to lint
+# Use "+recurse" to enable recursion (disabled by default).
+# To add a set of files, use "+process FileName", "+process Folder\Path\*.js",
+# or "+process Folder\Path\*.htm".
+#
+# +process jsl-test.js
11 management/pep8Flags.txt
@@ -0,0 +1,11 @@
+# This file specifies command-line flags that ./manage.py lint should
+# pass to the pep8 style checker.
+
+# don't complain about overly long lines
+--ignore=E501
+
+# give a verbose message explaining the violated style guideline
+--show-pep8
+
+# go ahead and display the same error multiple times
+--repeat
275 management/pylintrc.txt
@@ -0,0 +1,275 @@
+[MASTER]
+
+# Specify a configuration file.
+#rcfile=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Profiled execution.
+profile=no
+
+# Add files or directories to the blacklist. They should be base names, not
+# paths.
+ignore=CVS
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+
+[MESSAGES CONTROL]
+
+# Enable the message, report, category or checker with the given id(s). You can
+# either give multiple identifier separated by comma (,) or put this option
+# multiple time.
+#enable=
+
+# Brain-dead errors regarding standard language features
+# W0142 = *args and **kwargs support
+# W0403 = Relative imports
+
+# Pointless whinging
+# R0201 = Method could be a function
+# W0212 = Accessing protected attribute of client class
+# W0613 = Unused argument
+# W0232 = Class has no __init__ method
+# R0903 = Too few public methods
+# R0904 = Too many public methods
+# C0301 = Line too long
+# R0913 = Too many arguments
+# C0103 = Invalid name
+# R0914 = Too many local variables
+# W0603 = Using the global statement
+# R0912 = Too many branches
+# R0915 = Too many statements
+# R0902 = Too many instance attributes
+
+# PyLint's module importation is unreliable
+# F0401 = Unable to import module
+# W0402 = Uses of a deprecated module
+
+# Already an error when wildcard imports are used
+# W0614 = Unused import from wildcard
+
+# Sometimes disabled depending on how bad a module is
+# C0111 = Missing docstring
+
+# Maddening. No, I don't want you to tell me when I disable something
+# I0011 = Locally disabling <x>
+
+# E1103 = Instance of 'x' has no 'y' member (but some types could not be inferred)
+# R0801 = Similar lines in N files
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifier separated by comma (,) or put this option
+# multiple time (only on the command line, not in the configuration file where
+# it should appear only once).
+disable=W0142,W0403,R0201,W0212,W0613,W0232,R0903,R0904,W0614,C0111,C0301,R0913,C0103,R0914,W0603,R0912,R0915,R0902,F0401,W0402,W0614,C0111,I0011,E1103,R0801
+
+
+[REPORTS]
+
+# Set the output format. Available formats are text, parseable, colorized, msvs
+# (visual studio) and html
+output-format=parseable
+
+# Include message's id in output
+include-ids=yes
+
+# Put messages in a separate file for each module / package specified on the
+# command line instead of printing them on stdout. Reports (if any) will be
+# written in a file name "pylint_global.[txt|html]".
+files-output=no
+
+# Tells whether to display a full report or only the messages
+reports=no
+
+# Python expression which should return a note less than 10 (10 is the highest
+# note). You have access to the variables errors warning, statement which
+# respectively contain the number of errors / warnings messages and the total
+# number of statements analyzed. This is used by the global evaluation report
+# (RP0004).
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
+
+# Add a comment according to your evaluation note. This is used by the global
+# evaluation report (RP0004).
+comment=no
+
+
+[BASIC]
+
+# Required attributes for module, separated by a comma
+required-attributes=
+
+# List of builtins function names that should not be used, separated by a comma
+bad-functions=map,filter,apply,input
+
+# Regular expression which should only match correct module names
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Regular expression which should only match correct module level names
+const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
+
+# Regular expression which should only match correct class names
+class-rgx=[A-Z_][a-zA-Z0-9]+$
+
+# Regular expression which should only match correct function names
+function-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression which should only match correct method names
+method-rgx=[a-z_][a-zA-Z0-9_]{2,30}$
+
+# Regular expression which should only match correct instance attribute names
+attr-rgx=[a-z_][a-zA-Z0-9_]{0,30}$
+
+# Regular expression which should only match correct argument names
+argument-rgx=[a-z_][a-zA-Z0-9_]{0,30}$
+
+# Regular expression which should only match correct variable names
+variable-rgx=[a-z_][a-zA-Z0-9_]{0,30}$
+
+# Regular expression which should only match correct list comprehension /
+# generator expression variable names
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
+
+# Good variable names which should always be accepted, separated by a comma
+good-names=i,j,k,ex,Run,_
+
+# Bad variable names which should always be refused, separated by a comma
+bad-names=foo,bar,baz,toto,tutu,tata
+
+# Regular expression which should only match functions or classes name which do
+# not require a docstring
+no-docstring-rgx=__.*__
+
+
+[FORMAT]
+
+# Maximum number of characters on a single line.
+max-line-length=80
+
+# Maximum number of lines in a module
+max-module-lines=1000
+
+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
+# tab).
+indent-string=' '
+
+
+[MISCELLANEOUS]
+
+# List of note tags to take in consideration, separated by a comma.
+notes=FIXME,XXX,TODO
+
+
+[SIMILARITIES]
+
+# Minimum lines number of a similarity.
+min-similarity-lines=6
+
+# Ignore comments when computing similarities.
+ignore-comments=yes
+
+# Ignore docstrings when computing similarities.
+ignore-docstrings=yes
+
+
+[TYPECHECK]
+
+# Tells whether missing members accessed in mixin class should be ignored. A
+# mixin class is detected if its name ends with "mixin" (case insensitive).
+ignore-mixin-members=yes
+
+# List of classes names for which member attributes should not be checked
+# (useful for classes with attributes dynamically set).
+ignored-classes=SQLObject
+
+# When zope mode is activated, add a predefined set of Zope acquired attributes
+# to generated-members.
+zope=no
+
+# List of members which are set dynamically and missed by pylint inference
+# system, and so shouldn't trigger E0201 when accessed. Python regular
+# expressions are accepted.
+generated-members=REQUEST,acl_users,aq_parent,id,objects,filter,status_code,content,parse_date,ParseError,_meta
+
+
+[VARIABLES]
+
+# Tells whether we should check for unused import in __init__ files.
+init-import=no
+
+# A regular expression matching the beginning of the name of dummy variables
+# (i.e. not used).
+dummy-variables-rgx=_|dummy
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+additional-builtins=
+
+
+[CLASSES]
+
+# List of interface methods to ignore, separated by a comma. This is used for
+# instance to not check methods defines in Zope's Interface base class.
+ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
+
+# List of method names used to declare (i.e. assign) instance attributes.
+defining-attr-methods=__init__,__new__,setUp
+
+
+[DESIGN]
+
+# Maximum number of arguments for function / method
+max-args=5
+
+# Argument names that match this expression will be ignored. Default to name
+# with leading underscore
+ignored-argument-names=_.*
+
+# Maximum number of locals for function / method body
+max-locals=15
+
+# Maximum number of return / yield for function / method body
+max-returns=6
+
+# Maximum number of branch for function / method body
+max-branchs=12
+
+# Maximum number of statements in function / method body
+max-statements=50
+
+# Maximum number of parents for a class (see R0901).
+max-parents=7
+
+# Maximum number of attributes for a class (see R0902).
+max-attributes=7
+
+# Minimum number of public methods for a class (see R0903).
+min-public-methods=2
+
+# Maximum number of public methods for a class (see R0904).
+max-public-methods=20
+
+
+[IMPORTS]
+
+# Deprecated modules which should not be used, separated by a comma
+deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
+
+# Create a graph of every (i.e. internal and external) dependencies in the
+# given file (report RP0402 must not be disabled)
+import-graph=
+
+# Create a graph of external dependencies in the given file (report RP0402 must
+# not be disabled)
+ext-import-graph=
+
+# Create a graph of internal dependencies in the given file (report RP0402 must
+# not be disabled)
+int-import-graph=
16 management/requirements.txt
@@ -0,0 +1,16 @@
+# __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__
+
+# This is a pip requirements file
+# http://pip.openplans.org/requirement-format.html
+
+# If you have the geocamUtil app, these requirements will be installed
+# when you run "manage.py installreqs". This default version installs
+# the collected requirements from the apps' requirements.txt files and
+# the siteRequirements.txt file by including the auto-generated
+# allRequirements.txt file, but you can do whatever you want.
+
+-r ../build/management/allRequirements.txt
12 management/siteRequirements.txt
@@ -0,0 +1,12 @@
+# __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__
+
+# This is a pip requirements file
+# http://pip.openplans.org/requirement-format.html
+
+# This is a place to specify any Python dependencies your site has that
+# are not already specified in the requirements.txt file of one of your
+# apps.
28 management/templates/settings.py
@@ -0,0 +1,28 @@
+# __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__
+
+"""
+settings.py -- Local site settings
+
+Override in this what you wish. By default it simply imports the
+site default settings and overrides nothing.
+
+This file should *not* be checked into git.
+"""
+
+from siteSettings import * # pylint: disable=W0401
+
+# Make this unique, and don't share it with anybody. Used by Django's
+# cookie-based authentication mechanism.
+SECRET_KEY = '{{ secretKey }}'
+
+# For example, override the database settings:
+#DATABASES = {
+# 'default': {
+# 'ENGINE': 'django.db.backends.sqlite3',
+# 'NAME': 'dev.db'
+# }
+#}
22 management/templates/sourceme.sh
@@ -0,0 +1,22 @@
+# __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__
+
+{% if virtualEnvDir %}
+# Activate virtualenv environment
+source {{ virtualEnvDir }}/bin/activate
+{% endif %}
+
+# Set DJANGO_SCRIPT_NAME to the URL prefix for Django on your web server (with leading slash
+# and trailing slash). This setting is ignored if using the built-in Django development web
+# server.
+export DJANGO_SCRIPT_NAME='geocamBayCop'
+
+# The auto-generated PYTHONPATH usually works, but you might need to add more directories
+# depending on how you installed everything.
+export PYTHONPATH={{ parentDir }}:{{ appsDir }}:$PYTHONPATH
+
+# You should not need to change this.
+export DJANGO_SETTINGS_MODULE='geocamBayCop.settings'
195 setup.py
@@ -0,0 +1,195 @@
+# __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 os
+from setuptools import setup, find_packages, Command
+
+import os.path as op
+import subprocess
+
+
+def read_file(filename):
+ """Read a file into a string"""
+ path = os.path.abspath(os.path.dirname(__file__))
+ filepath = os.path.join(path, filename)
+ try:
+ return open(filepath).read()
+ except IOError:
+ return ''
+
+# Use the docstring of the __init__ file to be the description
+#DESC = " ".join(__import__('geocamBayCop').__doc__.splitlines()).strip()
+DESC = ""
+
+PROJ_ROOT = op.abspath(op.dirname(__file__))
+
+
+def find_sub_apps(directory=PROJ_ROOT):
+ """We define a sub-application to be any top-level subdirectory that
+ contains a urls.py and a models.py. Note that we do not look solely
+ for submodule based apps, since there could be an odd app or two that
+ aren't based on a git submodule, or it could be the main 'glue'
+ application."""
+ requiredFiles = ['models.py', 'urls.py']
+ subApps = []
+ for entry in os.listdir(directory):
+ fullEntry = op.join(directory, entry)
+ if not op.isdir(fullEntry):
+ continue
+ if all([op.exists(op.join(fullEntry, f)) for f in requiredFiles]):
+ subApps.append((entry, fullEntry))
+ return subApps
+
+
+def find_submodules(directory=op.join(PROJ_ROOT, 'apps')):
+ """We define a submodule as a subdirectory in submodules which contains a
+ subdirectory under that of the same name. We do not do git magic as there
+ could be times where it is a sub-app that isn't a git subrepo."""
+ subModules = []
+ for entry in os.listdir(directory):
+ fullEntry = op.join(directory, entry)
+ if not op.isdir(fullEntry):
+ continue
+ fullSubDir = op.join(fullEntry, entry)
+ if op.exists(fullSubDir) and op.isdir(fullSubDir):
+ subModules.append((entry, fullSubDir))
+ return subModules
+
+
+class RunSubCommand(Command):
+ """Run a sub-command on the sub-apps. This class is meant to be subclassed.
+ Override 'self.subcommand' in initialize_options to specify what command
+ to run. If you override run, be sure to call this class' run to
+ run the subcommand."""
+ user_options = []
+
+ # Option defaults
+ def initialize_options(self):
+ self.subcommand = None # pylint: disable=W0201
+
+ # Validate options
+ def finalize_options(self):
+ pass
+
+ # Where the action happens
+ def run(self):
+ if getattr(self, 'subcommand', None) is None:
+ raise Exception("must override self.subcommand")
+ projDir = op.abspath(op.dirname(__file__))
+ subApps = find_sub_apps(projDir)
+ for app, _directory in subApps:
+ appDir = op.join(projDir, 'submodules', app)
+ if not op.exists(appDir):
+ self.announce("skipping %s" % app)
+ continue
+
+ setupPath = op.join(appDir, 'setup.py')
+ if not op.exists(setupPath):
+ self.announce("skipping %s" % app)
+ continue
+
+ subprocess.call(["python", setupPath, self.subcommand])
+
+
+class TestCommand(RunSubCommand):
+ description = 'test geocam command'
+ user_options = []
+
+ # Option defaults
+ def initialize_options(self):
+ self.subcommand = 'geocam'
+
+ # Validate options
+ def finalize_options(self):
+ pass
+
+
+class SymlinkCommand(Command):
+ """This command makes the submodule app directories symlinked to the
+ site-level. Will not work on windows."""
+ description = 'symlink submodules to the main site level'
+ user_options = [('force', 'f', 'overwrite existing symlinks')]
+ boolean_options = ['force']
+
+ # Option defaults
+ def initialize_options(self):
+ self.force = False
+
+ # Validate options
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ subModules = find_submodules()
+ for name, directory in subModules:
+ destination = op.join(PROJ_ROOT, name)
+ if op.exists(destination):
+ if not op.islink(destination):
+ self.announce("skipping " + name + ": not a symlink")
+ continue
+ if not self.force:
+ self.announce("skipping " + name + ": file exists (use -f to override)")
+ continue
+ os.remove(destination)
+ os.symlink(directory, destination)
+
+
+class MediaCommand(Command):
+ description = 'collect together the site-level static media'
+ user_options = [('force', 'f', 'overwrite existing symlinks')]
+ boolean_options = ['force']
+
+ # Option defaults
+ def initialize_options(self):
+ self.force = False
+
+ # Validate options
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ siteMediaDir = op.join(PROJ_ROOT, 'media')
+ if not op.exists(siteMediaDir):
+ os.mkdir(siteMediaDir)
+ subApps = find_sub_apps()
+ for name, directory in subApps:
+ mediaDirectory = op.join(directory, 'media', name)
+ if not op.exists(mediaDirectory):
+ self.announce("skipping " + name + ": media directory does not exist")
+ continue
+ destination = op.join(siteMediaDir, name)
+ if op.exists(destination):
+ if not op.islink(destination):
+ self.announce("skipping " + name + ": not a symlink")
+ continue
+ if not self.force:
+ self.announce("skipping " + name + ": file exists (use -f to override)")
+ continue
+ os.remove(destination)
+ os.symlink(directory, destination)
+
+
+setup(
+ name="geocamBayCop",
+ version='1.0', # __import__('geocamBayCop').get_version().replace(' ', '-'),
+ url='',
+ author='Trey Smith',
+ author_email='',
+ description=DESC,
+ long_description=read_file('README'),
+ packages=find_packages(),
+ include_package_data=True,
+ install_requires=read_file('requirements.txt'),
+ classifiers=[
+ 'License :: OSI Approved :: NASA Open Source Agreement',
+ 'Framework :: Django',
+ ],
+
+ cmdclass={
+ 'link_submodules': SymlinkCommand,
+ 'link_media': MediaCommand
+ },
+)
142 siteSettings.py
@@ -0,0 +1,142 @@
+# __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__
+
+# siteSettings.py -- site default settings
+#
+# This contains the default settings for the site-level django app. This will
+# override any application-default settings and define the default set of
+# installed applications. This should be a full settings.py file which needs
+# minimal overrides by the settings.py file for the application to actually
+# function.
+#
+# As a bare minimum, please edit INSTALLED_APPS!
+#
+# This file *should* be checked into git.
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+import os
+import sys
+#APP = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+#PROJ_ROOT = os.path.abspath(os.path.dirname(__file__))
+PROJ_ROOT = os.path.abspath(os.path.dirname(__file__))
+
+SCRIPT_NAME = os.environ['DJANGO_SCRIPT_NAME'] # set in sourceme.sh
+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 = '/'
+
+# Python path is agnostic to what the site-level dir is. It also prefers the
+# checked-out version of an app over the standard python install locations.
+sys.path.append(PROJ_ROOT)
+
+ADMINS = (
+ # ('Trey Smith', 'your_email@domain.com'),
+)
+MANAGERS = ADMINS
+
+# Databases
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': 'dev.db'
+ }
+}
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Los_Angeles'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = os.path.join(PROJ_ROOT, "build", "media", "")
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
+MEDIA_URL = SCRIPT_NAME + 'media/'
+
+# Absolute path to the directory that holds data. This is different than media
+# in that it's uploaded/processed data that's not needed for the operation of
+# the site, but may need to be network-accessible, or be linked to from the
+# database. Examples: images, generate kml files, etc.
+# Example: "/data/"
+DATA_ROOT = os.path.join(PROJ_ROOT, "data", "")
+
+DATA_DIR = DATA_ROOT # some legacy modules use the DATA_DIR name
+
+# URL that handles the data served from DATA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://data.lawrence.com", "http://example.com/data/"
+DATA_URL = SCRIPT_NAME + "data/"
+
+STATIC_ROOT = os.path.join(PROJ_ROOT, "build", "static", "")
+STATIC_URL = SCRIPT_NAME + 'static/'
+
+# Awesome. Needed in Django 1.3 but causes deprecation warning in Django 1.4.
+ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'lrw*8r8013g3pdkk-@4rjgra9*y0#(_#-p-4_a7_@-=9#jg0ow'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+# 'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'geocamUtil.middleware.LogErrorsMiddleware',
+ 'django.middleware.gzip.GZipMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'geocamUtil.middleware.SecurityMiddleware',
+)
+
+ROOT_URLCONF = 'urls'
+
+TEMPLATE_DIRS = (
+ # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+)
+
+# Note: the order of INSTALLED_APPS affects the search order for
+# templates. We suggest putting your apps above standard apps
+# so your apps can override templates as needed.
+INSTALLED_APPS = (
+ # Put your installed apps here!
+ # 'geocamAwesome'
+
+ 'geocamUtil',
+
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+)
+
+GEOCAM_UTIL_SECURITY_ENABLED = not USING_DJANGO_DEV_SERVER
+GEOCAM_UTIL_SECURITY_SSL_REQUIRED_BY_DEFAULT = False
+GEOCAM_UTIL_SECURITY_REQUIRE_ENCRYPTED_PASSWORDS = False
+GEOCAM_UTIL_SECURITY_LOGIN_REQUIRED_BY_DEFAULT = 'write'
34 submodules/README.rst
@@ -0,0 +1,34 @@
+
+This Django site uses git submodules to pull in closely related packages
+from external git repositories.
+
+Conventions
+===========
+
+Submodules should be cloned into this ``submodules`` directory.
+
+If a submodule requires that external Python modules be installed, they
+should be listed in a file named ``requirements.txt`` in that
+submodule's top-level directory. Initializing the site (``./manage.py
+prep``) will install the requirements with ``pip``.
+
+For submodules that define Django apps, the directory within the
+submodule that defines the app (the one that contains the ``models.py``
+file) should be symlinked into the ``apps`` directory, which is in the
+``PYTHONPATH`` for the site. For example, ``apps/geocamUtil`` might be
+a symlink to ``submodules/geocamUtilWeb/geocamUtil``. (In some cases, a
+single submodule might define multiple apps which are separately
+symlinked into the ``apps`` directory.)
+
+Example of Adding a New Submodule
+=================================
+
+::
+
+ cd geocamBayCop
+ # note: using public (read-only) submodule URL to allow devs without
+ # write access to fetch submodule
+ git submodule add git://github.com/geocam/geocamUtilWeb.git submodules/geocamUtilWeb
+ ln -s ../submodules/geocamUtilWeb/geocamUtil apps/geocamUtil
+ git add apps/geocamUtil # check the symlink into git
+ git commit -m 'added geocamUtil app'

0 comments on commit 91a86a8

Please sign in to comment.