def checkout_branch(self, dst=PROJECT_ROOT, branch='develop'): fs.chdir(fs.join(dst, self.name)) try: check_call(['git', 'checkout', branch]) except CalledProcessError as e: if e.returncode == 1: check_call( ['git', 'checkout', '-b', 'develop', 'origin/develop']) fs.chdir('../../')
def check(self, dst=PROJECT_ROOT): logger.info('----------------------' * 3) logger.info('Check project: {!r}'.format(self.name)) if not fs.exists(dst): fs.makedirs(dst) fs.chdir(dst) if self.exists(): self.remove() compress_path = self.download(dst) logger.info('Uncompress from {!r} to {!r}'.format(compress_path, dst)) fs.uncompress(compress_path, dst=PROJECT_ROOT, temp_dir=PROJECT_ROOT)
def with_module(module_names): if module_names == '': logger.info('Need not modules') else: for module_name in module_names.split(','): module_string = '' module_version = [] module_url = REPO_URL[module_name] module_names = [ f for f in os.listdir(DIST_ROOT) if os.path.isfile(os.path.join(DIST_ROOT, f)) ] module_names = [f for f in module_names if module_name in f] if len(module_names) == 0: content = requests.get(module_url).text module_names = re.findall( r'>({}.*)</a>'.format(module_name), content) if len(module_names) == 0: logger.info( 'Can not find the {} package ,dispatcher build failed'. format(module_name)) sys.exit() for name in module_names: module_string += name module_version = re.findall('[-@](\d+\.\d+\.\d+)', module_string) module_version = max(module_version) for diff_version_module in REPO_NAME[module_name]: source_name = diff_version_module.format(module_version) link_name = diff_version_module.format('latest') source = join(module_url, source_name) target = join(DIST_ROOT, 'platform-ant-dispatcher/repo/', source_name) if os.path.exists(join(DIST_ROOT, source_name)): fs.copy(join(DIST_ROOT, source_name), target) else: Step.download(source, target) fs.chdir(join(DIST_ROOT, 'platform-ant-dispatcher/repo/')) check_call('ln -s {} {}'.format(source_name, link_name), shell=True) fs.chdir('../../../')
def clone(self, dst=PROJECT_ROOT): fs.makedirs(dst) fs.chdir(dst) check_call(['git', 'clone', self.url, self.name]) fs.chdir('../')
def pull(self, dst=PROJECT_ROOT): fs.chdir(fs.join(dst, self.name)) check_call(['git', 'pull'])