python-eigen-ingenuity-nocli 0.5.26b1__tar.gz → 0.5.27__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_eigen_ingenuity_nocli-0.5.26b1/python_eigen_ingenuity_nocli.egg-info → python_eigen_ingenuity_nocli-0.5.27}/PKG-INFO +1 -1
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/core/__init__.py +9 -3
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/logformatter.py +40 -7
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/util.py +148 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27/python_eigen_ingenuity_nocli.egg-info}/PKG-INFO +1 -1
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/MANIFEST.in +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/README-nocli.md +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/README.md +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/assetmodel.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/auth.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/commonmenu.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/elastic.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/events.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/historian.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/historianmulti.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/settings.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/sql.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/common.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/config.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/demo.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historian/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historian/test_getCurrentDataPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historian/test_getInterpolatedPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historian/test_getInterpolatedRange.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historian/test_getMetaData.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historian/test_getRawDataPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historian/test_listDataTags.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historian/test_writePoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/common_multi.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/test_getClosestRawPoint.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/test_getCurrentDataPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/test_getInterpolatedPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/test_getInterpolatedRange.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/test_getMetaData.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/test_getRawDatapoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/test_listDataTags.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/test_tagManagement.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/historianmulti/test_writePoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/run_tests.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/assetmodelbuilder.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/assetmodelcsvwriter.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/assetmodelutilities.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/configmanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/connectors/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/connectors/boltconnector.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/connectors/dbconnectors.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/connectors/genericconnector.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/connectors/httpsconnector.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/csvcontentsmanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/csvwriter.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/fileanalyser.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/filemanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/messages.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/processors/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/processors/cypherfileprocessor.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/processors/labelmanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/processors/nodefileprocessor.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/processors/propertymanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/processors/relationshipfileprocessor.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/processors/relationshipmanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/property.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/queries/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/queries/cypherbuilder.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/queries/query.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/modelbuilder/src/versionmanager.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/pyproject.toml +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/python_eigen_ingenuity_nocli.egg-info/SOURCES.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/python_eigen_ingenuity_nocli.egg-info/dependency_links.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/python_eigen_ingenuity_nocli.egg-info/requires.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/python_eigen_ingenuity_nocli.egg-info/top_level.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/common.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/common_multi.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian/common.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian/test_getCurrentDataPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian/test_getInterpolatedPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian/test_getInterpolatedRange.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian/test_getMetaData.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian/test_getRawDataPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian/test_listDataTags.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian/test_writePoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/__init__.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/common_multi.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/test_getClosestRawPoint.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/test_getCurrentDataPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/test_getInterpolatedPoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/test_getInterpolatedRange.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/test_getMetaData.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/test_getRawDatapoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/test_listDataTags.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/test_tagManagement.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/regressiontests/eigeningenuity/historian-multi/test_writePoints.py +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/requirements.txt +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/setup.cfg +0 -0
- {python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/setup.py +0 -0
|
@@ -22,6 +22,7 @@ import warnings
|
|
|
22
22
|
from eigeningenuity.util import (
|
|
23
23
|
_do_eigen_json_request,
|
|
24
24
|
EigenException,
|
|
25
|
+
_construct_trace_headers,
|
|
25
26
|
)
|
|
26
27
|
import eigeningenuity.settings as settings
|
|
27
28
|
|
|
@@ -59,13 +60,16 @@ class EigenServer(object):
|
|
|
59
60
|
baseurl = "http://localhost:8080/"
|
|
60
61
|
|
|
61
62
|
if settings._azure_auth_enabled_:
|
|
62
|
-
|
|
63
|
+
|
|
64
|
+
headers = _construct_trace_headers({}, preflight=True)
|
|
65
|
+
preflight = requests.get(baseurl + "/historian/list", verify=False, headers=headers)
|
|
63
66
|
|
|
64
67
|
# Old Method, not sure if any servers still use this and cant use the new one, but backwards compatibility
|
|
65
68
|
if preflight.status_code != 200:
|
|
66
69
|
preflight = requests.get(
|
|
67
70
|
baseurl + "historian-servlet/jsonbridge/calc?cmd=LISTHISTORIANS",
|
|
68
71
|
verify=False,
|
|
72
|
+
headers=headers,
|
|
69
73
|
)
|
|
70
74
|
|
|
71
75
|
if preflight.status_code != 200:
|
|
@@ -89,10 +93,12 @@ class EigenServer(object):
|
|
|
89
93
|
return self.__baseurl
|
|
90
94
|
|
|
91
95
|
def listDataSources(self):
|
|
92
|
-
|
|
96
|
+
headers = _construct_trace_headers({}, preflight=True)
|
|
97
|
+
return _do_eigen_json_request(self.__baseurl + "historian/list", headers)
|
|
93
98
|
|
|
94
99
|
def listWritableDataSources(self):
|
|
95
|
-
|
|
100
|
+
headers = _construct_trace_headers({}, preflight=True)
|
|
101
|
+
return _do_eigen_json_request(self.__baseurl + "historian/listwritable", headers)
|
|
96
102
|
|
|
97
103
|
def getHistorian(self, *args, **kwargs):
|
|
98
104
|
warnings.warn(
|
|
@@ -2,7 +2,7 @@ import datetime
|
|
|
2
2
|
import traceback
|
|
3
3
|
import sys
|
|
4
4
|
import logging
|
|
5
|
-
|
|
5
|
+
from eigeningenuity.util import _get_external_callsite
|
|
6
6
|
|
|
7
7
|
# Function to add the filename to each line of the traceback
|
|
8
8
|
def format_traceback(exc_type, exc_value, exc_traceback, filename, configfile):
|
|
@@ -74,22 +74,45 @@ def exception_formatter(exc_type, exc_value, exc_traceback, filename, configfile
|
|
|
74
74
|
sys.excepthook = exception_formatter
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
def
|
|
77
|
+
def _resolve_log_level(log_level):
|
|
78
|
+
"""Resolve string/int log levels into a logging module level integer."""
|
|
79
|
+
if isinstance(log_level, int):
|
|
80
|
+
return log_level
|
|
81
|
+
|
|
82
|
+
if isinstance(log_level, str):
|
|
83
|
+
level_name = log_level.strip().upper()
|
|
84
|
+
resolved = logging.getLevelName(level_name)
|
|
85
|
+
if isinstance(resolved, int):
|
|
86
|
+
return resolved
|
|
87
|
+
|
|
88
|
+
raise ValueError(
|
|
89
|
+
"Invalid log level. Use an int or one of: DEBUG, INFO, WARNING, ERROR, CRITICAL"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def log_handler(filename, configfile="", log_level=logging.INFO):
|
|
78
94
|
"""Configure root logger to output formatted messages to stdout.
|
|
79
95
|
|
|
80
96
|
Args:
|
|
81
97
|
filename (str): Base filename context for log entries.
|
|
82
98
|
configfile (str, optional): Configfile suffix. Defaults to "".
|
|
83
99
|
|
|
100
|
+
Args:
|
|
101
|
+
filename (str): Base filename context for log entries.
|
|
102
|
+
configfile (str, optional): Configfile suffix. Defaults to "".
|
|
103
|
+
log_level (Union[int, str], optional): Logging level. Defaults to logging.INFO.
|
|
104
|
+
|
|
84
105
|
Returns:
|
|
85
106
|
None
|
|
86
107
|
"""
|
|
108
|
+
resolved_level = _resolve_log_level(log_level)
|
|
109
|
+
|
|
87
110
|
if configfile != "":
|
|
88
111
|
configfile = ":" + configfile
|
|
89
112
|
stream_handler = logging.StreamHandler(
|
|
90
113
|
sys.stdout
|
|
91
114
|
) # By default, it logs to sys.stderr, but you can specify stdout.
|
|
92
|
-
stream_handler.setLevel(
|
|
115
|
+
stream_handler.setLevel(resolved_level)
|
|
93
116
|
stream_formatter = logging.Formatter(
|
|
94
117
|
f"%(asctime)s - {filename}{configfile} - %(levelname)s - %(message)s"
|
|
95
118
|
)
|
|
@@ -97,11 +120,11 @@ def log_handler(filename, configfile=""):
|
|
|
97
120
|
|
|
98
121
|
# Get the root logger and add the stream handler to it
|
|
99
122
|
root_logger = logging.getLogger()
|
|
100
|
-
root_logger.setLevel(
|
|
123
|
+
root_logger.setLevel(resolved_level)
|
|
101
124
|
root_logger.addHandler(stream_handler)
|
|
102
125
|
|
|
103
126
|
|
|
104
|
-
def setup_logging(filename, configfile=""):
|
|
127
|
+
def setup_logging(filename="", configfile="", log_level=logging.INFO, level=None):
|
|
105
128
|
"""Initialize logging, warning, and exception handlers. Fomratted to include timestamps and script filename.
|
|
106
129
|
|
|
107
130
|
This function is for use in scripts that run on containers, where the only logging output is stdout, and the filename context is important for distinguishing log entries.
|
|
@@ -111,6 +134,8 @@ def setup_logging(filename, configfile=""):
|
|
|
111
134
|
Args:
|
|
112
135
|
filename (str): Base filename context for log entries.
|
|
113
136
|
configfile (str, optional): Configfile suffix. Defaults to "".
|
|
137
|
+
log_level (Union[int, str], optional): Logging level. Defaults to logging.INFO.
|
|
138
|
+
level (Union[int, str], optional): Backward-compatible alias for log_level.
|
|
114
139
|
|
|
115
140
|
Returns:
|
|
116
141
|
None
|
|
@@ -118,7 +143,11 @@ def setup_logging(filename, configfile=""):
|
|
|
118
143
|
import warnings
|
|
119
144
|
import os
|
|
120
145
|
import atexit
|
|
121
|
-
|
|
146
|
+
|
|
147
|
+
if filename == "":
|
|
148
|
+
caller = _get_external_callsite()
|
|
149
|
+
filename = caller["file"] if caller and "file" in caller else "unknown"
|
|
150
|
+
|
|
122
151
|
# Extract just the filename if a full path is provided
|
|
123
152
|
if "/" in filename or "\\" in filename:
|
|
124
153
|
filename = os.path.basename(filename)
|
|
@@ -126,8 +155,12 @@ def setup_logging(filename, configfile=""):
|
|
|
126
155
|
if "/" in configfile or "\\" in configfile:
|
|
127
156
|
configfile = os.path.basename(configfile)
|
|
128
157
|
|
|
158
|
+
# Backward-compatible alias support for existing callers.
|
|
159
|
+
if level is not None:
|
|
160
|
+
log_level = level
|
|
161
|
+
|
|
129
162
|
# Set up logging handler
|
|
130
|
-
log_handler(filename, configfile)
|
|
163
|
+
log_handler(filename, configfile, log_level=log_level)
|
|
131
164
|
|
|
132
165
|
# Set up custom warning handler
|
|
133
166
|
def custom_warning_handler(
|
{python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/util.py
RENAMED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import re
|
|
3
3
|
import time
|
|
4
|
+
import os
|
|
5
|
+
import inspect
|
|
6
|
+
import socket
|
|
4
7
|
import requests
|
|
5
8
|
import csv
|
|
6
9
|
import logging
|
|
@@ -38,6 +41,8 @@ def _do_eigen_json_request(requesturl, auth, **params):
|
|
|
38
41
|
if settings._api_token_value_:
|
|
39
42
|
headers["X-Api-Key"] = settings._api_token_value_
|
|
40
43
|
|
|
44
|
+
headers.update(_construct_trace_headers(headers))
|
|
45
|
+
|
|
41
46
|
if params:
|
|
42
47
|
# Build parameter list, handling multiple values per key
|
|
43
48
|
param_list = []
|
|
@@ -101,6 +106,8 @@ def _do_eigen_post_request(requesturl, payload, auth):
|
|
|
101
106
|
|
|
102
107
|
if settings._api_token_value_:
|
|
103
108
|
headers["X-Api-Key"] = settings._api_token_value_
|
|
109
|
+
|
|
110
|
+
headers.update(_construct_trace_headers(headers))
|
|
104
111
|
|
|
105
112
|
resp = requests.post(requesturl, json=payload, headers=headers, verify=False)
|
|
106
113
|
|
|
@@ -132,6 +139,8 @@ def _do_chunked_eigen_post_request(requesturl, data, label, auth):
|
|
|
132
139
|
|
|
133
140
|
if settings._api_token_value_:
|
|
134
141
|
headers["X-Api-Key"] = settings._api_token_value_
|
|
142
|
+
|
|
143
|
+
headers.update(_construct_trace_headers(headers))
|
|
135
144
|
|
|
136
145
|
chunks = list(divide_chunks(data, 500))
|
|
137
146
|
failures = []
|
|
@@ -585,6 +594,143 @@ def update_keys(my_dict, historian):
|
|
|
585
594
|
}
|
|
586
595
|
|
|
587
596
|
|
|
597
|
+
def _get_external_callsite(package_root=None):
|
|
598
|
+
"""Return the first non-library callsite from the current stack.
|
|
599
|
+
|
|
600
|
+
This helps us attribute requests to user code (filename/line/function)
|
|
601
|
+
without requiring every public API method to pass explicit metadata.
|
|
602
|
+
"""
|
|
603
|
+
if package_root is None:
|
|
604
|
+
package_root = os.path.dirname(__file__)
|
|
605
|
+
|
|
606
|
+
package_root = os.path.normcase(os.path.abspath(package_root))
|
|
607
|
+
frame = inspect.currentframe()
|
|
608
|
+
|
|
609
|
+
try:
|
|
610
|
+
# Skip this helper and its immediate caller.
|
|
611
|
+
frame = frame.f_back
|
|
612
|
+
if frame is not None:
|
|
613
|
+
frame = frame.f_back
|
|
614
|
+
|
|
615
|
+
while frame is not None:
|
|
616
|
+
filename = os.path.normcase(os.path.abspath(frame.f_code.co_filename))
|
|
617
|
+
if not filename.startswith(package_root):
|
|
618
|
+
function_name = frame.f_code.co_name
|
|
619
|
+
if function_name == "<module>":
|
|
620
|
+
function_name = "module"
|
|
621
|
+
frame_info = inspect.getframeinfo(frame)
|
|
622
|
+
source_line = ""
|
|
623
|
+
if frame_info.code_context:
|
|
624
|
+
source_line = frame_info.code_context[0].strip()
|
|
625
|
+
return {
|
|
626
|
+
"file": os.path.basename(frame.f_code.co_filename),
|
|
627
|
+
"line": frame.f_lineno,
|
|
628
|
+
"function": function_name,
|
|
629
|
+
"source": source_line,
|
|
630
|
+
}
|
|
631
|
+
frame = frame.f_back
|
|
632
|
+
finally:
|
|
633
|
+
# Avoid reference cycles with frame objects.
|
|
634
|
+
del frame
|
|
635
|
+
|
|
636
|
+
return None
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
def _get_library_api_callsite(package_name="eigeningenuity", exclude_modules=None):
|
|
640
|
+
"""Return the user-facing library API frame as class/method metadata.
|
|
641
|
+
|
|
642
|
+
Walks outward through stack frames and prefers the outermost public method
|
|
643
|
+
(method name not starting with "_") in the first contiguous package call
|
|
644
|
+
chain. Falls back to the outermost package frame when only internal helpers
|
|
645
|
+
are present.
|
|
646
|
+
"""
|
|
647
|
+
if exclude_modules is None:
|
|
648
|
+
exclude_modules = {"eigeningenuity.util"}
|
|
649
|
+
|
|
650
|
+
frame = inspect.currentframe()
|
|
651
|
+
|
|
652
|
+
try:
|
|
653
|
+
# Skip this helper and its immediate caller.
|
|
654
|
+
frame = frame.f_back
|
|
655
|
+
if frame is not None:
|
|
656
|
+
frame = frame.f_back
|
|
657
|
+
|
|
658
|
+
latest_public = None
|
|
659
|
+
latest_any = None
|
|
660
|
+
saw_package_chain = False
|
|
661
|
+
|
|
662
|
+
while frame is not None:
|
|
663
|
+
module_name = frame.f_globals.get("__name__", "")
|
|
664
|
+
|
|
665
|
+
# Skip excluded modules (e.g., util internals) without breaking chain detection.
|
|
666
|
+
if module_name in exclude_modules:
|
|
667
|
+
frame = frame.f_back
|
|
668
|
+
continue
|
|
669
|
+
|
|
670
|
+
if module_name.startswith(package_name):
|
|
671
|
+
saw_package_chain = True
|
|
672
|
+
method_name = frame.f_code.co_name
|
|
673
|
+
instance = frame.f_locals.get("self")
|
|
674
|
+
class_name = type(instance).__name__ if instance is not None else None
|
|
675
|
+
|
|
676
|
+
candidate = {
|
|
677
|
+
"module": module_name,
|
|
678
|
+
"class": class_name,
|
|
679
|
+
"method": method_name,
|
|
680
|
+
"api": f"{class_name}.{method_name}" if class_name else method_name,
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
latest_any = candidate
|
|
684
|
+
if not method_name.startswith("_"):
|
|
685
|
+
latest_public = candidate
|
|
686
|
+
|
|
687
|
+
elif saw_package_chain:
|
|
688
|
+
# We left the package call chain; use the outermost public API if possible.
|
|
689
|
+
break
|
|
690
|
+
|
|
691
|
+
frame = frame.f_back
|
|
692
|
+
|
|
693
|
+
return latest_public or latest_any
|
|
694
|
+
finally:
|
|
695
|
+
del frame
|
|
696
|
+
|
|
697
|
+
return None
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
def _get_machine_name():
|
|
701
|
+
"""Return the current machine/host name if it's safe to send (No personal machine names)."""
|
|
702
|
+
hostname = socket.gethostname()
|
|
703
|
+
if os.environ.get("IS_CONTAINER", True):
|
|
704
|
+
return hostname
|
|
705
|
+
return None
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
def _construct_trace_headers(headers={},preflight=False):
|
|
710
|
+
"""Construct trace headers for a request based on callsite and auth context."""
|
|
711
|
+
|
|
712
|
+
caller = _get_external_callsite()
|
|
713
|
+
api_caller = _get_library_api_callsite()
|
|
714
|
+
machine_name = _get_machine_name()
|
|
715
|
+
api_class = api_caller["class"] if api_caller else ""
|
|
716
|
+
api_method = api_caller["method"] if api_caller else ""
|
|
717
|
+
|
|
718
|
+
if preflight:
|
|
719
|
+
headers["X-Trace-Source"] = f"traceSource=python-lib,traceMachine={machine_name or 'Personal'},traceScript=preflightCheck,traceClass={api_class}"
|
|
720
|
+
elif caller:
|
|
721
|
+
if machine_name:
|
|
722
|
+
headers["X-Trace-Source"] = (
|
|
723
|
+
f"traceSource=python-lib,traceMachine={machine_name},traceScript={caller['file']},traceLine={caller['line']},traceClass={api_class},traceMethod={api_method}"
|
|
724
|
+
)
|
|
725
|
+
else:
|
|
726
|
+
headers["X-Trace-Source"] = f"traceSource=python-lib,traceMachine=Personal,traceClass={api_class},traceMethod={api_method}"
|
|
727
|
+
logging.debug(
|
|
728
|
+
"Trace source: %s",
|
|
729
|
+
headers["X-Trace-Source"],
|
|
730
|
+
)
|
|
731
|
+
|
|
732
|
+
return headers
|
|
733
|
+
|
|
588
734
|
def _do_historian_multi_request(
|
|
589
735
|
url, body, auth, write_request=False, get_request=False, timestamp_format="iso"
|
|
590
736
|
):
|
|
@@ -601,6 +747,8 @@ def _do_historian_multi_request(
|
|
|
601
747
|
if settings._api_token_value_:
|
|
602
748
|
headers["X-Api-Key"] = settings._api_token_value_
|
|
603
749
|
|
|
750
|
+
headers.update(_construct_trace_headers(headers))
|
|
751
|
+
|
|
604
752
|
if get_request:
|
|
605
753
|
resp = requests.get(url, verify=False, headers=headers).json()
|
|
606
754
|
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/README-nocli.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/auth.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/eigeningenuity/sql.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/common.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/config.py
RENAMED
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/local-tests/demo.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/pyproject.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_eigen_ingenuity_nocli-0.5.26b1 → python_eigen_ingenuity_nocli-0.5.27}/requirements.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|