Commits

Albert Dengg  committed e410eed

fix umask & add metatask to rebuild venv

  • Participants
  • Parent commits fa5571b

Comments (0)

Files changed (1)

 from contextlib import contextmanager as _contextmanager
 from sys import executable as sys_executable
 from json import load as json_load
+from functools import partial
 
 @_contextmanager
 def virtualenv():
         with prefix(env.activate):
             yield
 
+@_contextmanager
+def umask(new_mask):
+    with prefix('umask %s' % (new_mask, )):
+        yield
+
+@_contextmanager
+def custom_cd(cdfunction, mask, path):
+    with umask(mask):
+        with cdfunction(path):
+            yield
+
 class CustomTask(WrappedCallableTask):
     def __init__(self, callable, *args, **kwargs):
         super(CustomTask, self).__init__(callable, *args, **kwargs)
         env.use_ssh_config = True
         if env.host_string == 'localhost' or not env.hosts:
             env.pyexecutable = sys_executable
-            env.cd = lcd
+            env.cd = partial(custom_cd, lcd, 002)
             env.run = local
             conffile = 'devenv.json'
         else:
-            env.cd = cd
+            env.cd = partial(custom_cd, cd, 002)
             env.run = run
             if 'production' in env and env.production:
                 error('TBD')
 def test_venv():
     with virtualenv():
         env.run('python -c "import sys; print sys.path"')
+
+@task(task_class=CustomTask)
+def rebuild_venv():
+    run('rm -rf %s' % (env.venvpath, ))
+    execute(update)
+    execute(make_venv)
+    execute(install_req)