Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions cuvis/General.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
import platform
import pkg_resources
from importlib.metadata import version as imp_version

from ._cuvis_il import cuvis_il
from .cuvis_aux import SDKException
Expand All @@ -12,16 +12,22 @@
from typing import Union, Optional


def init(settings_path: str = ".", global_loglevel: Union[int, str] = logging.DEBUG, logfile_name: Optional[str] = None):
if 'CUVIS_SETTINGS' in os.environ and settings_path == ".":
def init(
settings_path: str = ".",
global_loglevel: Union[int, str] = logging.DEBUG,
logfile_name: Optional[str] = None,
):
if "CUVIS_SETTINGS" in os.environ and settings_path == ".":
# env variable is set and settings path is default kwarg
settings_path = os.environ['CUVIS_SETTINGS']
settings_path = os.environ["CUVIS_SETTINGS"]

if isinstance(global_loglevel, str):
# also support string as input argument
global_loglevel = internal.__strToLogLevel__[global_loglevel]

if cuvis_il.status_ok != cuvis_il.cuvis_init(settings_path, internal.__CuvisLoglevel__[global_loglevel], logfile_name):
if cuvis_il.status_ok != cuvis_il.cuvis_init(
settings_path, internal.__CuvisLoglevel__[global_loglevel], logfile_name
):
raise SDKException()


Expand All @@ -38,14 +44,13 @@ def sdk_version() -> str:


def wrapper_version() -> str:
pip_version = pkg_resources.require('cuvis')[0].version
with open(Path(__file__).parent.parent / "git-hash.txt", 'r') as f:
pip_version = imp_version("cuvis")
with open(Path(__file__).parent.parent / "git-hash.txt", "r") as f:
git_hash = f.readline()
return f'{pip_version} {git_hash}'.strip()
return f"{pip_version} {git_hash}".strip()


def set_log_level(lvl: Union[int, str]):

def set_log_level(lvl: Union[int, str]):
if isinstance(lvl, str):
# also support string as input argument
lvl = internal.__strToLogLevel__[lvl]
Expand Down