Skip to content

Commit 6910482

Browse files
committed
don't configure logging
1 parent d55b6f4 commit 6910482

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

pyppeteer/__init__.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
import logging
77
import os
88

9+
from appdirs import AppDirs
10+
from pyppeteer.launcher import connect, executablePath, launch
11+
12+
from pyppeteer.launcher import defaultArgs # noqa: E402; noqa: E402
13+
914
try:
1015
# noinspection PyCompatibility
1116
from importlib.metadata import version
@@ -19,22 +24,12 @@
1924
except Exception:
2025
pass
2126

22-
from appdirs import AppDirs
2327

2428
__chromium_revision__ = '588429'
2529
__base_puppeteer_version__ = 'v1.6.0'
26-
__pyppeteer_home__ = os.environ.get(
27-
'PYPPETEER_HOME', AppDirs('pyppeteer').user_data_dir) # type: str
30+
__pyppeteer_home__ = os.environ.get('PYPPETEER_HOME', AppDirs('pyppeteer').user_data_dir) # type: str
2831
DEBUG = False
2932

30-
# Setup root logger
31-
_fmt = '[{levelname[0]}:{name}] {msg}'
32-
logging.basicConfig(level=logging.DEBUG, format=_fmt, style='{')
33-
_logger = logging.getLogger(__name__)
34-
_logger.propagate = False
35-
36-
from pyppeteer.launcher import connect, launch, executablePath # noqa: E402
37-
from pyppeteer.launcher import defaultArgs # noqa: E402
3833

3934
version = __version__
4035
version_info = tuple(int(i) for i in version.split('.'))

pyppeteer/chromium_downloader.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
from tqdm import tqdm
1818

1919
logger = logging.getLogger(__name__)
20+
# add our own stream handler - we want some output here
21+
handler = logging.StreamHandler()
22+
handler.setFormatter(fmt=logging.Formatter(fmt="[{levelname}] {msg}", style="{"))
23+
handler.setLevel(logging.INFO)
24+
logger.setLevel(logging.INFO)
25+
logger.addHandler(handler)
2026

2127
DOWNLOADS_FOLDER = Path(__pyppeteer_home__) / 'local-chromium'
2228
DEFAULT_DOWNLOAD_HOST = 'https://storage.googleapis.com'
@@ -67,7 +73,7 @@ def get_url() -> str:
6773

6874
def download_zip(url: str) -> BytesIO:
6975
"""Download data from url."""
70-
logger.info('Starting Chromium download. Download may take a few minutes.')
76+
logger.info('Starting Chromium download.')
7177

7278
with urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where()) as http:
7379
# Get data from url.
@@ -92,13 +98,13 @@ def download_zip(url: str) -> BytesIO:
9298
process_bar.update(len(chunk))
9399
process_bar.close()
94100

95-
logger.info('Chromium download done.')
96101
return _data
97102

98103

99104
def extract_zip(data: BytesIO, path: Path) -> None:
100105
"""Extract zipped data to path."""
101106
# On mac zipfile module cannot extract correctly, so use unzip instead.
107+
logger.info('Beginning extraction')
102108
if current_platform() == 'mac':
103109
import subprocess
104110
import shutil
@@ -125,22 +131,14 @@ def extract_zip(data: BytesIO, path: Path) -> None:
125131
if not exec_path.exists():
126132
raise IOError('Failed to extract chromium.')
127133
exec_path.chmod(exec_path.stat().st_mode | stat.S_IXOTH | stat.S_IXGRP | stat.S_IXUSR)
128-
logger.info(f'chromium extracted to: {path}')
134+
logger.info(f'Chromium extracted to: {path}')
129135

130136

131137
def download_chromium() -> None:
132138
"""Download and extract chromium."""
133139
extract_zip(download_zip(get_url()), DOWNLOADS_FOLDER / REVISION)
134140

135141

136-
def chromium_excutable() -> Path:
137-
"""[Deprecated] miss-spelled function.
138-
Use `chromium_executable` instead.
139-
"""
140-
logger.warning('`chromium_excutable` function is deprecated. ' 'Use `chromium_executable instead.')
141-
return chromium_executable()
142-
143-
144142
def chromium_executable() -> Path:
145143
"""Get path of the chromium executable."""
146144
return chromiumExecutable[current_platform()]

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pyppeteer"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
description = "Headless chrome/chromium automation library (unofficial port of puppeteer)"
55
readme = 'README.md'
66
license = "MIT"
@@ -77,7 +77,7 @@ build-backend = "poetry.core.masonry.api"
7777

7878
[tool.black]
7979
line-length = 120
80-
target-version = ['py37', 'py38', 'py39', 'py310']
80+
target-version = ['py37', 'py38']
8181
skip-string-normalization = true
8282

8383
[tool.isort]

0 commit comments

Comments
 (0)