Skip to content

Commit e2d7c85

Browse files
committed
Using urljoin and fixing comments
1 parent 6683a8b commit e2d7c85

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

cosmo/clients/netbox.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import time
2+
from urllib.parse import urljoin
23

34
import requests
45

@@ -21,7 +22,7 @@ def __init__(self, url, token):
2122

2223
def query_version(self):
2324
r = requests.get(
24-
f"{self.url}/api/status/",
25+
urljoin(self.url, "/api/status/"),
2526
headers={
2627
"Authorization": f"Token {self.token}",
2728
"Content-Type": "application/json",

cosmo/clients/netbox_client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from urllib.parse import urlencode
1+
from urllib.parse import urlencode, urljoin
22

33
import requests
44

@@ -10,7 +10,7 @@ def __init__(self, url, token):
1010

1111
def query(self, query):
1212
r = requests.post(
13-
f"{self.url}/graphql/",
13+
urljoin(self.url, "/graphql/"),
1414
json={"query": query},
1515
headers={
1616
"Authorization": f"Token {self.token}",
@@ -31,7 +31,7 @@ def query(self, query):
3131

3232
def query_rest(self, path, queries):
3333
q = urlencode(queries, doseq=True)
34-
url = f"{self.url}/{path}?{q}"
34+
url = urljoin(self.url, path) + f"?{q}",
3535

3636
return_array = list()
3737

cosmo/clients/netbox_v4.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def _merge_into(self, data: dict, query_data):
7878

7979
class LoopbackDataQuery(ParallelQuery):
8080
def _fetch_data(self, kwargs):
81-
# Note: This does not use the device list, because we can have other devices, which are not
81+
# Note: This does not use the device list, because we can have other participating devices
82+
# which are not in the same repository and thus are not appearing in device list.
83+
8284
query_template = Template('''
8385
query{
8486
interface_list(filters: {

0 commit comments

Comments
 (0)