def detect(self, app): """ Given an app, run detect script on it to determine whether it can be built with this pack. Return True/False. """ script = os.path.join(self.folder, 'bin', 'detect') cmd = '%s %s' % (script, app.folder) result = run(cmd) return result.status_code == 0
def compile(self, app): log.info( 'Compiling {app.basename} with {self.basename}'.format(**vars())) script = os.path.join(self.folder, 'bin', 'compile') cache_folder = os.path.join(CACHE_HOME, get_unique_repo_folder(app.url)) cmd = ' '.join([script, app.folder, cache_folder]) log.info(cmd) result = run(cmd, verbose=True) result.raise_for_status()
def tar(self, appname, appversion): """ Given an app name and version to be used in the tarball name, create a tar.bz2 file with all of this folder's contents inside. Return a Build object with attributes for appname, appversion, time, and path. """ name_tmpl = '%(app)s-%(version)s-%(time)s.tar.bz2' time = utc.now() name = name_tmpl % { 'app': appname, 'version': appversion, 'time': time.strftime('%Y-%m-%dT%H-%M') } if not os.path.exists(TARBALL_HOME): os.mkdir(TARBALL_HOME) tarball = os.path.join(TARBALL_HOME, name) tar_params = {'filename': tarball, 'folder': self.folder} tar_result = run('tar -C %(folder)s -cjf %(filename)s .' % tar_params) tar_result.raise_for_status() return Build(appname, appversion, time, tarball)
def run(command): r = run(command, verbose=True) r.raise_for_status() return r
def release(self, app): script = os.path.join(self.folder, 'bin', 'release') result = run('%s %s' % (script, app.folder)) assert result.status_code == 0, ("Failed release on %s with %s " "buildpack" % (app, self.basename)) return yaml.safe_load(result.output)
def test_git_folder_detection(self): with tmpdir(): folder = os.path.abspath('.git') run('mkdir -p %s' % folder) assert repo.guess_folder_vcs(os.getcwd()) == 'git'
def _git_config(): run('git config user.email "*****@*****.**"') run('git config --global user.name "Your Name"')
def test_hg_folder_detection(): with tmpdir(): folder = os.path.abspath('.hg') run('mkdir -p %s' % folder) assert repo.guess_folder_vcs(os.getcwd()) == 'hg'