Skip to content

Commit 3a26898

Browse files
committed
modify: runner - added custom params option
1 parent 2cbf023 commit 3a26898

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
-
9+
## [1.0.2] - 2019-02-22
10+
### Changed
11+
- added option to runner to pass custom parameters
912

1013
## [1.0.1] - 2019-02-14
1114
### Changed
@@ -18,3 +21,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1821

1922
[Unreleased]: https://github.com/adamcupial/lighthouse-python/compare/1.0.1...HEAD
2023
[1.0.1]: https://github.com/adamcupial/lighthouse-python/compare/1.0.0...1.0.1
24+
[1.0.2]: https://github.com/adamcupial/lighthouse-python/compare/1.0.1...1.0.2

lighthouse/runner.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,32 @@ class LighthouseRunner(object):
1818
report (LighthouseReport): object with simplified report
1919
"""
2020

21-
def __init__(self, url, form_factor='mobile', quiet=True):
21+
def __init__(self, url, form_factor='mobile', quiet=True,
22+
additional_settings=None):
2223
"""
2324
Args:
2425
url (str): url to test
2526
form_factor (str, optional): either mobile or desktop,
2627
default is mobile
2728
quiet (bool, optional): should not output anything to stdout,
2829
default is True
30+
additional_settings (list, optional): list of additional params
2931
"""
3032

3133
assert form_factor in ['mobile', 'desktop']
3234

3335
_, self.__report_path = tempfile.mkstemp(suffix='.json')
34-
self._run(url, form_factor, quiet)
36+
self._run(url, form_factor, quiet, additional_settings)
3537
self.report = self._get_report()
3638
self._clean()
3739

38-
def _run(self, url, form_factor, quiet):
40+
def _run(self, url, form_factor, quiet, additional_settings=None):
3941
report_path = self.__report_path
4042

43+
additional_settings = additional_settings or []
44+
4145
try:
42-
subprocess.check_call(' '.join([
46+
command = [
4347
'lighthouse',
4448
url,
4549
'--quiet' if quiet else '',
@@ -48,7 +52,10 @@ def _run(self, url, form_factor, quiet):
4852
'--emulated-form-factor={0}'.format(form_factor),
4953
'--output=json',
5054
'--output-path={0}'.format(report_path),
51-
]), shell=True)
55+
]
56+
57+
command = command + additional_settings
58+
subprocess.check_call(' '.join(command), shell=True)
5259
except subprocess.CalledProcessError as exc:
5360
msg = '''
5461
Command "{0}"

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#!/usr/bin/env python
2-
1+
# this python file uses the following encoding utf-8
32
from setuptools import setup, find_packages
43

54
setup(
65
name='lighthouse',
7-
version='1.0.1',
6+
version='1.0.2',
87
description='Lightouse runner',
9-
author='Adam Cupiał',
8+
author='Adam Cupial',
109
author_email='cupial.adam@gmail.com',
1110
url='n/a',
1211
packages=find_packages(),

0 commit comments

Comments
 (0)