Skip to content

Commit

Permalink
Working on activate fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven V. Gonzales committed Apr 12, 2012
1 parent 719ea48 commit 638dd60
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
17 changes: 17 additions & 0 deletions examples/example4/VEfile
@@ -0,0 +1,17 @@
environment:
DG_A: A
DG_B: B

---
profile: development

environment:
DG_C: C

---
profile: production

environment:
DG_A: OA
DG_C: OC
DG_D: D
5 changes: 4 additions & 1 deletion virtstrap-core/virtstrap/templates/init/activate.sh.tmpl
Expand Up @@ -62,8 +62,11 @@ VIRTSTRAP_PROJECT_DIR="{{project.path()}}"
export VIRTSTRAP_PROJECT_DIR

env_tempfile=`{{project.bin_path('virtstrap-tempfiler')}}`

config_profiles=`cat {{project.env_path('config/profiles')}}`
profiles=${1:-$config_profiles}
# Write extra environment to tempfile
{{project.bin_path('virtstrap-local')}} environment $env_tempfile
{{project.bin_path('virtstrap-local')}} environment $env_tempfile --profiles=$profiles
# Store file's contents
extra_env=`cat $env_tempfile`
# Remove the tempfile
Expand Down
@@ -1,2 +1,2 @@
#!/bin/bash
source {{project.bin_path('activate')}}
source {{project.bin_path('activate')}} $@
Binary file not shown.
Binary file not shown.
19 changes: 17 additions & 2 deletions virtstrap/virtstrap_system/commands/init.py
Expand Up @@ -38,7 +38,7 @@ def run(self, project, options, raw_args=None, use_injected_project=False,
project = self.load_project(options)
self.project = project
self.ensure_project_directory(project)
self.create_virtualenv(project)
self.create_virtualenv(project, options)
self.wrap_activate_script(project)
self.create_quick_activate_script(project)
self.run_install_for_project(project, options)
Expand All @@ -48,7 +48,7 @@ def ensure_project_directory(self, project):
if not os.path.exists(project_dir):
os.makedirs(project_dir)

def create_virtualenv(self, project):
def create_virtualenv(self, project, options):
"""Create virtual environment in the virtstrap directory"""
import virtualenv
virtstrap_dir = project.env_path()
Expand All @@ -69,6 +69,7 @@ def create_virtualenv(self, project):
# FIXME add later. with optimizations. This is really slow
self.install_virtstrap(project)
self.install_virtstrap_plugins(project)
self.setup_config_folder(project, options)

def install_virtstrap(self, project):
try:
Expand All @@ -94,6 +95,20 @@ def install_virtstrap(self, project):
self.logger.error('An error occured with pip')
sys.exit(2)

def setup_config_folder(self, project, options):
# Create the folder
config_path = project.env_path('config')
if not os.path.isdir(config_path):
os.makedirs(config_path)

# Create the profiles config
profiles_file_path = os.path.join(config_path, 'profiles')
profiles_file = open(profiles_file_path, 'w')

profiles_string = ",".join(options.profiles)
profiles_file.write(profiles_string)
profiles_file.close()

def install_virtstrap_plugins(self, project):
self.logger.info('Installing any virtstrap plugins')
plugin_set = project.process_config_section('plugins',
Expand Down

0 comments on commit 638dd60

Please sign in to comment.