Skip to content

Commit 433c6d5

Browse files
committed
add the satnogs DB api key usage
1 parent 326c5f4 commit 433c6d5

File tree

7 files changed

+15
-3
lines changed

7 files changed

+15
-3
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ Here is an example of how to use the glouton Pypi package :
5151

5252
Usage :
5353
-------
54+
55+
If you plan to download data from satnogs DB, you will have to register yourself on [https://db.satnogs.org](https://db.satnogs.org) in order to get an API key.
56+
Than you can add this key to the config file of glouton (/glouton/config.json)
57+
5458
Examples for downloading data from the satnogs network
5559

5660
simple command example for downloading :

glouton/config.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"DEFAULT": {
33
"NETWORK_API_URL": "https://network.satnogs.org/api/",
44
"DB_API_URL": "https://db.satnogs.org/api/",
5+
"DB_API_KEY": "",
56
"HTTPS_PROXY": "",
67
"HTTP_PROXY": ""
78
},

glouton/infrastructure/satnogClient.py

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class SatnogClient:
77
def __init__(self):
88
self.config = config.read()
99
self.proxies = self._set_proxy()
10+
self.header = self._get_authorization_header()
1011

1112
def _set_proxy(self):
1213
proxies = None
@@ -24,6 +25,10 @@ def _set_proxy(self):
2425

2526
return proxies
2627

28+
def _get_authorization_header(self):
29+
token = self.config['DEFAULT']['DB_API_KEY']
30+
return {'Authorization': 'Token ' + token}
31+
2732
def get(self, url, params=None):
2833
raise NotImplementedError()
2934

glouton/infrastructure/satnogDbClient.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self):
99
self._url = self.config['DEFAULT']['DB_API_URL']
1010

1111
def get(self, url, params=None):
12-
return requests.get(url, params=params, proxies=self.proxies)
12+
return requests.get(url, params=params, proxies=self.proxies, headers=self.header)
1313

1414
def get_from_base(self, url, params=None):
15-
return requests.get(self._url + url, params=params, proxies=self.proxies)
15+
return requests.get(self._url + url, params=params, proxies=self.proxies, headers=self.header)

glouton/shared/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def read():
99
"DEFAULT": {
1010
"NETWORK_API_URL": "https://network.satnogs.org/api/",
1111
"DB_API_URL": "https://db.satnogs.org/api/",
12+
"DB_API_KEY": "",
1213
"HTTPS_PROXY": "",
1314
"HTTP_PROXY": ""
1415
},

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
long_description = f.read()
1414

1515
setup(
16-
version="0.6.0",
16+
version="0.7.0",
1717
name="glouton",
1818
description="`Glouton is a cli program which helps you downloading satnogs data`",
1919
url="https://github.com/deckbsd/glouton-satnogs-data-downloader.git",

test/test_configuration.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"DEFAULT": {
66
"NETWORK_API_URL": "https://network.satnogs.org/api/",
77
"DB_API_URL": "https://db.satnogs.org/api/",
8+
"DB_API_KEY": "",
89
"HTTPS_PROXY": "",
910
"HTTP_PROXY": ""
1011
},

0 commit comments

Comments
 (0)