Permalink
Browse files

added mkdir functionality to ensure that the directory being synced/e…

…xecuted on actually exists
  • Loading branch information...
1 parent 68ed78a commit ad3d864a0de049819ef47f0ba8907309c10bb907 @agschwender-mccann agschwender-mccann committed Oct 12, 2012
Showing with 12 additions and 3 deletions.
  1. +12 −3 deployer/default_fabfile.py
@@ -4,6 +4,7 @@
from fabric.api import run, local, env, sudo
from fabric.context_managers import cd
+from fabric.contrib.files import exists
from fabric.contrib.project import rsync_project
env.use_ssh_config = True
@@ -18,6 +19,7 @@ def sync():
"""
local_path = _get_local_path()
remote_path = _get_remote_path(local_path)
+ _mkdir(remote_path)
local("rsync -avr --delete-excluded --exclude .git " \
+ "%(local_path)s %(host)s:%(remote_path)s" \
% (dict(host=env.host_string,
@@ -47,8 +49,10 @@ def execute(command):
command -- The shell command to be executed
"""
command = _clean_param(command)
- with cd(_get_remote_path(_get_local_path())):
- run(command)
+ path = _get_remote_path(_get_local_path())
+ _mkdir(path)
+ with cd(path):
+ sudo(command)
def ant(target, **kwargs):
@@ -62,7 +66,9 @@ def ant(target, **kwargs):
args = ""
for k,v in kwargs.iteritems():
args += " -D%s=%s" % (k, v)
- with cd(_get_remote_path(_get_local_path())):
+ path = _get_remote_path(_get_local_path())
+ _mkdir(path)
+ with cd(path):
sudo("ant %s%s" % (target, args))
@@ -86,6 +92,9 @@ def _get_local_path(path=None):
path = path if path.endswith("/") else "%s/" % path
return path
+def _mkdir(path):
+ if not exists(path):
+ sudo("mkdir -p %s" % path)
def _clean_param(param):
param = param if param is not None else ""

0 comments on commit ad3d864

Please sign in to comment.