Skip to content

Commit

Permalink
now commit symlinks in apps dir instead of generating them in bootstr…
Browse files Browse the repository at this point in the history
…ap.py
  • Loading branch information
trey0 committed Mar 27, 2012
1 parent 47e20bc commit 8161c7f
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 23 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -11,4 +11,3 @@
/settings.py /settings.py
/sourceme.sh /sourceme.sh
/gigapan /gigapan
/apps
1 change: 1 addition & 0 deletions apps/geocamAware
1 change: 1 addition & 0 deletions apps/geocamCore
1 change: 1 addition & 0 deletions apps/geocamFolder
1 change: 1 addition & 0 deletions apps/geocamLens
1 change: 1 addition & 0 deletions apps/geocamMemo
1 change: 1 addition & 0 deletions apps/geocamTalk
1 change: 1 addition & 0 deletions apps/geocamTrack
1 change: 1 addition & 0 deletions apps/geocamUtil
42 changes: 20 additions & 22 deletions management/bootstrap.py
Expand Up @@ -41,9 +41,9 @@
dict(name='gitSubmodulesMasterBranch', dict(name='gitSubmodulesMasterBranch',
desc='Set submodules to be on their master branch for development', desc='Set submodules to be on their master branch for development',
confirm=True), confirm=True),
dict(name='linkSubmodules', #dict(name='linkSubmodules',
desc='Link submodules into apps directory', # desc='Link submodules into apps directory',
confirm=True), # confirm=True),
dict(name='installSubModuleRequirements', dict(name='installSubModuleRequirements',
desc='Install Python modules listed in the requirements for each submodule', desc='Install Python modules listed in the requirements for each submodule',
confirm=True), confirm=True),
Expand Down Expand Up @@ -86,27 +86,27 @@ def dosys(cmd, continueOnError=False):
ret = os.system(cmd) ret = os.system(cmd)
if ret != 0: if ret != 0:
if continueOnError: if continueOnError:
logging.warning('WARNING: Command returned non-zero return value %d', ret) logging.warning('WARNING: Command returned non-zero return value %d' % ret)
else: else:
logging.error('ERROR: Command returned non-zero return value %d', ret) logging.error('ERROR: Command returned non-zero return value %d' % ret)
sys.exit(1) sys.exit(1)




def writeFileMakeDir(path, text): def writeFileMakeDir(path, text):
d = os.path.dirname(path) dir = os.path.dirname(path)
if not os.path.exists(d): if not os.path.exists(dir):
os.makedirs(d) os.makedirs(dir)
f = file(path, 'w') f = file(path, 'w')
f.write(text + '\n') f.write(text + '\n')
f.close() f.close()




def fillTemplate(inputFile, outputFile, context): def fillTemplate(inputFile, outputFile, context):
if os.path.exists(outputFile): if os.path.exists(outputFile):
logging.warning('WARNING: File %s exists, not overwriting. Move current version out of the way to regenerate', outputFile) logging.warning('WARNING: File %s exists, not overwriting. Move current version out of the way to regenerate' % outputFile)
return return


logging.info('generating %s', outputFile) logging.info('generating %s' % outputFile)


from django.template import Template, Context from django.template import Template, Context
from django.conf import settings from django.conf import settings
Expand Down Expand Up @@ -140,9 +140,9 @@ def linkSubmodules(opts):
relativeSrc = '../%s' % src relativeSrc = '../%s' % src
dst = 'apps/%s' % appName dst = 'apps/%s' % appName
if os.path.lexists(dst): if os.path.lexists(dst):
logging.debug(' %s -> %s skipped (already exists)', dst, relativeSrc) logging.debug(' %s -> %s skipped (already exists)' % (dst, relativeSrc))
else: else:
logging.debug(' %s -> %s', dst, relativeSrc) logging.debug(' %s -> %s' % (dst, relativeSrc))
os.symlink(relativeSrc, dst) os.symlink(relativeSrc, dst)




Expand All @@ -154,15 +154,15 @@ def hasRequirements(reqsFile):




def installRequirements(reqsFile): def installRequirements(reqsFile):
needSudo = 'VIRTUALENV' not in os.environ needSudo = 'VIRTUAL_ENV' not in os.environ
if needSudo: if needSudo:
sudoStr = 'sudo ' sudoStr = 'sudo '
else: else:
sudoStr = '' sudoStr = ''
if hasRequirements(reqsFile): if hasRequirements(reqsFile):
dosys('%spip install -r %s' % (sudoStr, reqsFile)) dosys('%spip install -r %s' % (sudoStr, reqsFile))
else: else:
logging.info('requirements file %s is empty', reqsFile) logging.info('requirements file %s is empty' % reqsFile)




def installSubModuleRequirements(opts): def installSubModuleRequirements(opts):
Expand Down Expand Up @@ -192,7 +192,7 @@ def needSettings(opts):




def genSettings(opts): def genSettings(opts):
secretKey = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for _ in range(50)]) secretKey = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])


fillTemplate('management/templates/%s' % SETTINGS_NAME, fillTemplate('management/templates/%s' % SETTINGS_NAME,
SETTINGS_NAME, SETTINGS_NAME,
Expand Down Expand Up @@ -229,9 +229,9 @@ def doAction(opts, action):


if status != 'NEEDED': if status != 'NEEDED':
if opts.retry: if opts.retry:
logging.info('Would skip %s, status is %s, but running in retry mode', action['name'], status) logging.info('Would skip %s, status is %s, but running in retry mode' % (action['name'], status))
else: else:
logging.info('Skipping step %s, status is %s', action['name'], status) logging.info('Skipping step %s, status is %s' % (action['name'], status))
return return


# confirm with user # confirm with user
Expand Down Expand Up @@ -260,16 +260,14 @@ def doit(opts, args):
if args: if args:
for arg in args: for arg in args:
if arg not in ACTION_DICT: if arg not in ACTION_DICT:
print >> sys.stderr, 'ERROR: there is no action %s' % arg print >>sys.stderr, 'ERROR: there is no action %s' % arg
# suppress bogus pylint warning about redefining name 'a' from outer scope print >>sys.stderr, 'Available actions are: %s' % (' '.join([a['name'] for a in ACTIONS]))
# pylint: disable=W0621
print >> sys.stderr, 'Available actions are: %s' % (' '.join([a['name'] for a in ACTIONS]))
sys.exit(1) sys.exit(1)
actions = [ACTION_DICT[arg] for arg in args] actions = [ACTION_DICT[arg] for arg in args]
else: else:
actions = ACTIONS actions = ACTIONS


logging.info('Working in %s', os.getcwd()) logging.info('Working in %s' % os.getcwd())
for action in actions: for action in actions:
doAction(opts, action) doAction(opts, action)


Expand Down

0 comments on commit 8161c7f

Please sign in to comment.