Print progress messages during download.

This commit is contained in:
Eric Snow 2018-01-11 18:36:14 +00:00
parent cbfe55a56a
commit a93d0ed25c
2 changed files with 13 additions and 3 deletions

View file

@ -21,17 +21,21 @@ def as_command(name):
def handle_download(source=UPSTREAM, target=VENDORED, *,
_open=open, _open_url=open_url):
# Download the schema file.
print('downloading the schema file from {}...'.format(source))
with _open_url(source) as infile:
with _open(target, 'wb') as outfile:
meta = download(source, infile, outfile,
_open_url=_open_url)
print('...schema file written to {}.'.format(target))
# Save the metadata.
metafile, _ = open_metadata(target, 'w',
_open=_open)
print('saving the schema metadata...')
metafile, filename = open_metadata(target, 'w',
_open=_open)
with metafile:
metafile.write(
meta.format())
print('...metadata written to {}.'.format(filename))
@as_command('check')

View file

@ -4,6 +4,7 @@ from textwrap import dedent
import unittest
from .helpers import StubOpener
from debugger_protocol.schema.vendored import FILENAME as VENDORED, METADATA
from debugger_protocol.schema.__main__ import (
COMMANDS, handle_download, handle_check)
@ -58,7 +59,12 @@ class HandleDownloadTests(unittest.TestCase):
revision: fc2395ca3564fb2afded8d90ddbe38dad1bf86f1
checksum: e778c3751f9d0bceaf8d5aa81e2c659f
""").strip()) # noqa
self.assertEqual(stdout.getvalue(), '')
self.assertEqual(stdout.getvalue(), dedent("""\
downloading the schema file from https://github.com/Microsoft/vscode-debugadapter-node/raw/master/debugProtocol.json...
...schema file written to {}.
saving the schema metadata...
...metadata written to {}.
""").format(VENDORED, METADATA)) # noqa
class HandleCheckTests(unittest.TestCase):