-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into typed-definition-setup.py
- Loading branch information
Showing
10 changed files
with
135 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# used mainly to resolve local utility helpers like config.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import os | ||
import json | ||
|
||
|
||
class Config: | ||
def __init__(self): | ||
self.host = os.getenv('INFLUXDB_HOST') or 'https://us-east-1-1.aws.cloud2.influxdata.com/' | ||
self.token = os.getenv('INFLUXDB_TOKEN') or 'my-token' | ||
self.org = os.getenv('INFLUXDB_ORG') or 'my-org' | ||
self.database = os.getenv('INFLUXDB_DATABASE') or 'my-db' | ||
|
||
def __str__(self): | ||
return json.dumps(self.__dict__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Demonstrates handling response error headers on error. | ||
""" | ||
import logging | ||
from config import Config | ||
|
||
import influxdb_client_3 as InfluxDBClient3 | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Main function | ||
:return: | ||
""" | ||
config = Config() | ||
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO) | ||
|
||
client = InfluxDBClient3.InfluxDBClient3( | ||
host=config.host, | ||
token=config.token, | ||
org=config.org, | ||
database=config.database | ||
) | ||
|
||
# write with empty field results in HTTP 400 error | ||
# Other cases might be HTTP 503 or HTTP 429 too many requests | ||
lp = 'drone,location=harfa,id=A16E22 speed=18.7,alt=97.6,shutter=' | ||
|
||
try: | ||
client.write(lp) | ||
except InfluxDBClient3.InfluxDBError as idberr: | ||
logging.log(logging.ERROR, 'WRITE ERROR: %s (%s)', | ||
idberr.response.status, | ||
idberr.message) | ||
headers_string = 'Response Headers:\n' | ||
headers = idberr.getheaders() | ||
for h in headers: | ||
headers_string += f' {h}: {headers[h]}\n' | ||
logging.log(logging.INFO, headers_string) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters