def _cmd_create(args): data = { 'id': args.ID, 'playlist': 'lobby', 'template': 'main' } pooldir = os.path.join('lobbyscreens', args.ID) os_utils.ensureDirExists(pooldir, noisy=True) os_utils.ensureDirExists(os.path.join(pooldir, 'files'), noisy=True) written = [] with open(os.path.join(pooldir, '__POOL__.yml'), 'w') as f: yaml.dump(data, f, default_flow_style=False) log.info('Wrote %s.', f.name) written += [f.name] with open('.gitignore', 'w') as f: f.write('/parsed.yml\n') written += [f.name] with os_utils.Chdir(pooldir): if not os.path.isdir('.git'): os_utils.cmd(['git', 'init'], echo=True, show_output=True, critical=True) os_utils.cmd(['git', 'lfs', 'install'], echo=True, show_output=True, critical=True) os_utils.cmd(['git', 'lfs', 'track', '*.png', '*.gif', '*.jpg', '*.webm', '*.webp'], echo=True, show_output=True, critical=True) os_utils.cmd(['git', 'add', '.gitattributes']+written, echo=True, show_output=True, critical=True)
def build(self): opts = self.buildOpts() with os_utils.Chdir(self.working_dir): os_utils.cmd([self.exe_path] + self.opts, show_output=True, echo=self.should_echo_commands(), critical=True) if not os.path.isfile(self.target): self.touch(self.target)
def build(self): with os_utils.Chdir(os.path.join(self.base_path)): os_utils.cmd([os_utils.which('yarn')], echo=True, show_output=True, critical=True) os_utils.cmd([os_utils.which('grunt'), 'requirejs', 'uglify:main'], echo=True, show_output=True, critical=True)
def build(self): with os_utils.Chdir(self.cwd): os_utils.cmd(self.cmd, show_output=self.show_output, echo=self.should_echo_commands() if self.echo is None else self.echo, critical=True, globbify=self.globbify) for t in self.provides(): self.touch(t)
def build(self): gitmodules = {} with open(self.gitmodulesfile, 'r') as tomlf: smid = None for line in tomlf: line = line.strip() m = REG_SUBMODULE_SECTION.match(line) if m is not None: smid = m.group(1).strip() gitmodules[smid] = {} if '=' in line: k, v = line.split('=', 2) gitmodules[smid][k.strip()] = v.strip() gitconfig = {} with open(self.gitconfigfile, 'r') as tomlf: smid = None for line in tomlf: line = line.strip() #print(line) m = REG_SUBMODULE_SECTION.match(line) if m is not None: smid = m.group(1).strip() gitconfig[smid] = {} if smid is not None and '=' in line: #print(line) k, v = line.split('=', 2) gitconfig[smid][k.strip()] = v.strip() ''' with open(self.gitmodulesfile + '.yml', 'w') as f: yaml.dump(gitmodules, f, default_flow_style=False) with open('.gitconfig.yml', 'w') as f: yaml.dump(gitconfig, f, default_flow_style=False) ''' for repoID, repoconf in gitconfig.items(): if repoID not in gitmodules.keys(): with log.warn('Submodule %s is present in .git/config but not .gitmodules!', repoID): pathspec = repoconf.get('path', repoID) path = os.path.abspath(pathspec) tag = repoconf.get('tag', None) branch = repoconf.get('branch', 'HEAD' if tag is None else None) log.info('path = %s', pathspec) for repoID, repoconf in gitmodules.items(): if repoID not in gitconfig.keys(): with log.warn('Submodule %s is present in .gitmodules but not .git/config!', repoID): pathspec = repoconf.get('path', repoID) path = os.path.abspath(pathspec) tag = repoconf.get('tag', None) branch = repoconf.get('branch', 'HEAD' if tag is None else None) opts = [] if branch != 'HEAD': opts += ['-b', branch] log.info('path = %s', pathspec) if os.path.isdir(path): log.warn('Removing existing %s directory.', path) shutil.rmtree(path) cmd = ['git', 'submodule', 'add']+opts+['-f', '--name', repoID, '--', repoconf.get('url'), pathspec] os_utils.cmd(cmd, critical=True, echo=self.should_echo_commands(), show_output=True) #log.error('Would exec: %s', ' '.join(cmd)) for repoID, repoconf in gitmodules.items(): with log.info('Checking %s...', repoID): pathspec = repoconf.get('path', repoID) path = os.path.abspath(pathspec) tag = repoconf.get('tag', None) branch = repoconf.get('branch', 'HEAD' if tag is None else None) if os.path.isdir(path): desired_commit = '' cmdline = ['git', 'ls-tree', Git.GetBranch(), pathspec] stdout, stderr = os_utils.cmd_output(cmdline, echo=self.should_echo_commands(), critical=True) skip_this = False for line in (stdout+stderr).decode('utf-8').splitlines(): if line.startswith('error:') or line.startswith('fatal:'): log.critical(line) raise error.SubprocessThrewError(cmdline, line) line,repoID = line.strip().split('\t') _, _, desired_commit = line.split(' ') if not skip_this: with os_utils.Chdir(path, quiet=not self.should_echo_commands()): cur_commit = Git.GetCommit(short=False, quiet=not self.should_echo_commands()) #log.info(desired_commit) #log.info(cur_commit) if cur_commit == desired_commit: log.info('Commits are synced, skipping.') continue repo = GitRepository(path, origin_uri=repoconf['url'], submodule=True) if repo.CheckForUpdates(branch=branch, quiet=False): if os.path.isdir(path): os_utils.cmd(['git', 'submodule', 'sync', '--', pathspec], critical=True, echo=self.should_echo_commands(), show_output=True) os_utils.cmd(['git', 'submodule', 'update', '--init', '--recursive', pathspec], critical=True, echo=self.should_echo_commands(), show_output=True)