kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'feature/download_fonts_only_if_missing' into 'master'
Download font file only is not exists in target location See merge request idf/esp-idf!4979pull/3513/head
commit
ef05ccf666
|
@ -10,7 +10,7 @@ import sys
|
||||||
import os
|
import os
|
||||||
sys.path.insert(0, os.path.abspath('..'))
|
sys.path.insert(0, os.path.abspath('..'))
|
||||||
from conf_common import * # noqa: F401, F403 - need to make available everything from common
|
from conf_common import * # noqa: F401, F403 - need to make available everything from common
|
||||||
from local_util import download_file # noqa: E402 - need to import from common folder
|
from local_util import download_file_if_missing # noqa: E402 - need to import from common folder
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'ESP-IDF Programming Guide'
|
project = u'ESP-IDF Programming Guide'
|
||||||
|
@ -22,7 +22,7 @@ language = 'en'
|
||||||
|
|
||||||
# Download font file that is stored on a separate server to save on esp-idf repository size.
|
# Download font file that is stored on a separate server to save on esp-idf repository size.
|
||||||
print("Downloading font file")
|
print("Downloading font file")
|
||||||
download_file('https://dl.espressif.com/dl/esp-idf/docs/_static/DejaVuSans.ttf', '../_static')
|
download_file_if_missing('https://dl.espressif.com/dl/esp-idf/docs/_static/DejaVuSans.ttf', '../_static')
|
||||||
|
|
||||||
# Set up font for blockdiag, nwdiag, rackdiag and packetdiag
|
# Set up font for blockdiag, nwdiag, rackdiag and packetdiag
|
||||||
blockdiag_fontpath = '../_static/DejaVuSans.ttf'
|
blockdiag_fontpath = '../_static/DejaVuSans.ttf'
|
||||||
|
|
|
@ -18,7 +18,14 @@ from __future__ import unicode_literals
|
||||||
from io import open
|
from io import open
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import urllib
|
|
||||||
|
try:
|
||||||
|
import urllib.request
|
||||||
|
_urlretrieve = urllib.request.urlretrieve
|
||||||
|
except ImportError:
|
||||||
|
# Python 2 fallback
|
||||||
|
import urllib
|
||||||
|
_urlretrieve = urllib.urlretrieve
|
||||||
|
|
||||||
|
|
||||||
def run_cmd_get_output(cmd):
|
def run_cmd_get_output(cmd):
|
||||||
|
@ -58,9 +65,13 @@ def copy_if_modified(src_path, dst_path):
|
||||||
copy_file_if_modified(src_file_path, dst_file_path)
|
copy_file_if_modified(src_file_path, dst_file_path)
|
||||||
|
|
||||||
|
|
||||||
def download_file(from_url, to_path):
|
def download_file_if_missing(from_url, to_path):
|
||||||
tmp_file, header = urllib.urlretrieve(from_url)
|
filename_with_path = to_path + "/" + os.path.basename(from_url)
|
||||||
filename = os.path.basename(from_url)
|
exists = os.path.isfile(filename_with_path)
|
||||||
with open(to_path + "/" + filename, 'wb') as fobj:
|
if exists:
|
||||||
with open(tmp_file, 'rb') as tmp:
|
print("The file '%s' already exists" % (filename_with_path))
|
||||||
fobj.write(tmp.read())
|
else:
|
||||||
|
tmp_file, header = _urlretrieve(from_url)
|
||||||
|
with open(filename_with_path, 'wb') as fobj:
|
||||||
|
with open(tmp_file, 'rb') as tmp:
|
||||||
|
fobj.write(tmp.read())
|
||||||
|
|
|
@ -10,7 +10,7 @@ import sys
|
||||||
import os
|
import os
|
||||||
sys.path.insert(0, os.path.abspath('..'))
|
sys.path.insert(0, os.path.abspath('..'))
|
||||||
from conf_common import * # noqa: F401, F403 - need to make available everything from common
|
from conf_common import * # noqa: F401, F403 - need to make available everything from common
|
||||||
from local_util import download_file # noqa: E402 - need to import from common folder
|
from local_util import download_file_if_missing # noqa: E402 - need to import from common folder
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'ESP-IDF 编程指南'
|
project = u'ESP-IDF 编程指南'
|
||||||
|
@ -22,7 +22,7 @@ language = 'zh_CN'
|
||||||
|
|
||||||
# Download font file that is stored on a separate server to save on esp-idf repository size.
|
# Download font file that is stored on a separate server to save on esp-idf repository size.
|
||||||
print("Downloading font file")
|
print("Downloading font file")
|
||||||
download_file('https://dl.espressif.com/dl/esp-idf/docs/_static/NotoSansSC-Regular.otf', '../_static')
|
download_file_if_missing('https://dl.espressif.com/dl/esp-idf/docs/_static/NotoSansSC-Regular.otf', '../_static')
|
||||||
|
|
||||||
# Set up font for blockdiag, nwdiag, rackdiag and packetdiag
|
# Set up font for blockdiag, nwdiag, rackdiag and packetdiag
|
||||||
blockdiag_fontpath = '../_static/NotoSansSC-Regular.otf'
|
blockdiag_fontpath = '../_static/NotoSansSC-Regular.otf'
|
||||||
|
|
Ładowanie…
Reference in New Issue