Commits

lakin.wecker committed 45e0223

the command should be relative to the fabfile not the cwd.

Comments (0)

Files changed (1)

baste/__init__.py

 
 import os.path
 
-from fabric.api import local, lcd, settings
+from fabric.api import (
+        env,
+        hide,
+        lcd,
+        local,
+        settings,
+    )
 from fabric import colors
 
 try:
     'PgShell',
     'PgLoadPlain',
     'MysqlLoadPlain',
+    'project_relative',
     'python_dependency',
     'Repository',
     'RsyncMedia',
 ]
 
 #-------------------------------------------------------------------------------
+def project_relative(path):
+    return os.path.join(os.path.dirname(env.real_fabfile), path)
+
+
+#-------------------------------------------------------------------------------
 class Repository(object):
     """
     Generic base repository which knows how to construct a safe update command.
     def __init__(self, name, url):
         """Instantiate the repository with the given name and url"""
         self.name = name
+        self.directory = project_relative(self.name)
         self.url = url
 
     #---------------------------------------------------------------------------
 
     #---------------------------------------------------------------------------
     def update(self):
-        local("test -d %s && %s || %s" % (
-                self.name, self.update_command(), self.create_command()
+        print(colors.green("[update] ") + self.name)
+        with hide('running'):
+            local("test -d %s && %s || %s" % (
+                    self.directory, self.update_command(), self.create_command()
+                )
             )
-        )
 
 #-------------------------------------------------------------------------------
 class Subversion(Repository):
     """Represents a subversion repository."""
     #---------------------------------------------------------------------------
     def create_command(self):
-        return "svn co %s %s" % (self.url, self.name)
+        return "svn co %s %s" % (self.url, self.directory)
 
     #---------------------------------------------------------------------------
     def update_command(self):
-        return "svn up %s" % (self.name)
+        return "svn up %s" % (self.directory)
 
     #---------------------------------------------------------------------------
     def status_command(self):
-        return "svn st %s" % (self.name)
+        return "svn st %s" % (self.directory)
 
     #---------------------------------------------------------------------------
     def diff_command(self):
-        return "svn diff %s" % (self.name)
+        return "svn diff %s" % (self.directory)
 
 #-------------------------------------------------------------------------------
 class Mercurial(Repository):
     """Represents a mercurial repository."""
     #---------------------------------------------------------------------------
     def create_command(self):
-        return "hg clone %s %s" % (self.url, self.name)
+        return "hg clone %s %s" % (self.url, self.directory)
 
     #---------------------------------------------------------------------------
     def update_command(self):
-        return "hg -R %s pull -u" % (self.name)
+        return "hg -R %s pull -u" % (self.directory)
 
     #---------------------------------------------------------------------------
     def status_command(self):
-        return "hg -R %s status" % (self.name)
+        return "hg -R %s status" % (self.directory)
 
     #---------------------------------------------------------------------------
     def diff_command(self):
-        return "hg -R %s diff" % (self.name)
+        return "hg -R %s diff" % (self.directory)
 
 #-------------------------------------------------------------------------------
 class Git(Repository):
     """Represents a mercurial repository."""
     #---------------------------------------------------------------------------
     def create_command(self):
-        return "git clone %s %s" % (self.url, self.name)
+        return "git clone %s %s" % (self.url, self.directory)
 
     #---------------------------------------------------------------------------
     def update_command(self):
-        return "git --git-dir=%s/.git pull origin master" % (self.name)
+        return "git --git-dir=%s/.git pull origin master" % (self.directory)
 
     #---------------------------------------------------------------------------
     def status_command(self):
-        return "cd %s && git status && cd .." % (self.name)
+        return "cd %s && git status" % (self.directory)
 
     #---------------------------------------------------------------------------
     def diff_command(self):
-        return "cd %s && git diff && cd .." % (self.name)
+        return "cd %s && git diff" % (self.directory)
 
 #-------------------------------------------------------------------------------
 def python_dependency(package, python_version, dir=None):
     if dir is None:
         dir = package
     symlink = "env/lib/%s/%s" % (python_version, package)
+    symlink = project_relative(symlink)
     python_path = os.path.abspath(dir)
     create_symbolic_link = "ln -s %s %s" % (python_path, symlink)
-    local("test -L %s || %s" % (symlink, create_symbolic_link))
+    print(colors.green("[install] ") + package)
+    with hide('running'):
+        local("test -L %s || %s" % (symlink, create_symbolic_link))
 
 #-------------------------------------------------------------------------------
 class StatusCommand(object):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.