Skip to content

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
kmille committed Feb 9, 2024
1 parent f10aa30 commit 0c89321
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
sudo poetry install
- name: Lint with flake8
run: |
sudo poetry run flake8 --ignore=E501 --show-source --statistics riseup_vpn_configurator
sudo poetry run flake8 --ignore=E501 --show-source --statistics
- name: Type check with mypy
run: |
sudo poetry run mypy riseup_vpn_configurator
Expand Down
8 changes: 4 additions & 4 deletions monitoring/monitor_riseupvpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def monitor_host(self):
state_succeed = {
'full_text': "VPN: OK",
'color': self.py3.COLOR_GOOD,
'cached_until': self.py3.time_in(seconds=2*60)
'cached_until': self.py3.time_in(seconds=2 * 60)
}

interfaces = netifaces.interfaces()
Expand All @@ -34,15 +34,15 @@ def monitor_host(self):
return state_fail

gw_ip, interface = netifaces.gateways()['default'][netifaces.AF_INET]
#self.py3.log(gw_ip, interface)
# self.py3.log(gw_ip, interface)
if interface != self.VPN_INTERFACE:
self.py3.log(f"Default gateway interface is not the VPN interface ({interface})")
return state_fail

try:
resp = ping(gw_ip, timeout=2,
resp = ping(gw_ip, timeout=2, # noqa: F841
count=1, privileged=False)
#self.py3.log(resp)
# self.py3.log(resp)
return state_succeed
except ICMPLibError as e:
self.py3.log(f"Ping failed: {e}")
Expand Down
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ poetry install

# run tests
# run by git hooks
poetry run flake8 --ignore=E501 --show-source --statistics riseup_vpn_configurator
poetry run flake8 --ignore=E501 --show-source --statistics
poetry run mypy riseup_vpn_configurator
sudo poetry run pytest -v -s tests

Expand Down
36 changes: 18 additions & 18 deletions riseup_vpn_configurator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ def get_rtt(ip: str) -> float:
return 9000.0


#def cache_api_ca_cert() -> None:
# logging.debug("Updating riseup.net API API CA certificate")
# logging.debug(f"Fetching riseup.net VPN metadata from {PROVIDER_API_URL}")
# try:
# resp = requests.get(PROVIDER_API_URL, verify=VERIFY_SSL_CERTIFICATE)
# resp.raise_for_status()
# j = resp.json()
# logging.debug(f"Fetching API CA certificate from {j['ca_cert_uri']}")
# resp = requests.get(j['ca_cert_uri'], verify=VERIFY_SSL_CERTIFICATE)
# resp.raise_for_status()
# api_ca_cert_file.write_text(resp.text)
# except (requests.RequestException, KeyError) as e:
# logging.error(e)
# sys.exit(1)
# fix_file_permissions(api_ca_cert_file)
# logging.info(f"Sucessfully cached API CA certificate to {api_ca_cert_file}")
# def cache_api_ca_cert() -> None:
# logging.debug("Updating riseup.net API API CA certificate")
# logging.debug(f"Fetching riseup.net VPN metadata from {PROVIDER_API_URL}")
# try:
# resp = requests.get(PROVIDER_API_URL, verify=VERIFY_SSL_CERTIFICATE)
# resp.raise_for_status()
# j = resp.json()
# logging.debug(f"Fetching API CA certificate from {j['ca_cert_uri']}")
# resp = requests.get(j['ca_cert_uri'], verify=VERIFY_SSL_CERTIFICATE)
# resp.raise_for_status()
# api_ca_cert_file.write_text(resp.text)
# except (requests.RequestException, KeyError) as e:
# logging.error(e)
# sys.exit(1)
# fix_file_permissions(api_ca_cert_file)
# logging.info(f"Sucessfully cached API CA certificate to {api_ca_cert_file}")


def update_gateways() -> None:
Expand Down Expand Up @@ -496,8 +496,8 @@ def main() -> None:
if args.no_check_certificate:
# deprecated
pass
#global VERIFY_SSL_CERTIFICATE
#VERIFY_SSL_CERTIFICATE = False
# global VERIFY_SSL_CERTIFICATE
# VERIFY_SSL_CERTIFICATE = False

elif args.version:
show_version()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_riseupvpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ def test_update_vpn_ca_certificate(self, caplog):
assert ca_cert_file.strip().endswith("-----END CERTIFICATE-----")

def test_update_vpn_client_credentials(self, caplog):
from riseup_vpn_configurator import update_vpn_client_credentials #, cache_api_ca_cert
from riseup_vpn_configurator import update_vpn_client_credentials # , cache_api_ca_cert
caplog.set_level(logging.INFO)

#cache_api_ca_cert()
# cache_api_ca_cert()
update_vpn_client_credentials()

# BEGIN CHECK CERT
Expand Down

0 comments on commit 0c89321

Please sign in to comment.