Skip to content

Commit 7c51620

Browse files
authored
Merge pull request #497 from jfly/add-ruff-formatting
Add ruff-format to treefmt (to format Python files)
2 parents 2f0e117 + 3440e39 commit 7c51620

File tree

5 files changed

+140
-142
lines changed

5 files changed

+140
-142
lines changed

build/datadog/hydra.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import requests
66
import json
77

8+
89
class HydraCheck(AgentCheck):
910
def check(self, instance):
10-
r = requests.get('http://localhost:3000/status', headers={'Content-Type':'application/json'})
11-
self.gauge('hydra.active_buildsteps', len(json.loads(r.text)))
12-
11+
r = requests.get(
12+
"http://localhost:3000/status", headers={"Content-Type": "application/json"}
13+
)
14+
self.gauge("hydra.active_buildsteps", len(json.loads(r.text)))

build/pluto/prometheus/exporters/channel-exporter.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@
3535
"Number of channel status requests which have failed",
3636
)
3737

38+
3839
@CHANNEL_REQUEST_TIME.time()
3940
def measure_channel(name):
4041
try:
4142
with CHANNEL_REQUEST_FAILURES.count_exceptions():
42-
result = requests.get(f"https://nixos.org/channels/{name}/git-revision", timeout=10)
43+
result = requests.get(
44+
f"https://nixos.org/channels/{name}/git-revision", timeout=10
45+
)
4346

4447
try:
4548
return {
4649
"timestamp": parse(result.headers["last-modified"]).timestamp(),
47-
"revision": result.text
50+
"revision": result.text,
4851
}
4952
except KeyError as e:
5053
print(f"Got KeyError after getting our result for {name}:")
@@ -66,19 +69,29 @@ def measure_channel(name):
6669
revisions = {}
6770

6871
while True:
69-
for (channel, about) in channels.items():
72+
for channel, about in channels.items():
7073
measurement = measure_channel(channel)
7174
if measurement is not None:
72-
revision = measurement['revision']
73-
status = about.get('status', '')
74-
variant = about.get('variant', '')
75-
current = int(status != 'unmaintained')
76-
CHANNEL_UPDATE_TIME.labels(channel=channel).set(measurement['timestamp'])
77-
CHANNEL_REVISION.labels(channel=channel, revision=revision, status=status, variant=variant, current=current).set(1)
75+
revision = measurement["revision"]
76+
status = about.get("status", "")
77+
variant = about.get("variant", "")
78+
current = int(status != "unmaintained")
79+
CHANNEL_UPDATE_TIME.labels(channel=channel).set(
80+
measurement["timestamp"]
81+
)
82+
CHANNEL_REVISION.labels(
83+
channel=channel,
84+
revision=revision,
85+
status=status,
86+
variant=variant,
87+
current=current,
88+
).set(1)
7889
CHANNEL_CURRENT.labels(channel=channel).set(current)
79-
print('updated {}'.format(channel))
90+
print("updated {}".format(channel))
8091
previous_revision = revisions.pop(channel, None)
8192
revisions[channel] = revision
8293
if previous_revision and previous_revision != revision:
83-
CHANNEL_REVISION.remove(channel, previous_revision, status, variant, current)
94+
CHANNEL_REVISION.remove(
95+
channel, previous_revision, status, variant, current
96+
)
8497
time.sleep(55)

0 commit comments

Comments
 (0)