Commits

theoden committed a9d9582

Improved os independency:
* '/tmp/' was replaced by more flexible tempfile.gettempdir()
* --exclude "option_value" turned into --exclude="option_value"
* local command 'rm -f' changed to os.remove call

Comments (0)

Files changed (1)

fab_deploy/vcs/none.py

 from __future__ import with_statement
 import os.path
+import tempfile
 from datetime import datetime
 from fabric.api import run, local, env, put, cd
 from taskset import TaskSet, task
 
     def _exclude_string(self):
         excludes = [utils._project_path(env.conf.LOCAL_CONFIG), '*.pyc', '*.pyo']
-        exclude_string = " ".join(['--exclude "%s"' % pattern for pattern in excludes])
+        exclude_string = " ".join(['--exclude="%s"' % pattern for pattern in excludes])
         if os.path.exists('.excludes'):
             exclude_string =  "-X .excludes " + exclude_string
         return exclude_string
         This should be using ``fabric.contrib.project.upload_project``
         but upload_project doesn't support excludes.
         """
-        tar_file = "/tmp/fab.%s.tar" % datetime.utcnow().strftime(
-            '%Y_%m_%d_%H-%M-%S')
-        local("tar %s -czf %s ." % (self._exclude_string(), tar_file))
+        tar_file = os.path.join(
+            tempfile.gettempdir(),
+            "fab.%s.tar" % datetime.utcnow().strftime('%Y_%m_%d_%H-%M-%S')
+        )
+        tarCommand = "tar %s -czf %s ." % (self._exclude_string(), tar_file)
+        local(tarCommand)
         tgz_name = env.conf.SRC_DIR + '/' + env.conf.INSTANCE_NAME + ".tar.gz"
         put(tar_file, tgz_name)
-        local("rm -f " + tar_file)
+        os.remove(tar_file)
         with cd(env.conf.SRC_DIR):
             run("tar -xzf " + tgz_name)
             run("rm -f " + tgz_name)