Skip to content

Commit

Permalink
rebase pubsub fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
craig8 committed Jul 31, 2024
1 parent 91e5fe0 commit ec85a41
Show file tree
Hide file tree
Showing 11 changed files with 505 additions and 554 deletions.
16 changes: 16 additions & 0 deletions src/volttron/client/logs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging
from logging import Logger
import sys
import os


def get_logger() -> Logger:
Expand Down Expand Up @@ -43,6 +45,18 @@ def get_default_client_log_config(level=logging.DEBUG) -> dict:
}


class JsonFormatter(logging.Formatter):

def format(self, record):
dct = record.__dict__.copy()
dct["msg"] = record.getMessage()
dct.pop("args")
exc_info = dct.pop("exc_info", None)
if exc_info:
dct["exc_text"] = "".join(traceback.format_exception(*exc_info))
return jsonapi.dumps(dct)


class AgentFormatter(logging.Formatter):

def __init__(self, fmt=None, datefmt=None):
Expand All @@ -66,6 +80,8 @@ def format(self, record):


def setup_logging(level=logging.DEBUG, console=False):
from volttron.utils.commands import isapipe

root = logging.getLogger()
if not root.handlers:
handler = logging.StreamHandler()
Expand Down
8 changes: 5 additions & 3 deletions src/volttron/client/vip/agent/subsystems/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from zmq import ZMQError
from zmq.green import ENOTSOCK

from volttron.auth.auth_exception import AuthException
#from volttron.auth.auth_exception import AuthException
from volttron.utils import jsonapi, jsonrpc
from volttron.client.known_identities import AUTH

Expand Down Expand Up @@ -265,8 +265,10 @@ def checked_method(*args, **kwargs):
method_name = method.__name__
args_dict = inspect.getcallargs(method, *args, **kwargs)
try:
self.call(AUTH, "check_authorization",
identity=calling_user, method_name=f"{self.core.identity}.{method_name}",
self.call(AUTH,
"check_authorization",
identity=calling_user,
method_name=f"{self.core.identity}.{method_name}",
method_args=args_dict).get(timeout=10)
except AuthException as e:
# msg = ("method '{}' requires capabilities {}, but capability {} "
Expand Down
3 changes: 1 addition & 2 deletions src/volttron/server/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import logging
import os

from volttron.client.logs import AgentFormatter

# -*- coding: utf-8 -*- {{{
# ===----------------------------------------------------------------------===
#
Expand Down Expand Up @@ -62,6 +60,7 @@
import warnings

from volttron.utils import jsonapi
from volttron.client.logs import AgentFormatter

try:
HAS_SYSLOG = True
Expand Down
5 changes: 2 additions & 3 deletions src/volttron/types/auth/authz_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,8 @@ def create_or_merge_role(self,
rpc_capabilities: RPCCapabilities = None,
pubsub_capabilities: PubsubCapabilities = None) -> bool:
if not rpc_capabilities and not pubsub_capabilities:
raise ValueError(
f"Role {name} should have non empty capabilities - __rpc__ capabilities, "
"pubsub capabilities or both")
raise ValueError(f"Role {name} should have non empty capabilities - rpc capabilities, "
"pubsub capabilities or both")
if not self.compact_dict.get(ROLES):
self.compact_dict[ROLES] = dict()
if name not in self.compact_dict.get(ROLES):
Expand Down
4 changes: 1 addition & 3 deletions src/volttron/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
from volttron.utils.version import get_version
from volttron.types import Identity

from volttron.client.logs import setup_logging

_log = logging.getLogger(__name__)


Expand Down Expand Up @@ -92,7 +90,7 @@ def load_config(default_configuration: str | Path | dict | None) -> dict:
:rtype: dict
"""

if default_configuration is None:
if default_configuration is None or default_configuration == "":
return {}

if isinstance(default_configuration, dict):
Expand Down
19 changes: 0 additions & 19 deletions tests/unit/test_aip.py

This file was deleted.

Loading

0 comments on commit ec85a41

Please sign in to comment.