Skip to content

Commit e98f8cd

Browse files
author
César Román
authoredFeb 26, 2023
feat(vision): add authentication and authorization (#137)
1 parent bdfc236 commit e98f8cd

File tree

17 files changed

+241
-112
lines changed

17 files changed

+241
-112
lines changed
 

‎.cz.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
---
12
commitizen:
23
name: cz_conventional_commits
4+
tag_format: v$version
5+
update_changelog_on_bump: true
6+
version: 2023.1.0
7+
version_files:
8+
- src/incendium/version.py

‎.github/workflows/main.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ on:
88
- main
99

1010
jobs:
11-
test:
12-
uses: coatl-dev/workflows/.github/workflows/tox.yml@v1.2.0
11+
tox:
12+
uses: coatl-dev/workflows/.github/workflows/tox.yml@v2.1.0
1313
with:
14-
image: ubuntu-20.04
1514
pre-commit: true

‎.github/workflows/publish.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ on:
77

88
jobs:
99
main:
10-
uses: coatl-dev/workflows/.github/workflows/pypi-upload.yml@v1.2.0
11-
with:
12-
image: ubuntu-20.04
13-
python-version: "2.7"
10+
uses: coatl-dev/workflows/.github/workflows/pypi-upload.yml@v2.1.0
1411
secrets:
1512
pypi-token: ${{ secrets.PYPI_API_TOKEN }}

‎requirements/ci.txt

-1
This file was deleted.

‎requirements/lint.txt

-2
This file was deleted.

‎requirements/style.txt

-5
This file was deleted.

‎src/incendium/dataset.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
from com.inductiveautomation.ignition.common import Dataset
1212
from java.util import Date
1313

14-
from incendium.helper.types import DictStringAny, String
14+
from incendium.helper.types import AnyStr, DictStringAny
1515

1616

1717
class _NanoXML(object):
18-
indent = None # type: String
19-
root = None # type: String
18+
indent = None # type: AnyStr
19+
root = None # type: AnyStr
2020

2121
def __init__(self, root="root", indent="\t"):
22-
# type: (String, String) -> None
22+
# type: (AnyStr, AnyStr) -> None
2323
"""Nano XML initializer.
2424
2525
Args:
@@ -35,7 +35,7 @@ def __init__(self, root="root", indent="\t"):
3535
)
3636

3737
def add_element(self, name):
38-
# type: (String) -> None
38+
# type: (AnyStr) -> None
3939
"""Add an element to the XML document.
4040
4141
Args:
@@ -46,7 +46,7 @@ def add_element(self, name):
4646
)
4747

4848
def add_sub_element(self, name, value):
49-
# type: (String, String) -> None
49+
# type: (AnyStr, AnyStr) -> None
5050
"""Add a sub element to an element.
5151
5252
Args:
@@ -61,7 +61,7 @@ def add_sub_element(self, name, value):
6161
)
6262

6363
def close_element(self, name):
64-
# type: (String) -> None
64+
# type: (AnyStr) -> None
6565
"""Close element.
6666
6767
Args:
@@ -72,7 +72,7 @@ def close_element(self, name):
7272
)
7373

7474
def to_string(self):
75-
# type: () -> String
75+
# type: () -> AnyStr
7676
"""Return the string representation of the XML document.
7777
7878
Returns:
@@ -99,7 +99,7 @@ def _format_object(obj):
9999

100100

101101
def _format_value(obj, header=""):
102-
# type: (Any, String) -> String
102+
# type: (Any, AnyStr) -> AnyStr
103103
"""Format the value to be properly represented in JSON.
104104
105105
Args:
@@ -124,7 +124,7 @@ def _format_value(obj, header=""):
124124

125125

126126
def _to_json(dataset, root=None, is_root=True):
127-
# type: (Dataset, Optional[String], bool) -> String
127+
# type: (Dataset, Optional[AnyStr], bool) -> AnyStr
128128
"""Return a string JSON representation of the Dataset.
129129
130130
Private function.
@@ -188,7 +188,7 @@ def _to_jsonobject(dataset):
188188

189189

190190
def to_json(dataset, root=None):
191-
# type: (Dataset, Optional[String]) -> String
191+
# type: (Dataset, Optional[AnyStr]) -> AnyStr
192192
"""Return a string JSON representation of the Dataset.
193193
194194
Args:
@@ -215,7 +215,7 @@ def to_jsonobject(dataset):
215215

216216

217217
def to_xml(dataset, root="root", element="row", indent="\t"):
218-
# type: (Dataset, String, String, String) -> String
218+
# type: (Dataset, AnyStr, AnyStr, AnyStr) -> AnyStr
219219
r"""Return a string XML representation of the Dataset.
220220
221221
Args:

‎src/incendium/db.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from com.inductiveautomation.ignition.common import BasicDataset
2222
from java.lang import Thread
2323

24-
from incendium.helper.types import DictIntStringAny, SProcResult, String
24+
from incendium.helper.types import AnyStr, DictIntStringAny, SProcResult
2525

2626

2727
class DisposableConnection(object):
@@ -32,11 +32,11 @@ class DisposableConnection(object):
3232
resources.
3333
"""
3434

35-
database = None # type: String
35+
database = None # type: AnyStr
3636
retries = None # type: int
3737

3838
def __init__(self, database, retries=3):
39-
# type: (String, int) -> None
39+
# type: (AnyStr, int) -> None
4040
"""Disposable Connection initializer.
4141
4242
Args:
@@ -89,7 +89,7 @@ def __exit__(
8989

9090
@property
9191
def status(self):
92-
# type: () -> String
92+
# type: () -> AnyStr
9393
"""Get connection status."""
9494
connection_info = system.db.getConnectionInfo(self.database)
9595
return str(connection_info.getValueAt(0, "Status"))
@@ -100,7 +100,7 @@ class Param(object):
100100

101101
def __init__(
102102
self,
103-
name_or_index, # type: Union[int, String]
103+
name_or_index, # type: Union[int, AnyStr]
104104
type_code, # type: int
105105
value=None, # type: Optional[Any]
106106
):
@@ -132,7 +132,7 @@ def __str__(self): # type: ignore[no-untyped-def]
132132

133133
@property
134134
def name_or_index(self):
135-
# type: () -> Union[int, String]
135+
# type: () -> Union[int, AnyStr]
136136
"""Get value of name_or_index."""
137137
return self._name_or_index
138138

@@ -153,7 +153,7 @@ class InParam(Param):
153153
"""Class used for declaring INPUT parameters."""
154154

155155
def __init__(self, name_or_index, type_code, value):
156-
# type: (Union[int, String], int, Any) -> None
156+
# type: (Union[int, AnyStr], int, Any) -> None
157157
"""Create an instance of InParam.
158158
159159
Args:
@@ -169,7 +169,7 @@ class OutParam(Param):
169169
"""Class used for declaring OUTPUT parameters."""
170170

171171
def __init__(self, name_or_index, type_code):
172-
# type: (Union[int, String], int) -> None
172+
# type: (Union[int, AnyStr], int) -> None
173173
"""Create an instance of OutParam.
174174
175175
Args:
@@ -181,9 +181,9 @@ def __init__(self, name_or_index, type_code):
181181

182182

183183
def _execute_sp(
184-
stored_procedure, # type: String
185-
database="", # type: String
186-
transaction=None, # type: Optional[String]
184+
stored_procedure, # type: AnyStr
185+
database="", # type: AnyStr
186+
transaction=None, # type: Optional[AnyStr]
187187
skip_audit=False, # type: bool
188188
in_params=None, # type: Optional[List[InParam]]
189189
out_params=None, # type: Optional[List[OutParam]]
@@ -262,7 +262,7 @@ def _execute_sp(
262262

263263

264264
def check(stored_procedure, database="", params=None):
265-
# type: (String, String, Optional[List[InParam]]) -> Optional[bool]
265+
# type: (AnyStr, AnyStr, Optional[List[InParam]]) -> Optional[bool]
266266
"""Execute a stored procedure against the connection.
267267
268268
This will return a flag set to TRUE or FALSE.
@@ -286,9 +286,9 @@ def check(stored_procedure, database="", params=None):
286286

287287

288288
def execute_non_query(
289-
stored_procedure, # type: String
290-
database="", # type: String
291-
transaction=None, # type: Optional[String]
289+
stored_procedure, # type: AnyStr
290+
database="", # type: AnyStr
291+
transaction=None, # type: Optional[AnyStr]
292292
params=None, # type: Optional[List[InParam]]
293293
):
294294
# type: (...) -> int
@@ -322,8 +322,8 @@ def execute_non_query(
322322

323323

324324
def get_data(
325-
stored_procedure, # type: String
326-
database="", # type: String
325+
stored_procedure, # type: AnyStr
326+
database="", # type: AnyStr
327327
params=None, # type: Optional[List[InParam]]
328328
):
329329
# type: (...) -> BasicDataset
@@ -352,10 +352,10 @@ def get_data(
352352

353353

354354
def get_output_params(
355-
stored_procedure, # type: String
355+
stored_procedure, # type: AnyStr
356356
output, # type: List[OutParam]
357-
database="", # type: String
358-
transaction=None, # type: Optional[String]
357+
database="", # type: AnyStr
358+
transaction=None, # type: Optional[AnyStr]
359359
params=None, # type: Optional[List[InParam]]
360360
):
361361
# type: (...) -> DictIntStringAny
@@ -389,10 +389,10 @@ def get_output_params(
389389

390390

391391
def get_return_value(
392-
stored_procedure, # type: String
392+
stored_procedure, # type: AnyStr
393393
return_type_code, # type: int
394-
database="", # type: String
395-
transaction=None, # type: Optional[String]
394+
database="", # type: AnyStr
395+
transaction=None, # type: Optional[AnyStr]
396396
params=None, # type: Optional[List[InParam]]
397397
):
398398
# type: (...) -> Optional[int]
@@ -425,10 +425,10 @@ def get_return_value(
425425

426426

427427
def o_execute_non_query(
428-
stored_procedure, # type: String
428+
stored_procedure, # type: AnyStr
429429
out_params, # type: List[OutParam]
430-
database="", # type: String
431-
transaction=None, # type: Optional[String]
430+
database="", # type: AnyStr
431+
transaction=None, # type: Optional[AnyStr]
432432
in_params=None, # type: Optional[List[InParam]]
433433
):
434434
# type: (...) -> Tuple[int, DictIntStringAny]
@@ -467,9 +467,9 @@ def o_execute_non_query(
467467

468468

469469
def o_get_data(
470-
stored_procedure, # type: String
470+
stored_procedure, # type: AnyStr
471471
out_params, # type: List[OutParam]
472-
database="", # type: String
472+
database="", # type: AnyStr
473473
in_params=None, # type: Optional[List[InParam]]
474474
):
475475
# type: (...) -> Tuple[BasicDataset, DictIntStringAny]

‎src/incendium/exceptions.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99
from java.lang import Throwable
1010

11-
from incendium.helper.types import InnerException, String
11+
from incendium.helper.types import AnyStr, InnerException
1212

1313

1414
class ApplicationError(Exception):
1515
"""Application Error class."""
1616

1717
cause = None # type: Optional[Throwable]
1818
inner_exception = None # type: InnerException
19-
message = None # type: String
19+
message = None # type: AnyStr
2020

2121
def __init__(
2222
self,
23-
message, # type: String
23+
message, # type: AnyStr
2424
inner_exception=None, # type: InnerException
2525
cause=None, # type: Optional[Throwable]
2626
):
@@ -54,10 +54,10 @@ def __str__(self): # type: ignore[no-untyped-def]
5454
class TagError(Exception):
5555
"""Tag Error class."""
5656

57-
message = None # type: String
57+
message = None # type: AnyStr
5858

5959
def __init__(self, message):
60-
# type: (String) -> None
60+
# type: (AnyStr) -> None
6161
"""Tag Error initializer.
6262
6363
Args:

‎src/incendium/helper/types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from com.inductiveautomation.ignition.common import BasicDataset
66
from java.lang import Exception as JavaException
77

8+
AnyStr = Union[str, unicode]
89
DictIntStringAny = Dict[Union[int, str, unicode], Any]
910
DictStringAny = Dict[Union[str, unicode], Any]
1011
InnerException = Optional[Union[Exception, JavaException]]
@@ -18,4 +19,3 @@
1819
"update_count": int,
1920
},
2021
)
21-
String = Union[str, unicode]
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.