def _git(self, log_out, repo_location=None): repo_location = repo_location or self.repo_location git = sh.git if log_out: git = bake(git) return git.bake('--no-pager', '--git-dir', repo_location / '.git', '--work-tree', repo_location)
def _git(self, log_out): git = sh.git if log_out: git = bake(git) return git.bake( '--no-pager', '--git-dir', self.repo_location / '.git', '--work-tree', self.repo_location)
def nose_run(virtualenv_location, test_path, **_): nose = bake(sh.Command(os.path.join(virtualenv_location, 'bin', 'nosetests'))) try: nose(test_path, nocapture=True, nologcapture=True, verbose=True).wait() except: raise exceptions.NonRecoverableError()
def _hub(log_out): repo_location = repo.repo_location try: hub = sh.hub except sh.CommandNotFound: raise exceptions.NonRecoverableError( 'hub must be installed to use this command.') if log_out: hub = bake(hub) env = os.environ.copy() env.update({ 'GIT_WORK_TREE': repo_location, 'GIT_DIR': repo_location / '.git' }) return hub.bake(_env=env)
def clone(self): git = bake(sh.git) self.runtime_properties['repo_location'] = str(self.repo_location) self.git_version = sh.git(version=True).stdout.strip() if self.repo_location.isdir(): return if self.clone_method == 'https': clone_url = 'https://github.com/{}/{}.git'.format( self.organization, self.name) elif self.clone_method == 'ssh': clone_url = '[email protected]:{}/{}.git'.format( self.organization, self.name) else: raise exceptions.NonRecoverableError( 'Illegal clone method: {0}'.format(self.clone_method)) git.clone(clone_url, self.repo_location, '-b', self.branch).wait()
def install_packages(**_): storage = ctx._endpoint.storage package_node_instance_ids = ctx.capabilities.get_all().keys() package_node_instances = [ storage.get_node_instance(instance_id) for instance_id in package_node_instance_ids ] package_node_instances = [ instance for instance in package_node_instances if 'virtualenv_location' in instance.runtime_properties ] virtualenvs = set((instance.runtime_properties['virtualenv_location'] for instance in package_node_instances)) for virtualenv_location in virtualenvs: virtualenv_package_instances = [ instance for instance in package_node_instances if instance.runtime_properties['virtualenv_location'] == virtualenv_location ] graph = networkx.DiGraph() for instance in virtualenv_package_instances: graph.add_node(instance.id) for relationship in instance.relationships: graph.add_edge(instance.id, relationship['target_id']) topological_sort = networkx.topological_sort(graph.reverse()) requirements = [] for instance_id in topological_sort: instance = storage.get_node_instance(instance_id) for requirement in instance.runtime_properties.get( 'requirements', []): if requirement not in requirements: requirements.append(requirement) requirements_file = tempfile.mktemp(prefix='requirements-', suffix='.txt') if not requirements: return with open(requirements_file, 'w') as f: f.write('\n'.join(requirements)) pip = bake(sh.Command(os.path.join(virtualenv_location, 'bin', 'pip'))) pip.install(requirement=requirements_file, c=os.path.join(virtualenv_location, 'constraints.txt')).wait()
def install_packages(**_): storage = ctx._endpoint.storage package_node_instance_ids = ctx.capabilities.get_all().keys() package_node_instances = [storage.get_node_instance(instance_id) for instance_id in package_node_instance_ids] package_node_instances = [ instance for instance in package_node_instances if 'virtualenv_location' in instance.runtime_properties] virtualenvs = set((instance.runtime_properties['virtualenv_location'] for instance in package_node_instances)) for virtualenv_location in virtualenvs: virtualenv_package_instances = [ instance for instance in package_node_instances if instance.runtime_properties[ 'virtualenv_location'] == virtualenv_location] graph = networkx.DiGraph() for instance in virtualenv_package_instances: graph.add_node(instance.id) for relationship in instance.relationships: graph.add_edge(instance.id, relationship['target_id']) topological_sort = networkx.topological_sort(graph.reverse()) requirements = [] for instance_id in topological_sort: instance = storage.get_node_instance(instance_id) for requirement in instance.runtime_properties.get('requirements', []): if requirement not in requirements: requirements.append(requirement) requirements_file = tempfile.mktemp(prefix='requirements-', suffix='.txt') if not requirements: return with open(requirements_file, 'w') as f: f.write('\n'.join(requirements)) pip = bake(sh.Command(os.path.join(virtualenv_location, 'bin', 'pip'))) pip.install( requirement=requirements_file, c=os.path.join(virtualenv_location, 'constraints.txt')).wait()
def install(virtualenv_location, package_path, **_): pip = bake(sh.Command(os.path.join(virtualenv_location, 'bin', 'pip'))) pip.install(c=os.path.join(virtualenv_location, 'constraints.txt'), e=package_path).wait()
def install(virtualenv_location, package_path, **_): pip = bake(sh.Command(os.path.join(virtualenv_location, 'bin', 'pip'))) pip.install( c=os.path.join(virtualenv_location, 'constraints.txt'), e=package_path).wait()