Skip to content

Commit

Permalink
Merge pull request #498 from jfly/add-ruff-checking
Browse files Browse the repository at this point in the history
Add `ruff-check`
  • Loading branch information
Mic92 authored Oct 30, 2024
2 parents e8b4196 + 09914a3 commit fb5e9ae
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
6 changes: 2 additions & 4 deletions build/datadog/hydra.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#! /usr/bin/env python
from checks import *
import os
import subprocess
import checks
import requests
import json


class HydraCheck(AgentCheck):
class HydraCheck(checks.AgentCheck):
def check(self, instance):
r = requests.get(
"http://localhost:3000/status", headers={"Content-Type": "application/json"}
Expand Down
2 changes: 1 addition & 1 deletion build/pluto/prometheus/exporters/channel-exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import requests
from dateutil.parser import parse
from prometheus_client import Counter, Histogram, Gauge, start_http_server, REGISTRY
from prometheus_client import Counter, Histogram, Gauge, start_http_server
import time
import sys
import logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import requests
import json
from prometheus_client.core import GaugeMetricFamily, CounterMetricFamily
from prometheus_client import CollectorRegistry, generate_latest, start_http_server
from pprint import pprint
from prometheus_client import CollectorRegistry, start_http_server
import time


Expand All @@ -21,7 +20,7 @@ def __init__(self, state):
def preserving_read(self, key):
val = self._state[key]

if type(val) is dict:
if isinstance(val, dict):
return EvaporatingDict(val)
else:
return val
Expand Down
1 change: 1 addition & 0 deletions formatter/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
programs.nixfmt.enable = true;
programs.nixfmt.package = pkgs.nixfmt-rfc-style;
programs.ruff-format.enable = true;
programs.ruff-check.enable = true;

programs.shellcheck.enable = true;

Expand Down
14 changes: 6 additions & 8 deletions hydra-packet-importer/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import json
import packet # type: ignore
import base64
from pprint import pprint
import subprocess
import sys
from typing import Union, Dict, Any, List, Optional
from typing import Dict, Any, List, Optional
from typing import TypedDict

DeviceKeys = List[Dict[str, Any]]
Expand Down Expand Up @@ -103,7 +101,7 @@ def get_remote_builder_info(manager, device_id: str) -> Optional[RemoteBuilder]:
events_url = "devices/{}/events?per_page=50".format(device_id)
debug(events_url)
data = manager.call_api(events_url)
except:
except Exception:
# 404 probably
return None

Expand All @@ -122,17 +120,17 @@ def get_remote_builder_info(manager, device_id: str) -> Optional[RemoteBuilder]:
# If we receive a LOT of spam (> 50 spams!) like that, we
# will return None because we never reach this message.
if host_key is not None:
key = strip_ssh_key_comment(host_key["key"])
if key is not None and metadata is not None:
return {"metadata": metadata, "ssh_key": key}
ssh_key = strip_ssh_key_comment(host_key["key"])
if ssh_key is not None and metadata is not None:
return {"metadata": metadata, "ssh_key": ssh_key}
return None
if event["type"] == "user.1001":
try:
host_keys: List[HostKey] = [
key for key in json.loads(event["body"]) if key["port"] == 22
]
host_key = host_keys[0]
except:
except Exception:
pass
if event["type"] == "user.1002":
metadata = json.loads(event["body"])
Expand Down

0 comments on commit fb5e9ae

Please sign in to comment.