Skip to content

Commit

Permalink
small fixups for Python 3.7 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
rtertiaer committed Dec 4, 2024
1 parent 39d513d commit 7c9448c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions admin/cloud.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from os import getenv
from typing import List
from ipaddress import IPv4Address

from pydantic import UUID4
Expand Down Expand Up @@ -34,7 +35,7 @@ def get_ts_instance(tunnel_id: UUID4) -> compute_v1.Instance:
instance_client = compute_v1.InstancesClient()
return instance_client.get(project=PROJECT_ID, zone=ZONE, instance=f"{INSTANCE_NAME_PREFIX}-{tunnel_id}")

def list_ts_instances() -> list[compute_v1.Instance]:
def list_ts_instances() -> List[compute_v1.Instance]:
""" Lists tunnel server instances. At present, it just uses the
INSTANCE_NAME_PREFIX to determine if it is a tunnel server.
"""
Expand All @@ -53,7 +54,7 @@ def _create_ts_boot_disk() -> compute_v1.AttachedDisk:
disk.boot = True
return disk

def _create_ts_network_interfaces() -> list[compute_v1.NetworkInterface]:
def _create_ts_network_interfaces() -> List[compute_v1.NetworkInterface]:
""" create a list of network interface descriptions """
# create network interface & external access configs
netiface = compute_v1.NetworkInterface()
Expand Down
3 changes: 2 additions & 1 deletion api/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def get_tunnel_id(token: str = Depends(oauth2_scheme)) -> UUID:
try:
payload = TunnelRequestTokenData(
**jwt.decode(token, JWT_SECRET, algorithms=[JWT_ALGO]))
tunnel_id_str = payload.sub.removeprefix("tunnel_id:")
prefix_len = len("tunnel_id:")
tunnel_id_str = payload.sub[prefix_len:]
logging.debug(f"tunnel_id_str: {tunnel_id_str}")
tunnel_id = UUID(hex=tunnel_id_str)
except JWTError:
Expand Down

0 comments on commit 7c9448c

Please sign in to comment.