Skip to content

Commit

Permalink
Release 0.92.11 (#87)
Browse files Browse the repository at this point in the history
* Syncing master with develop

Signed-off-by: Christian Tremblay <christian.tremblay@servisys.com>

* Quick fix to look for exception in scram login

* cleanup / fix setup.py, and add license (#69)

`re` and `requests` weren't used in this file, and weren't declared in
`setup_requires` causing some build issues. Removed these imports.

Removed mixed tabs & spaces.

Explicitly added the Apache License to list of Classifiers so this
project can be identified as Apache Licensed at pypi.org. This matches
the license file.

* Synchronise VRT's Pyhaystack tree (#71)

* WC-847: client.widesky: Expect to see 404 messages.

* WC-847: client.ops.entity: Handle "not found" errors.

If we get back a `HaystackError` of the form `HNotFoundError: …`, then
the entity does not exist.

* WC-847: client.mixins.vendor.widesky.crud: Handle 200/400/404 error codes.

- 200: the "happy path"
- 400: bad request
- 404: not found

* WC-621: client.ops.his: Handle rng=slice object case.

MeterMaster passes in a `slice` object with two `datetime.datetime`
objects when it wishes to do a read operation.  It seems this construct
causes some grief with `pyhaystack` and `hszinc` which shouldn't be an
issue.

This fixes the issue by converting the slice object into a
comma-separated string: standard Project Haystack format.

* WC-1534: fix for creating entity without specifing 'id' tag

* WC-1534: add api server version check for uuid support

* VRT-1681: mkdeb.sh: Add Debian package build script.

* VRT-1681: Drop out-of-date Debian package files.

The script `mkdeb.sh` just needs `stdeb` and should remain up-to-date.

* WC-847: client.session: Wrap low-level function calls

This lets a subclass easily insert options into the `_get` or `_post`
request passed to the HTTP client, e.g. to expect certain HTTP error
codes.

* VRT-1681: client.widesky: Clean up duplication from merge.

* Added a helper function to translate niagara ~2d, etc characters and make more readable strings

* Run black over the files.

* Update the company name of Widesky IoT platform (#78)

* cleanup / fix setup.py, and add license

`re` and `requests` weren't used in this file, and weren't declared in
`setup_requires` causing some build issues. Removed these imports.

Removed mixed tabs & spaces.

Explicitly added the Apache License to list of Classifiers so this
project can be identified as Apache Licensed at pypi.org. This matches
the license file.

* Update the company name of Widesky IoT platform

As of July 2019 Widesky.cloud is now the company responsible for developing Widesky.

* Added forgotten file

* Modification in his.py to cover nan in series. Better implementation for JSON by default for Niagara4

* Added notice that Niagara4 works better with JSON

* Issue 82: client.ops.grid: Clean up whitespace.

* Issue 82: client.ops.grid: Remove check on raw_request.

Regardless of something being a raw request or not, we should still be
setting the `Accept` header accordingly.  Can't recall why this check
was done and can't see a good reason for doing it, so out it goes.

* simplifying grid_format parameter (#81)

* Preparing to release 0.92.11

Co-authored-by: Stuart Longland <stuartl@vrt.com.au>
Co-authored-by: Samuel <samuelt@vrt.com.au>
Co-authored-by: Eduardo S. Klein <duduklein@gmail.com>
  • Loading branch information
4 people authored Jun 17, 2020
1 parent ea6177c commit fd1cfca
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/source/connect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ arguments, so all should be usable.

* ``grid_format``: This selects the grid serialisation format for the Project
Haystack server. Some (e.g. nHaystack/Niagara AX) only support ZINC
serialisation, where as others (such as WideSky) work better with JSON.
serialisation, where as others (such as WideSky and Niagara4) work better with JSON.
Most of the time, the default here will be selected appropriate for the
underlying server implementation. Valid values are ``zinc`` and ``json``.

Expand Down
6 changes: 3 additions & 3 deletions pyhaystack/client/niagara.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ class Niagara4HaystackSession(HaystackSession, BQLMixin, EncodingMixin):
_AUTH_OPERATION = Niagara4ScramAuthenticateOperation
_BQL_OPERATION = BQLOperation

def __init__(self, uri, username, password, **kwargs):
def __init__(self, uri, username, password, grid_format=hszinc.MODE_JSON, **kwargs):
"""
Initialise a Nagara 4 Project Haystack session handler.
:param uri: Base URI for the Haystack installation.
:param username: Authentication user name.
:param password: Authentication password.
:param grid_format: the grid format to use in series (json, zinc)
"""

super(Niagara4HaystackSession, self).__init__(
uri, "haystack", grid_format=hszinc.MODE_JSON, **kwargs
uri, "haystack", grid_format=grid_format, **kwargs
)
self._username = username
self._password = password
Expand Down
21 changes: 10 additions & 11 deletions pyhaystack/client/ops/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BaseAuthOperation(state.HaystackOperation):
def __init__(self, session, uri, retries=2, cache=False):
"""
Initialise a request for the authenticating with the given URI and arguments.
It also contains the state machine for reconnection if needed.
:param session: Haystack HTTP session object.
Expand Down Expand Up @@ -215,16 +215,15 @@ def __init__(
cache_key = uri
self._cache_key = cache_key

if not raw_response:
if expect_format == hszinc.MODE_ZINC:
self._headers[b"Accept"] = "text/zinc"
elif expect_format == hszinc.MODE_JSON:
self._headers[b"Accept"] = "application/json"
elif expect_format is not None:
raise ValueError(
"expect_format must be one onf hszinc.MODE_ZINC "
"or hszinc.MODE_JSON"
)
if expect_format == hszinc.MODE_ZINC:
self._headers[b"Accept"] = "text/zinc"
elif expect_format == hszinc.MODE_JSON:
self._headers[b"Accept"] = "application/json"
elif expect_format is not None:
raise ValueError(
"expect_format must be one onf hszinc.MODE_ZINC "
"or hszinc.MODE_JSON"
)

def _do_check_cache(self, event):
"""
Expand Down
18 changes: 14 additions & 4 deletions pyhaystack/client/ops/his.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,28 @@ def _on_read(self, operation, **kwargs):
# Convert grid to list of tuples
data = [(conv_ts(row["ts"]), row["val"]) for row in grid]

units = ""
values = []
if self._series_format == self.FORMAT_DICT:
data = dict(data)
elif self._series_format == self.FORMAT_SERIES:
# Split into index and data.
try:
(index, data) = zip(*data)
if isinstance(data[0], hszinc.Quantity):
values = [each.value for each in data]
units = data[0].unit
if isinstance(data[0], hszinc.Quantity) or isinstance(
data[-1], hszinc.Quantity
):
for each in data:
try:
values.append(each.value)
if units == "":
units = each.unit
except AttributeError:
if isinstance(each, float):
values.append(each)
continue
else:
values = data
units = ""
except ValueError:
values = []
index = []
Expand Down
2 changes: 1 addition & 1 deletion pyhaystack/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

__author__ = "Christian Tremblay, Stuart Longland, @sudo-Whateverman, Igor"
__author_email__ = "christian.tremblay@servisys.com"
__version__ = "0.92.10"
__version__ = "0.92.11"
__license__ = "Apache 2.0"
__copyright__ = "Christian Tremblay / SERVISYS inc. | Stuart Longland / VRT | 2016"

0 comments on commit fd1cfca

Please sign in to comment.