示例#1
0
    def begin_html(self):
        if osp.isfile(self.visdir):
            raise FileExistsError('Visualization dir "{}" is a file.'.format(
                self.visdir))
        elif osp.isdir(self.visdir):
            if yes_or_no(
                    'Visualization dir "{}" is not empty. Do you want to overwrite?'
                    .format(self.visdir)):
                shutil.rmtree(self.visdir)
            else:
                raise FileExistsError(
                    'Visualization dir "{}" already exists.'.format(
                        self.visdir))

        io.mkdir(self.visdir)
        io.mkdir(osp.join(self.visdir, 'assets'))
        self._index_file = open(self.get_index_filename(), 'w')
        self._print('<html>')
        self._print('<head>')
        self._print('<title>{}</title>'.format(self.title))
        self._print('<style>')
        self._print('td {vertical-align:top;padding:5px}')
        self._print('</style>')
        self._print('</head>')
        self._print('<body>')
        self._print('<h1>{}</h1>'.format(self.title))
示例#2
0
文件: git.py 项目: vacancy/Jacinle
def git_guard(force=False):
    uncommitted_files = git_uncommitted_files()
    if len(uncommitted_files) > 0:
        from jacinle.logging import get_logger
        from jacinle.cli.keyboard import yes_or_no
        logger = get_logger(__file__)

        logger.warning('Uncommited changes at the current repo:\n  ' +
                       '\n  '.join(uncommitted_files))
        if force:
            if not yes_or_no('Are you sure you want to continue?',
                             default='no'):
                exit(1)
        logger.info(git_status_full())