Skip to content
Merged
Show file tree
Hide file tree
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: 11 additions & 14 deletions cuvis/General.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,29 @@
from dataclasses import dataclass

class General(object):
def __init__(self, path=""):
log_path = "."
def __init__(self, settings_path:str=".", log_path:str="", global_loglevel:int=logging.DEBUG):
FORMAT = '%(asctime)s -- %(levelname)s: %(message)s'
if os.path.exists(path):
log_path = path + os.sep
if os.path.exists(log_path):
pass
elif platform.system() == "Linux":
log_path = os.path.expanduser('~') + os.sep + ".cuvis" + os.sep
if not os.path.exists(log_path):
os.mkdir(log_path)
log_path = os.path.join(os.path.expanduser('~'), ".cuvis")
os.makedirs(log_path, exist_ok=True)
elif platform.system() == "Windows":
log_path = os.getenv('APPDATA') + os.sep + ".cuvis" + os.sep
if not os.path.exists(log_path):
os.mkdir(log_path)

log_path = "C:\\ProgramData\\cuvis"
os.makedirs(log_path, exist_ok=True)

if os.path.exists(log_path):
logging.basicConfig(filename=log_path + "cuvisSDK_python.log",
logging.basicConfig(filename= os.path.join(log_path, "cuvisSDK_python.log"),
format=FORMAT,
encoding='utf-8',
level=logging.DEBUG,
level=global_loglevel,
filemode='w')
else:
raise SDKException(
"path {} does not exist...".format(os.path.abspath(log_path)))
logging.info("Logger ready.")

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

Expand Down
10 changes: 10 additions & 0 deletions cuvis/cuvis_types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import numpy as np
from enum import Enum
import logging

from _cuvis_il import cuvis_il

__CuvisLoglevel__ = {
logging.DEBUG: cuvis_il.loglevel_debug,
logging.INFO: cuvis_il.loglevel_info,
logging.WARNING: cuvis_il.loglevel_warning,
logging.ERROR: cuvis_il.loglevel_error,
logging.FATAL: cuvis_il.loglevel_fatal,
}


def __generateTranslationDict(enum_cls):
transDict = {value : cuvis_il.__dict__[value.name] for value in enum_cls }
return transDict, __inverseTranslationDict(transDict)
Expand Down