Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
Fixed some minor coding issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zerok committed Jun 16, 2009
1 parent e8db075 commit 023923f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions zerokspot/recipe/git/__init__.py
Expand Up @@ -21,15 +21,17 @@
import os.path
import zc.buildout
import shutil
from pdb import set_trace


def git(operation, args, message):
command = r'git %s ' + ' '.join(('"%s"',) * len(args))
command = command % ((operation,) + tuple(args))
status = subprocess.call(command, shell=True)
status = subprocess.call(command, shell=True, stdout=open(os.devnull, 'w'),
stderr=subprocess.STDOUT)
if status != 0:
raise zc.buildout.UserError(message)


def get_reponame(url, branch = None, rev = None):
"""
Given the URL of a repository, this function returns the name of it after
Expand Down Expand Up @@ -97,20 +99,23 @@ def install(self):
# the download cache, fetch the repo as usual and then copy it
# into the download cache.
if os.path.exists(self.cache_path):
git('clone', (self.cache_path, self.options['location']), 'Failed to clone repository')
git('clone', (self.cache_path, self.options['location']),
'Failed to clone repository')

os.chdir(self.buildout['buildout']['directory'])
self.installed_from_cache = True
return self.options['location']
else:
raise zc.buildout.UserError("No repository in the download cache directory.")
raise zc.buildout.UserError("No repository in the download "
"cache directory.")
else:
os.chdir(self.buildout['buildout']['download-cache'])

if os.path.exists(self.cache_path):
shutil.rmtree(self.cache_path)

git('clone', (self.repository, self.cache_name), 'Failed to clone repository')
git('clone', (self.repository, self.cache_name),
'Failed to clone repository')

os.chdir(self.cache_path)
if self.branch != 'master':
Expand All @@ -123,7 +128,8 @@ def install(self):
if self.rev is not None:
git('checkout', (self.rev,), 'Failed to checkout revision')

git('clone', (self.cache_path, self.options['location']), 'Failed to clone repository')
git('clone', (self.cache_path, self.options['location']),
'Failed to clone repository')

if self.as_egg:
self._install_as_egg()
Expand Down

0 comments on commit 023923f

Please sign in to comment.