Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Created May 25, 2013 13:32
Show Gist options
  • Save marcelcaraciolo/5649050 to your computer and use it in GitHub Desktop.
Save marcelcaraciolo/5649050 to your computer and use it in GitHub Desktop.
class BenchmarkRepository(object):
"""
Manage an isolated copy of a repository for benchmarking
"""
...
def _copy_repo(self):
if os.path.exists(self.target_dir):
print 'Deleting %s first' % self.target_dir
# response = raw_input('%s exists, delete? y/n' % self.target_dir)
# if response == 'n':
# raise Exception('foo')
cmd = 'rm -rf %s' % self.target_dir
print cmd
os.system(cmd)
self._clone(self.target_dir_tmp, self.target_dir)
self._prep()
self._copy_benchmark_scripts_and_deps()
def _clone(self, source, target):
cmd = 'git clone %s %s' % (source, target)
print cmd
os.system(cmd)
def _copy_benchmark_scripts_and_deps(self):
pth, _ = os.path.split(os.path.abspath(__file__))
deps = [os.path.join(pth, 'run_benchmarks.py')]
if self.dependencies is not None:
deps.extend(self.dependencies)
for dep in deps:
cmd = 'cp %s %s' % (dep, self.target_dir)
print cmd
proc = subprocess.Popen(cmd, shell=True)
proc.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment