Skip to content

Commit d16ddc4

Browse files
chore: update pipenv (#278)
* chore: update pipenv * chore: use pipenv to update requirements file * chore: run black for formatting * chore: update release script to take new version into account * chore: update tests to run on non deprecated python versions chore: update versions to 3.10 * chore: update python version used to build pypi
1 parent 0202e12 commit d16ddc4

File tree

12 files changed

+892
-688
lines changed

12 files changed

+892
-688
lines changed

.github/workflows/pypi-upload.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: PyPI Upload
22

33
on:
44
release:
5-
types: [ created ]
5+
types: [created]
66

77
jobs:
88
machine_stats:
@@ -13,24 +13,24 @@ jobs:
1313
working-directory: unix
1414

1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1717

18-
- uses: actions/setup-python@v3
18+
- uses: actions/setup-python@v6
1919
with:
20-
python-version: 3.8
20+
python-version: 3.10
2121
architecture: x64
2222

2323
- name: Autobump version
2424
run: |
2525
# from refs/tags/v1.2.3 get 1.2.3
2626
VERSION=${GITHUB_REF/refs\/tags\//}
27-
PLACEHOLDER='version="develop"'
27+
PLACEHOLDER='version="0.0.1-dev"'
2828
VERSION_FILE='setup.py'
2929
3030
# grep ensures the placeholder is there. If grep doesn't find the placeholder
31-
# it exits with exit code 1 and github actions aborts the build.
31+
# it exits with exit code 1 and github actions aborts the build.
3232
grep "$PLACEHOLDER" "$VERSION_FILE"
33-
33+
3434
sed -i "s/$PLACEHOLDER/version=\"${VERSION}\"/g" "$VERSION_FILE"
3535
3636
- name: Install pypa/build and twine
@@ -60,7 +60,7 @@ jobs:
6060
with:
6161
python-version: 3.8
6262
architecture: x64
63-
63+
6464
- name: Autobump version
6565
run: |
6666
# from refs/tags/v1.2.3 get 1.2.3
@@ -69,9 +69,9 @@ jobs:
6969
VERSION_FILE='setup.py'
7070
7171
# grep ensures the placeholder is there. If grep doesn't find the placeholder
72-
# it exits with exit code 1 and github actions aborts the build.
72+
# it exits with exit code 1 and github actions aborts the build.
7373
grep "$PLACEHOLDER" "$VERSION_FILE"
74-
74+
7575
sed -i "s/$PLACEHOLDER/version=\"${VERSION}\"/g" "$VERSION_FILE"
7676
7777
- name: Install pypa/build and twine

.github/workflows/python-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.8", "3.9", "3.10"]
14+
python-version: ["3.10", "3.11"]
1515

1616
steps:
1717
- uses: actions/checkout@v3

unix/Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ machine_stats = {editable = true, path = "."}
99
pluginbase = "*"
1010

1111
[dev-packages]
12-
black = "==22.1.0"
12+
black = ">=25.0.0,<26.0.0"
1313
flake8 = "*"
1414
isort = "*"
1515
pylint = "*"

unix/Pipfile.lock

Lines changed: 776 additions & 577 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unix/dev-requirements.txt

Lines changed: 50 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,53 @@
1-
#
2-
# These requirements were autogenerated by pipenv
3-
# To regenerate from the project's Pipfile, run:
4-
#
5-
# pipenv lock --requirements --dev
6-
#
7-
8-
# Note: in pipenv 2020.x, "--dev" changed to emit both default and development
9-
# requirements. To emit only development requirements, pass "--dev-only".
10-
11-
-i https://pypi.org/simple/
12-
-e .
13-
-e .
14-
ansible==2.9.22
15-
astroid==2.12.13
16-
black==22.1.0
17-
bleach==5.0.1
18-
build==0.9.0
1+
-i https://pypi.org/simple
2+
astroid==4.0.1
3+
backports.tarfile==1.2.0
4+
black==25.9.0
5+
build==1.3.0
196
bump2version==1.0.1
20-
certifi==2022.12.7
21-
cffi==1.15.1
22-
charset-normalizer==2.1.1
23-
click==8.1.3
24-
commonmark==0.9.1
25-
cryptography==39.0.0
26-
dill==0.3.6; python_version < '3.11'
27-
docutils==0.19
28-
flake8==6.0.0
29-
idna==3.4
30-
importlib-metadata==6.0.0
31-
importlib-resources==5.10.2; python_version < '3.9'
32-
isort==5.11.4
33-
jaraco.classes==3.2.3
34-
jeepney==0.8.0
35-
keyring==23.13.1
36-
lazy-object-proxy==1.9.0
7+
certifi==2025.10.5
8+
charset-normalizer==3.4.4
9+
click==8.3.0
10+
dill==0.4.0
11+
docutils==0.22.2
12+
exceptiongroup==1.3.0
13+
flake8==7.3.0
14+
id==1.5.0
15+
idna==3.11
16+
importlib-metadata==8.7.0
17+
iniconfig==2.3.0
18+
isort==7.0.0
19+
jaraco.classes==3.4.0
20+
jaraco.context==6.0.1
21+
jaraco.functools==4.3.0
22+
keyring==25.6.0
23+
markdown-it-py==4.0.0
3724
mccabe==0.7.0
38-
more-itertools==9.0.0
39-
mypy-extensions==0.4.3
40-
packaging==22.0
41-
pathspec==0.10.3
42-
pep517==0.13.0
43-
pkginfo==1.9.3
44-
platformdirs==2.6.2
45-
pycodestyle==2.10.0
46-
pycparser==2.21
47-
pyflakes==3.0.1
48-
pygments==2.14.0
49-
pylint==2.15.9
50-
readme-renderer==37.3
51-
requests-toolbelt==0.10.1
52-
requests==2.28.1
25+
mdurl==0.1.2
26+
more-itertools==10.8.0
27+
mypy-extensions==1.1.0
28+
nh3==0.3.1
29+
packaging==25.0
30+
pathspec==0.12.1
31+
platformdirs==4.5.0
32+
pluggy==1.6.0
33+
pycodestyle==2.14.0
34+
pyflakes==3.4.0
35+
pygments==2.19.2
36+
pylint==4.0.2
37+
pyproject-hooks==1.2.0
38+
pytest==8.4.2
39+
pytest-mock==3.15.1
40+
pytokens==0.2.0
41+
readme-renderer==44.0
42+
requests==2.32.5
43+
requests-toolbelt==1.0.0
5344
rfc3986==2.0.0
54-
rich==13.0.0
55-
secretstorage==3.3.3; sys_platform == 'linux'
56-
six==1.16.0
57-
tomli==2.0.1
58-
tomlkit==0.11.6
59-
twine==4.0.2
60-
typing-extensions==4.4.0; python_version < '3.10'
61-
urllib3==1.26.13
62-
webencodings==0.5.1
63-
wheel==0.38.4
64-
wrapt==1.14.1; python_version < '3.11'
65-
zipp==3.11.0; python_version < '3.10'
66-
pytest
67-
pytest-mock
45+
rich==14.2.0
46+
setuptools==80.9.0
47+
tomli==2.3.0
48+
tomlkit==0.13.3
49+
twine==6.2.0
50+
typing-extensions==4.15.0
51+
urllib3==2.5.0
52+
wheel==0.45.1
53+
zipp==3.23.0

unix/flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
python310Packages.pluggy
3939
python310Packages.wheel
4040
python310Packages.setuptools
41+
pipenv
4142
libvirt
4243
];
4344

unix/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
22
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta:__legacy__"
3+
build-backend = "setuptools.build_meta:__legacy__"

unix/requirements.txt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
#
2-
# These requirements were autogenerated by pipenv
3-
# To regenerate from the project's Pipfile, run:
4-
#
5-
# pipenv lock --requirements
6-
#
7-
81
-i https://pypi.org/simple
2+
ansible==2.9.27
3+
cffi==2.0.0
4+
cryptography==46.0.3
5+
jinja2==3.1.6
96
-e .
10-
ansible==2.9.20
11-
cffi==1.15.1
12-
cryptography==38.0.4
13-
jinja2==3.1.2
14-
markupsafe==2.1.1
7+
markupsafe==3.0.3
158
pluginbase==1.0.1
16-
pycparser==2.21
9+
pycparser==2.23
1710
pyyaml==6.0.3
11+
typing-extensions==4.15.0

unix/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="machine_stats",
8-
version="0.1.1",
8+
version="0.0.1-dev",
99
author="Tidal SW",
1010
author_email="support@tidalcloud.com",
1111
description="A simple and effective way to gather machine statistics (RAM, Storage, CPU, etc.) from server environment",

unix/src/machine_stats/__init__.py

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
for k, v in default_config.items():
1919
os.environ[k] = v
2020

21+
2122
# Loading config file must be prior to importing most of the ansible.* packages
2223
def find_config_file():
2324
"""Find configuration file"""
@@ -104,22 +105,27 @@ def method(*args, **kwargs):
104105

105106
return method
106107

108+
107109
def ram_allocated_gb(facts):
108110
"""Return total memory allocation in GB"""
109111
return facts["ansible_memtotal_mb"] / 1024
110112

113+
111114
def ram_used_gb(facts):
112115
"""Return used memory in GB"""
113116
return (facts["ansible_memtotal_mb"] - facts["ansible_memfree_mb"]) / 1024
114117

118+
115119
def _size(key, mounts):
116120
return sum([item.get(key, 0) for item in mounts])
117121

122+
118123
def storage_allocated_gb(facts):
119124
"""Return total storage allocation in GB"""
120125
if "ansible_mounts" not in facts:
121126
return 0
122-
return _size("size_total", facts["ansible_mounts"]) / 1024 ** 3
127+
return _size("size_total", facts["ansible_mounts"]) / 1024**3
128+
123129

124130
def storage_used_gb(facts):
125131
"""Return used storage in GB"""
@@ -128,12 +134,14 @@ def storage_used_gb(facts):
128134
return (
129135
_size("size_total", facts["ansible_mounts"])
130136
- _size("size_available", facts["ansible_mounts"])
131-
) / 1024 ** 3
137+
) / 1024**3
138+
132139

133140
def cpu_logical_processors(facts):
134141
"""Return the number of CPU logical processors."""
135142
return int(facts.get("ansible_processor_vcpus", 0))
136143

144+
137145
def cpu_name(proc):
138146
"""Return CPU name"""
139147
items_count = len(proc)
@@ -143,10 +151,16 @@ def cpu_name(proc):
143151
return proc[2]
144152
return "Unknown"
145153

154+
146155
def ip_addresses(facts):
147156
"""Return IP addresses formatted for the tidal API"""
148-
return list(map(lambda ip: {"address": ip},
149-
facts["ansible_all_ipv4_addresses"] + facts["ansible_all_ipv6_addresses"]))
157+
return list(
158+
map(
159+
lambda ip: {"address": ip},
160+
facts["ansible_all_ipv4_addresses"] + facts["ansible_all_ipv6_addresses"],
161+
)
162+
)
163+
150164

151165
class ResultCallback(CallbackBase):
152166
"""A sample callback plugin used for performing an action as results come in
@@ -189,14 +203,17 @@ def update_results(self, host, data: dict):
189203
if host not in self._total_results:
190204
self._total_results[host] = data
191205
return
192-
206+
193207
# Ensure we append any custom fields, rather than overwriting them
194-
if 'custom_fields' in data and 'custom_fields' in self._total_results[host]:
195-
combined_custom_fields = {**self._total_results[host]['custom_fields'], **data['custom_fields']}
196-
data['custom_fields'].update(combined_custom_fields)
208+
if "custom_fields" in data and "custom_fields" in self._total_results[host]:
209+
combined_custom_fields = {
210+
**self._total_results[host]["custom_fields"],
211+
**data["custom_fields"],
212+
}
213+
data["custom_fields"].update(combined_custom_fields)
197214
self._total_results[host].update(data)
198215
return
199-
216+
200217
self._total_results[host].update(data)
201218

202219
def v2_runner_on_ok(self, result):
@@ -241,37 +258,37 @@ def v2_playbook_on_stats(self, stats):
241258
t = stats.summarize(h) # pylint: disable=invalid-name
242259

243260
self._display.display(
244-
u"%s : %s %s %s %s %s %s %s"
261+
"%s : %s %s %s %s %s %s %s"
245262
% (
246263
hostcolor(h, t),
247-
colorize(u"ok", t["ok"], C.COLOR_OK), # pylint: disable=no-member
264+
colorize("ok", t["ok"], C.COLOR_OK), # pylint: disable=no-member
248265
colorize(
249-
u"changed",
266+
"changed",
250267
t["changed"],
251268
C.COLOR_CHANGED, # pylint: disable=no-member
252269
),
253270
colorize(
254-
u"unreachable",
271+
"unreachable",
255272
t["unreachable"],
256273
C.COLOR_UNREACHABLE, # pylint: disable=no-member
257274
),
258275
colorize(
259-
u"failed",
276+
"failed",
260277
t["failures"],
261278
C.COLOR_ERROR, # pylint: disable=no-member
262279
),
263280
colorize(
264-
u"skipped",
281+
"skipped",
265282
t["skipped"],
266283
C.COLOR_SKIP, # pylint: disable=no-member
267284
),
268285
colorize(
269-
u"rescued",
286+
"rescued",
270287
t["rescued"],
271288
C.COLOR_OK, # pylint: disable=no-member
272289
),
273290
colorize(
274-
u"ignored",
291+
"ignored",
275292
t["ignored"],
276293
C.COLOR_WARN, # pylint: disable=no-member
277294
),
@@ -322,7 +339,9 @@ def v2_playbook_on_stats(self, stats):
322339
server_dict["measurable_type"] = "server"
323340
server_dict["field_name"] = custom_field + "_timeseries"
324341
server_dict["value"] = server["custom_fields"][custom_field]
325-
server_dict["external_timestamp"] = server["custom_fields"]["cpu_utilization_timestamp"]
342+
server_dict["external_timestamp"] = server["custom_fields"][
343+
"cpu_utilization_timestamp"
344+
]
326345
server_dict["measurable"] = {
327346
"host_name": server["host_name"]
328347
}

0 commit comments

Comments
 (0)