Merge pull request #5175 from tk0miya/5161_html_crashes_on_copying

Fix html: crashes if copying static files are failed (refs: #5161)
This commit is contained in:
Takeshi KOMIYA 2018-07-16 14:51:38 +09:00 committed by GitHub
commit c777b920c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 73 additions and 64 deletions

View File

@ -44,6 +44,7 @@ Bugs fixed
sorting sorting
* #5139: autodoc: Enum argument missing if it shares value with another * #5139: autodoc: Enum argument missing if it shares value with another
* #4946: py domain: rtype field could not handle "None" as a type * #4946: py domain: rtype field could not handle "None" as a type
* #5161: html: crashes if copying static files are failed
Testing Testing
-------- --------

View File

@ -740,12 +740,13 @@ class StandaloneHTMLBuilder(Builder):
try: try:
copyfile(path.join(self.srcdir, src), copyfile(path.join(self.srcdir, src),
path.join(self.outdir, '_downloads', dest)) path.join(self.outdir, '_downloads', dest))
except Exception as err: except EnvironmentError as err:
logger.warning('cannot copy downloadable file %r: %s', logger.warning('cannot copy downloadable file %r: %s',
path.join(self.srcdir, src), err) path.join(self.srcdir, src), err)
def copy_static_files(self): def copy_static_files(self):
# type: () -> None # type: () -> None
try:
# copy static files # copy static files
logger.info(bold('copying static files... '), nonl=True) logger.info(bold('copying static files... '), nonl=True)
ensuredir(path.join(self.outdir, '_static')) ensuredir(path.join(self.outdir, '_static'))
@ -804,9 +805,14 @@ class StandaloneHTMLBuilder(Builder):
copyfile(path.join(self.confdir, self.config.html_favicon), copyfile(path.join(self.confdir, self.config.html_favicon),
icontarget) icontarget)
logger.info('done') logger.info('done')
except EnvironmentError as err:
# TODO: In py3, EnvironmentError (and IOError) was merged into OSError.
# So it should be replaced by IOError on dropping py2 support
logger.warning(__('cannot copy static file %r'), err)
def copy_extra_files(self): def copy_extra_files(self):
# type: () -> None # type: () -> None
try:
# copy html_extra_path files # copy html_extra_path files
logger.info(bold('copying extra files... '), nonl=True) logger.info(bold('copying extra files... '), nonl=True)
excluded = Matcher(self.config.exclude_patterns) excluded = Matcher(self.config.exclude_patterns)
@ -819,6 +825,8 @@ class StandaloneHTMLBuilder(Builder):
copy_asset(entry, self.outdir, excluded) copy_asset(entry, self.outdir, excluded)
logger.info('done') logger.info('done')
except EnvironmentError as err:
logger.warning(__('cannot copy extra file %r'), err)
def write_buildinfo(self): def write_buildinfo(self):
# type: () -> None # type: () -> None