Skip to content

Commit 6db96a3

Browse files
committed
generate browsers.json
1 parent d81fdcb commit 6db96a3

File tree

7 files changed

+29
-15
lines changed

7 files changed

+29
-15
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Debug dir
2+
results/
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

helpers/config_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from helpers.open_file import OpenFile
1+
from helpers.open_config_file import OpenFile
22
from pykwalify.core import Core
33
from icecream import ic
44

helpers/file_generators/json/generator.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
class Generator:
55

6-
def __init__(self):
7-
pass
6+
def __init__(self, data: dict, file_path: str) -> None:
7+
self.data = data
8+
self.file_path = file_path
89

9-
def __call__(self):
10-
pass
10+
def __call__(self) -> None:
11+
self.json_data_dump_to_file()
1112

12-
def json_data_dump(self):
13-
json_data = json.dumps(self.data)
13+
def json_data_dump_to_file(self) -> None:
14+
with open(self.file_path, 'w') as json_file:
15+
json.dump(self.data, json_file, sort_keys=True, indent=4)

helpers/http_requests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(
2323
headers: dict = None,
2424
body: dict = None,
2525
secure: bool = None
26-
):
26+
) -> None:
2727
if secure is False:
2828
self.protocol = 'http'
2929
else:
@@ -50,7 +50,7 @@ def __init__(
5050

5151
self.requests_session = requests.session()
5252

53-
def get(self):
53+
def get(self) -> dict:
5454
try:
5555
response = self.requests_session.get(self.url, headers=self.headers, timeout=(10, 10))
5656
except TimeoutError:

helpers/open_file.py helpers/open_config_file.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class OpenFile:
77

8-
def __init__(self, file_path):
8+
def __init__(self, file_path: str) -> None:
99
self.file_path = path.abspath(file_path)
1010
self.allow_yaml_formats = ['yaml', 'yml']
1111
self.allow_json_formats = ['json']

main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from helpers.change_root_dir import ChangeRootDir
77
from helpers.config_parser import ConfigParser
88
from src.configurator import Configurator
9-
from helpers.open_file import OpenFile
9+
from helpers.open_config_file import OpenFile
1010

1111
def init() -> None:
1212
try:

src/configurator.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from helpers.config_parser import ConfigParser
22
from helpers.http_requests import HttpRequests
3+
from helpers.file_generators import JsonGenerator
4+
35
from icecream import ic
46
import json
57

@@ -230,14 +232,21 @@ def __init__(self) -> None:
230232
ic(self.hosts_dict)
231233

232234
def __call__(self) -> None:
233-
self.generate_result()
234235
self.configurate_browsers()
235236

236-
def generate_result(self) -> None:
237-
pass
238-
239237
def configurate_browsers(self) -> None:
238+
# TODO: if ggr exist in config
239+
# TODO: config for each selenoid ip
240240
browsers_json_dict = self._generate_selenoid_browsers_json_file()
241+
browsers_json_paths = (
242+
'./results/selenoid/config/browsers.json',
243+
'./results/ggr/config/browsers.json'
244+
)
245+
for browser_json_path in browsers_json_paths:
246+
JsonGenerator(
247+
browsers_json_dict,
248+
browser_json_path
249+
).json_data_dump_to_file()
241250

242251
def _browser_count_check(self) -> None:
243252
""" Validation: count of browsers > 0 """

0 commit comments

Comments
 (0)