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
5 changes: 4 additions & 1 deletion cuvis/FileWriteSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class SaveArgs(GeneralExportSettings):
soft_limit: int = 20
hard_limit: int = 100
max_buftime: int = 10000
full_export: bool = False

def _get_internal(self):
ge = super()._get_internal()
Expand All @@ -157,6 +158,7 @@ def _get_internal(self):
sa.soft_limit = int(self.soft_limit)
sa.hard_limit = int(self.hard_limit)
sa.max_buftime = int(self.max_buftime)
sa.full_export = int(self.full_export)
return ge, sa

@classmethod
Expand All @@ -172,7 +174,8 @@ def _from_internal(cls, ge, sa):
fps = sa.fps,
soft_limit = sa.soft_limit,
hard_limit = sa.hard_limit,
max_buftime = sa.max_buftime
max_buftime = sa.max_buftime,
full_export = sa.full_export
)

@dataclass
Expand Down
83 changes: 42 additions & 41 deletions cuvis/General.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,53 @@

from dataclasses import dataclass

class General(object):
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(log_path):
pass
elif platform.system() == "Linux":
log_path = os.path.join(os.path.expanduser('~'), ".cuvis")
os.makedirs(log_path, exist_ok=True)
elif platform.system() == "Windows":
log_path = "C:\\ProgramData\\cuvis"
os.makedirs(log_path, exist_ok=True)

if os.path.exists(log_path):
logging.basicConfig(filename= os.path.join(log_path, "cuvisSDK_python.log"),
format=FORMAT,
encoding='utf-8',
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(settings_path, internal.__CuvisLoglevel__[global_loglevel]):
raise SDKException()
def init(settings_path:str=".", log_path:str="", global_loglevel:int=logging.DEBUG):
FORMAT = '%(asctime)s -- %(levelname)s: %(message)s'
if os.path.exists(log_path):
pass
elif platform.system() == "Linux":
log_path = os.path.join(os.path.expanduser('~'), ".cuvis")
os.makedirs(log_path, exist_ok=True)
elif platform.system() == "Windows":
log_path = "C:\\ProgramData\\cuvis"
os.makedirs(log_path, exist_ok=True)

if os.path.exists(log_path):
logging.basicConfig(filename= os.path.join(log_path, "cuvisSDK_python.log"),
format=FORMAT,
encoding='utf-8',
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(settings_path, internal.__CuvisLoglevel__[global_loglevel]):
raise SDKException()

def shutdown():
cuvis_il.cuvis_shutdown()

@property
def version(self) -> str:
return cuvis_il.cuvis_version_swig()
def version() -> str:
return cuvis_il.cuvis_version_swig()

def set_log_level(self, lvl):
lvl_dict = {"info": {"cuvis": cuvis_il.loglevel_info,
"logging": logging.INFO},
"debug": {"cuvis": cuvis_il.loglevel_debug,
"logging": logging.DEBUG},
"error": {"cuvis": cuvis_il.loglevel_error,
"logging": logging.ERROR},
"fatal": {"cuvis": cuvis_il.loglevel_fatal,
"logging": logging.CRITICAL},
"warning": {"cuvis": cuvis_il.loglevel_warning,
"logging": logging.WARNING},
}
def set_log_level(lvl):
lvl_dict = {"info": {"cuvis": cuvis_il.loglevel_info,
"logging": logging.INFO},
"debug": {"cuvis": cuvis_il.loglevel_debug,
"logging": logging.DEBUG},
"error": {"cuvis": cuvis_il.loglevel_error,
"logging": logging.ERROR},
"fatal": {"cuvis": cuvis_il.loglevel_fatal,
"logging": logging.CRITICAL},
"warning": {"cuvis": cuvis_il.loglevel_warning,
"logging": logging.WARNING},
}

cuvis_il.cuvis_set_log_level(lvl_dict[lvl]["cuvis"])
logging.basicConfig(level=lvl_dict[lvl]["logging"])
cuvis_il.cuvis_set_log_level(lvl_dict[lvl]["cuvis"])
logging.basicConfig(level=lvl_dict[lvl]["logging"])


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion cuvis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
ProcessingArgs, \
EnviExportSettings, TiffExportSettings, ViewExportSettings, \
WorkerSettings
from .General import General
from .General import init, shutdown, version, set_log_level
from .Measurement import Measurement
from .ProcessingContext import ProcessingContext
from .SessionFile import SessionFile
Expand Down