Skip to content

Commit 55d3ee5

Browse files
authored
Merge pull request #37 from DevoInc/release-next
Version 1.6.3 - Fixes in documentation, and codestyle
2 parents 2154e75 + 670d078 commit 55d3ee5

File tree

15 files changed

+83
-82
lines changed

15 files changed

+83
-82
lines changed

.travis.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ install:
88
script:
99
- python run_tests.py
1010
deploy:
11-
- provider: releases
12-
api_key:
13-
secure: "ON5p7zLOp8YlGxvv9+saMVChEdyJnPdlY0Cvm4MuiJU0t1hVlcnREsX/QuztQM/uAs2Tug8rkWKlhwbUNt0gOz/N0aA5JqojS8jGYrB0at9rOAPoWj+MMbKlj8YfPxfWJwHAffxurwhKzklb/ni4tc2SFV7D8uUC1BUbj+agETV93MHYUAPrMNEhFmXFExTsNQw/5Bww145mrzRu1Kctz9IR7UtCj8a2KCeiFVxk3kaSuvtYBMHRfaVgkbDtIV8rMzZYBzM9OAEDcOBRqBAp9sFSvVxnG6l630Lv0VoRhmH1mvnpw/BM7BxWn4t2QVYAkMrTC//w6C6VIOMonQI9RaD6xEqu44PyedOVwtTpFTP1S71vob+u05K5uCs14zNCd3O8fVIZtCi8x/7t82UCaV/iCISy3YZqeeNioN5EsPEY0wLekmWOZG8dY3CBgukWsNeEe9MsteOvrPaJ59yqmJDw1JFbd7BU64aEeHj82/e75wf0TvIpfydwJAWFQLF9yTcvK+i/YxEwrjkpoIJ8sQLE7wrnpa5MVtOzHMomG5eVHI9tagrV3thwHwtq0tVBRr38L4BC4AHYSMtbH8g6a7jdPJMoy99jm1pfvrMRSd6dacYAF7yEn2wNYmwScwovI4vdaZkVanSvIR94YYKeAMoJfu8CRRXQVa0zz3jDz9w="
14-
file: dist/devo_sdk-*.whl
15-
on:
16-
repo: DevoInc/python-sdk
17-
branch: master
1811
- provider: pypi
1912
user: worvast
2013
password:

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [1.6.3] - 2019-01-17
8+
#### Fixed
9+
* Broken urls in documentations
10+
11+
#### Changed
12+
* Inconsistences in api.base class
13+
* PEP8/Pylint styles in api and common packages
14+
715
## [1.6.2] - 2019-01-16
816
#### Added
917
* Documentation about API "destination" parameter

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[![master Build Status](https://travis-ci.com/DevoInc/python-sdk.svg?branch=master)](https://travis-ci.com/DevoInc/python-sdk) [![LICENSE](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/DevoInc/python-sdk/blob/master/LICENSE)
33

4-
[![wheel](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.org/project/devo-sdk/) [![version](https://img.shields.io/badge/version-1.6.2-blue.svg)](https://pypi.org/project/devo-sdk/) [![python](https://img.shields.io/badge/python-2.7%20%7C%203.3%20%7C%203.4%20%7C%203.5%20%7C%203.6%20%7C%203.7-blue.svg)](https://pypi.org/project/devo-sdk/)
4+
[![wheel](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.org/project/devo-sdk/) [![version](https://img.shields.io/badge/version-1.6.3-blue.svg)](https://pypi.org/project/devo-sdk/) [![python](https://img.shields.io/badge/python-2.7%20%7C%203.3%20%7C%203.4%20%7C%203.5%20%7C%203.6%20%7C%203.7-blue.svg)](https://pypi.org/project/devo-sdk/)
55

66

77
# Devo Python SDK
@@ -42,9 +42,16 @@ You can use sources files, clonning the project too:
4242
### Documentation
4343

4444
You has specific documentation in _[docs](docs)_ folder for each part of SDK:
45-
* [Api Query](docs/api.md)
4645
* [Sender](docs/sender.md)
4746
* [Common](docs/common.md)
47+
* API:
48+
* [Api query](docs/api/api.md)
49+
* [Api tasks management](docs/api/task.md)
50+
* [Destination: email](docs/api/destination_email.md)
51+
* [Destination: redis](docs/api/destination_redis.md)
52+
* [Destination: S3](docs/api/destination_s3.md)
53+
54+
4855

4956

5057
## Contributing
@@ -57,18 +64,18 @@ To send data with Devo SDK, first choose the required endpoint depending on the
5764
* **USA:** us.elb.relay.logtrust.net:443
5865
* **EU:** eu.elb.relay.logtrust.net:443
5966

60-
You has more info in [Relays article](https://docs.devo.com/confluence/docs/system-configuration/relays).
67+
You have more information in the official documentation of Devo, [Sending data to Devo](https://docs.devo.com/confluence/ndt/sending-data-to-devo).
6168

6269
##### API
6370
To perform a request with API, first choose the required endpoint depending on the region your are accessing from:
6471
* **USA:** https://api-us.logtrust.com/search/query
6572
* **EU:** https://api-eu.logtrust.com/search/query
6673

67-
You has more info in [REST API article](https://docs.devo.com/confluence/docs/api/rest-api-v2) .
74+
You have more information in the official documentation of Devo, [REST API v2](https://docs.devo.com/confluence/ndt/api-reference/rest-api-v2) .
6875

6976
## Credentials
7077
To obtain the access credentials necessary to use this SDK, you must have an account in [DEVO](https://www.devo.com/).<br/>
71-
Check the [Credentials article](https://docs.devo.com/confluence/docs/administration/administration-credentials) for more details.
78+
Check the [security credentials](https://docs.devo.com/confluence/ndt/domain-administration/security-credentials) info for more details.
7279

7380
##### Certificates
7481
You need use a three files (Cert, key and chain) to secure send data to Devo.

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__ = "1.6.2"
3+
__version__ = "1.6.3"
44
__author__ = 'Devo'
55
__author_email__ = 'support@devo.com'
66
__license__ = 'MIT'

devo/api/base.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def __init__(self, *args, **kwargs):
7272
self.retries = 3
7373
self.timeout = 30
7474
self.sleep = 5
75+
self.buffer = None
7576

7677
def __set_url_query(self):
7778
"""
@@ -92,30 +93,15 @@ def __get_url_parts(self):
9293
self.url.split("//")[-1].split("/", maxsplit=1) if PY3
9394
else self.url.split("//")[-1].split("/", 1))
9495

95-
def __verify_url_complement(self, url_list):
96+
@staticmethod
97+
def __verify_url_complement(url_list):
9698
"""
9799
Verify if only has main domain or full url
98100
:param url_list: One or two part of the url
99101
"""
100102
return url_list if len(url_list) == 2 \
101103
else [url_list[0], URL_QUERY_COMPLEMENT]
102104

103-
def _generate_pragmas(self, comment=None):
104-
"""
105-
Generate pragmas to add to query
106-
:comment: Pragma comment free
107-
:user: Pragma comment user
108-
:app_name: Pragma comment id. App name.
109-
"""
110-
str_pragmas = ' pragma comment.id:"{}" ' \
111-
'pragma comment.user:"{}"'\
112-
.format(self.app_name, self.user)
113-
114-
if comment:
115-
return str_pragmas + ' pragma comment.free:"{}"'.format(comment)
116-
117-
return str_pragmas
118-
119105
@staticmethod
120106
def _generate_dates(dates):
121107
"""
@@ -186,10 +172,3 @@ def close(self):
186172
if self.socket is not None:
187173
self.socket.close()
188174
self.socket = None
189-
190-
def _get_job_url_part(self):
191-
URL_JOB = '/search/job'
192-
URL_JOBS = '/search/jobs'
193-
URL_JOB_START = '/start/'
194-
URL_JOB_STOP = '/start/'
195-
URL_JOB_REMOVE = '/start/'

devo/api/client.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import hashlib
55
import time
66
import json
7-
import requests
87
from socket import timeout as socket_timeout
8+
import requests
99
from devo.common import Buffer, default_from, default_to
1010
from .base import Base, DevoClientException, CLIENT_DEFAULT_USER, \
1111
CLIENT_DEFAULT_APP_NAME, URL_JOB, URL_JOBS, URL_JOB_START, URL_JOB_STOP, \
@@ -151,7 +151,7 @@ def _call_stream(self, payload=None):
151151
while not self.buffer.is_empty() or self.buffer.close:
152152
time.sleep(1)
153153
else:
154-
raise DevoClientException("Devo-Client|%s" % str(data))
154+
self.buffer.close = True
155155

156156
@staticmethod
157157
def _get_payload(query, query_id, dates, opts):
@@ -275,6 +275,22 @@ def _get_sign(self, data, tstamp):
275275
hashlib.sha256)
276276
return sign.hexdigest()
277277

278+
def _generate_pragmas(self, comment=None):
279+
"""
280+
Generate pragmas to add to query
281+
:comment: Pragma comment free
282+
:user: Pragma comment user
283+
:app_name: Pragma comment id. App name.
284+
"""
285+
str_pragmas = ' pragma comment.id:"{}" ' \
286+
'pragma comment.user:"{}"'\
287+
.format(self.app_name, self.user)
288+
289+
if comment:
290+
return str_pragmas + ' pragma comment.free:"{}"'.format(comment)
291+
292+
return str_pragmas
293+
278294
def _call_jobs(self, url):
279295
"""
280296
Make the call
@@ -349,4 +365,3 @@ def remove_job(self, job_id):
349365
:return: bool"""
350366
return self._call_jobs("{}{}{}{}".format(self.url, URL_JOB,
351367
URL_JOB_REMOVE, job_id))
352-

devo/common/data/buffer.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
class DevoBufferException(Exception):
1414
""" Default Devo Client Exception """
15-
pass
1615

1716

1817
def clrf():
@@ -23,17 +22,16 @@ def clrf():
2322
def get_response_split(api_response):
2423
"""Get split for each event, if csv or other, and in bytes or str"""
2524
if version_info[0] > 2:
26-
return b"\n" if api_response is "csv" else b"\r\n"
27-
else:
28-
return "\n" if api_response is "csv" else "\r\n"
25+
return b"\n" if api_response == "csv" else b"\r\n"
26+
return "\n" if api_response == "csv" else "\r\n"
2927

3028

3129
def empty():
3230
"""Empty string in bytes or str if py2 or py3"""
3331
return bytes() if version_info[0] > 2 else str()
3432

3533

36-
class Buffer(object):
34+
class Buffer:
3735
""" Simple Buffer class """
3836
def __init__(self, buffer_max_size=1000, api_response="json/compact"):
3937
self.queue = Queue.Queue(maxsize=buffer_max_size)
@@ -49,13 +47,16 @@ def __init__(self, buffer_max_size=1000, api_response="json/compact"):
4947
self.api_response = api_response
5048

5149
def is_alive(self):
50+
"""Revise is buffer is alive"""
5251
return self.thread.isAlive()
5352

5453
def set_timeout(self, timeout):
54+
"""Set timeout for socket call"""
5555
self.timeout = timeout
5656

5757
def is_empty(self):
58-
return False if self.size() > 0 else True
58+
"""Revise is buffer queue is empty"""
59+
return True if self.size() else False
5960

6061
def create_thread(self, target, kwargs):
6162
""" Function for create one separate thread for Queue"""
@@ -85,17 +86,18 @@ def process_first_line(self, data):
8586
""" process first line of the Query call (For delete headers) """
8687

8788
if version_info[0] > 2:
88-
ok = b"200 OK"
89+
response_ok = b"200 OK"
8990
else:
90-
ok = "200 OK"
91+
response_ok = "200 OK"
9192

92-
if ok in data.split(self.clrf+self.clrf)[0]:
93+
if response_ok in data.split(self.clrf+self.clrf)[0]:
9394
return self.buffering(data[data.find(self.clrf+self.clrf)+4:]), None
9495

9596
self.error = data
9697
return False, data
9798

9899
def buffering(self, data):
100+
"""Saving temp date from system IO, waiting for all octet response"""
99101
if not self.octet:
100102
pointer = data.find(self.clrf) + 2
101103
size = int(data[:pointer], 16)
@@ -122,8 +124,8 @@ def process_recv(self, data):
122124
if data[-(len(self.response_split)):] != self.response_split:
123125
self.temp_event = data_list.pop()
124126

125-
for aux in range(0, len(data_list)):
126-
self.queue.put(data_list[aux].strip(), block=True)
127+
for item in data_list:
128+
self.queue.put(item.strip(), block=True)
127129

128130
self.octet = 0
129131
if len(self.temp.strip()):

devo/common/data/chain_dict.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def set_key(self, key_list, value):
1414
if not isinstance(key_list, list):
1515
key_list = [key_list]
1616
self.set_key_chain(self, key_list, value)
17-
return
1817

1918
@staticmethod
2019
def set_key_chain(cdict, key_list, value):
@@ -30,6 +29,6 @@ def set_key_chain(cdict, key_list, value):
3029
cdict[key_list[0]] = value
3130
else:
3231
cdict[key_list[0]] = ChainDict.set_key_chain(dict(),
33-
key_list[1:],
34-
value)
32+
key_list[1:],
33+
value)
3534
return cdict

devo/common/dates/dateoperations.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
# -*- coding: utf-8 -*-
2-
"""Utils for date operations."""
2+
"""A collection of allowed operations on date parsing"""
33
from datetime import datetime as dt, timedelta
44
from .dateutils import to_millis, trunc_time, trunc_time_minute
55

66

7-
"""
8-
This class is a collection of allowed operations on date parsing
9-
"""
10-
11-
127
def month():
138
"""
149
Return millis for a month
@@ -90,6 +85,7 @@ def yesterday():
9085

9186

9287
def parse_functions():
88+
"""Return object with all functions availables"""
9389
return {
9490
"month": month,
9591
"week": week,
@@ -101,4 +97,4 @@ def parse_functions():
10197
"now_without_ms": now_without_ms,
10298
"today": today,
10399
"yesterday": yesterday
104-
}
100+
}

devo/common/dates/dateparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def parse_string(date_string):
3232
if test_date_format(date_string, '%Y-%m-%d %H:%M:%S'):
3333
date = dt.strptime(date_string, '%Y-%m-%d %H:%M:%S')
3434
return to_millis(date)
35-
elif test_date_format(date_string, '%Y-%m-%d'):
35+
if test_date_format(date_string, '%Y-%m-%d'):
3636
date = dt.strptime(date_string, '%Y-%m-%d')
3737
return to_millis(trunc_time(date))
3838
return parse_expression(date_string)

0 commit comments

Comments
 (0)