Skip to content

Commit 25a56f6

Browse files
authored
Merge pull request #292 from DevoInc/python12support
Version 6.0.0 merge request
2 parents eecbf7d + 00cadec commit 25a56f6

24 files changed

+219
-150
lines changed

.github/workflows/python-prereleased.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Python
2626
uses: actions/setup-python@v3
2727
with:
28-
python-version: "3.9"
28+
python-version: "3.12"
2929
- name: Install dependencies
3030
run: |
3131
python -m pip install --upgrade pip

.github/workflows/python-pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
max-parallel: 1
2929
matrix:
30-
version: ["3.8", "3.9"]
30+
version: [ "3.12", "3.11", "3.10", "3.9" ]
3131
runs-on: ubuntu-latest
3232
steps:
3333
- uses: actions/checkout@v4
@@ -61,4 +61,4 @@ jobs:
6161
export DEVO_SENDER_CHAIN=$(realpath certs/us/ca.crt)
6262
export TMPDIR=${PWD}
6363
cd tests
64-
python -m pytest
64+
python -m pytest -vvv

.github/workflows/python-released.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Python
2626
uses: actions/setup-python@v3
2727
with:
28-
python-version: "3.9"
28+
python-version: "3.12"
2929
- name: Install dependencies
3030
run: |
3131
python -m pip install --upgrade pip

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [6.0.0] - 2024-10-07
8+
9+
### Changed
10+
- Supported Python versions extended to 10, 11 and 12
11+
- Added time zones in date operations
12+
- Jobs API reviewed and fixed. Jobs searching by type and friendlyName discontinued as it is not supported by API.
13+
Jobs API unit test checked and enabled
14+
- Added timeout to unit tests of API queries. They may run forever when faulty
15+
16+
### Fixed
17+
- Keep-alive mechanism not working for queries with `destination`. Forcing NO_KEEP_ALIVE in queries with
18+
`destination`.
19+
- SSL wrapping of the TCP connection when no certificates are used improved
20+
- Fix auxiliary Echo serving for unit testing in order to run with new async paradigm
21+
- Documentation fixes. Some parameters missing or non-existent in docstring
22+
- Fix for a unit test when using concurrency (from library `stopit` to `pebble`)
23+
24+
### Removed
25+
- Python 3.8 support discontinued
26+
27+
### Incompatibilities with 5.x.x that caused mayor version bump
28+
- Python 3.8 not supported anymore
29+
- Jobs searching by type and friendlyName discontinued in Jobs API. Only search by job id is supported.
30+
- Date requires time zone
31+
- Query with `destination` are forced to NO_KEEP_ALIVE mode for Keep-alive mechanism (instead of
32+
DEFAULT_KEEPALIVE_TOKEN)
33+
734
## [5.4.1] - 2024-09-13
835

936
### Security

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ This is the SDK to access Devo directly from Python. It can be used to:
1414

1515
## Requirements
1616

17-
The Devo SDK for Python requires Python 3.8+
17+
The Devo SDK for Python requires Python 3.9+
1818

1919
## Compatibility
2020

21-
- Tested compatibility for python 3.8 and 3.9
21+
- Tested compatibility for python 3.9, 3.10, 3.11 and 3.12
2222

2323
## Quick Start
2424

devo/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__description__ = "Devo Python Library."
22
__url__ = "http://www.devo.com"
3-
__version__ = "5.4.1"
3+
__version__ = "6.0.0"
44
__author__ = "Devo"
55
__author_email__ = "support@devo.com"
66
__license__ = "MIT"

devo/api/client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
"connection_error": "Failed to establish a new connection",
5656
"other_errors": "Error while invoking query",
5757
"error_no_detail": "Error code %d while invoking query",
58+
"no_keepalive_for_destination": "Queries with destination functionality only support No Keepalive mode. Forced to"
59+
" NO_KEEP_ALIVE"
5860
}
5961

6062
DEFAULT_KEEPALIVE_TOKEN = "\n"
@@ -173,6 +175,7 @@ def __init__(
173175
self.processor = None
174176
self.set_processor(processor)
175177
self.keepAliveToken = None
178+
176179
self.set_keepalive_token(keepAliveToken)
177180

178181
if pragmas:
@@ -235,7 +238,12 @@ def set_keepalive_token(self, keepAliveToken=DEFAULT_KEEPALIVE_TOKEN):
235238
# keepalive (cannot be modified), but implementation uses
236239
# NO_KEEP_ALIVE value as it does not change the query msgpack and
237240
# xls does not support keepalive
238-
if self.response in [
241+
# Queries with destination only supports NO_KEEP_ALIVE
242+
if self.destination is not None:
243+
self.keepAliveToken = NO_KEEPALIVE_TOKEN
244+
if keepAliveToken not in [NO_KEEPALIVE_TOKEN, DEFAULT_KEEPALIVE_TOKEN]:
245+
logging.warning(ERROR_MSGS["no_keepalive_for_destination"])
246+
elif self.response in [
239247
"json",
240248
"json/compact",
241249
"json/simple",
@@ -254,7 +262,6 @@ def set_keepalive_token(self, keepAliveToken=DEFAULT_KEEPALIVE_TOKEN):
254262
self.keepAliveToken = NO_KEEPALIVE_TOKEN
255263
return True
256264

257-
258265
class Client:
259266
"""
260267
The Devo search rest api main class
@@ -441,6 +448,7 @@ def query(
441448
:param limit: Max number of rows
442449
:param offset: start of needle for query
443450
:param comment: comment for query
451+
:param ip_as_string: whether to recive IP types as strings
444452
:return: Result of the query (dict) or Iterator object
445453
"""
446454
dates = self._generate_dates(dates)
@@ -755,18 +763,10 @@ def _generate_pragmas(self, comment=None):
755763

756764
return str_pragmas
757765

758-
def get_jobs(self, job_type=None, name=None):
766+
def get_jobs(self):
759767
"""Get list of jobs by type and name, default All
760-
:param job_type: category of jobs
761-
:param name: name of jobs
762768
:return: json"""
763-
plus = (
764-
""
765-
if not job_type
766-
else "/{}".format(job_type if not name else "{}/{}".format(job_type, name))
767-
)
768-
769-
return self._call_jobs("{}{}{}".format(self.address[0], "/search/jobs", plus))
769+
return self._call_jobs("{}{}".format(self.address[0], "/search/jobs"))
770770

771771
def get_job(self, job_id):
772772
"""Get all info of job

devo/api/scripts/client_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def configure(args):
161161
"""
162162
Load CLI configuration
163163
:param args: args from files, launch vars, etc
164-
:return: Clien t API Object and Config values in array
164+
:return: Client API Object and Config values in array
165165
"""
166166
config = Configuration()
167167
try:

devo/common/dates/dateoperations.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"""A collection of allowed operations on date parsing"""
33

44
from datetime import datetime as dt
5+
import zoneinfo
6+
UTC = zoneinfo.ZoneInfo("UTC")
7+
58
from datetime import timedelta
69

710
from .dateutils import to_millis, trunc_time, trunc_time_minute
@@ -60,31 +63,31 @@ def now():
6063
Return current millis in UTC
6164
:return: Millis
6265
"""
63-
return to_millis(dt.utcnow())
66+
return to_millis(dt.now(UTC))
6467

6568

6669
def now_without_ms():
6770
"""
6871
Return current millis in UTC
6972
:return: Millis
7073
"""
71-
return to_millis(trunc_time_minute(dt.utcnow()))
74+
return to_millis(trunc_time_minute(dt.now(UTC)))
7275

7376

7477
def today():
7578
"""
7679
Return current millis with the time truncated to 00:00:00
7780
:return: Millis
7881
"""
79-
return to_millis(trunc_time(dt.utcnow()))
82+
return to_millis(trunc_time(dt.now(UTC)))
8083

8184

8285
def yesterday():
8386
"""
8487
Return millis from yesterday with time truncated to 00:00:00
8588
:return: Millis
8689
"""
87-
return to_millis(trunc_time(dt.utcnow()) - timedelta(days=1))
90+
return to_millis(trunc_time(dt.now(UTC)) - timedelta(days=1))
8891

8992

9093
def parse_functions():

devo/common/dates/dateutils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"""Utils for format and trunc dates."""
33

44
from datetime import datetime as dt
5+
import zoneinfo
6+
UTC = zoneinfo.ZoneInfo("UTC")
57

68

79
def to_millis(date):
@@ -10,7 +12,10 @@ def to_millis(date):
1012
:param date: Date for parse to millis
1113
:return: Millis from the date
1214
"""
13-
return int((date - dt.utcfromtimestamp(0)).total_seconds() * 1000)
15+
# Verify whether param has timezone, if not set the default UTC one
16+
if date.tzinfo is None:
17+
date = date.replace(tzinfo=UTC)
18+
return int((date - dt.fromtimestamp(0, UTC)).total_seconds() * 1000)
1419

1520

1621
def trunc_time(date):
@@ -50,4 +55,4 @@ def get_timestamp():
5055
Generate current timestamp
5156
:return:
5257
"""
53-
return to_millis(dt.utcnow())
58+
return to_millis(dt.now(UTC))

0 commit comments

Comments
 (0)