2 Commits

Author SHA1 Message Date
e785db369f Merge remote-tracking branch 'origin/master' 2024-07-03 09:49:34 +02:00
4783ec5a32 base, elog destination and file naming change 2024-07-03 09:02:11 +02:00
3 changed files with 34 additions and 32 deletions

39
base.py
View File

@@ -75,6 +75,7 @@ class BaseWindow(QMainWindow):
QThread.__init__(self)
self.parent = parent
self.settings = self.parent.settings
self.folder_name = folder_name
self.time_in_seconds = time_in_seconds
self.reanalysis_time = reanalysis_time
@@ -109,17 +110,28 @@ class BaseWindow(QMainWindow):
name = name_base + "_{0}".format(
idx) if idx > 0 else name_base
save_dest = (folder_name + date_str + '_' + name +
'.png')
'.png')
_dirname = os.path.dirname(save_dest)
if not os.path.exists(save_dest):
if all_fig_data[canvas][idx] is not None:
_dirname = os.path.dirname(save_dest)
#print("DIRECTORY NAME IS ", _dirname)
#print("exists?", os.path.exists(_dirname),
#os.path.exists(save_dest))
if not os.path.isfile(save_dest):
if all_fig_data[canvas][idx] is not None:
if not os.path.exists(_dirname):
os.makedirs(_dirname)
if os.access(_dirname, os.W_OK):
all_fig_data[canvas][idx].savefig(save_dest)
elif not write_message_fired:
_mess = ("Do not have write permission " +
@@ -441,9 +453,13 @@ class BaseWindow(QMainWindow):
self.menu = self.menuBar()
self.elog_dest = self.settings.data["Elog"]["destination"]
try:
self.elog_add_date_to_dir = self.settings.data["Elog"]["addDateToDir"]
except KeyError:
self.elog_add_date_to_dir = True
self.screenshot_dest = self.settings.data["screenshot"]["destination"]
self.stdlog_dest = (self.settings.data["stdlog"]["destination"] +
self.appname + "-" + os.getlogin() + ".log")
@@ -1069,8 +1085,11 @@ class BaseWindow(QMainWindow):
_month = when.strftime("%m")
_day = when.strftime("%d")
return str(_year + "/" + _month + "/" + _day + "/" + self.appname +
"_" + _date_label)
if self.elog_add_date_to_dir:
return str(_year + "/" + _month + "/" + _day + "/" + self.appname +
"_" + _date_label)
else:
return str(self.appname + "_" + _date_label)
def verify_save_to_hdf(self):

View File

@@ -9,22 +9,13 @@ from qtpy.QtWidgets import (QComboBox, QDialog, QFileDialog, QHBoxLayout,
QVBoxLayout)
import elog # https://github.com/paulscherrerinstitute/py_elog
from pyqtacc.bdbase.enumkind import MsgSeverity
from apps4ops.bdbase.enumkind import MsgSeverity
from apps4ops.bdbase.utils import _line
_version = "1.0.0"
_pymodule = os.path.basename(__file__)
_appname, _appext = _pymodule.split(".")
def _line():
"""Macro to return the current line number.
The current line number within the file is used when
reporting messages to the message logging window.
Returns:
int: Current line number.
"""
return inspect.currentframe().f_back.f_lineno
class QSendToELOG(QDialog):
""" Graphical interface to elog

View File

@@ -9,22 +9,14 @@ from qtpy.QtWidgets import (
QLineEdit, QPushButton, QTextEdit, QVBoxLayout)
import elog # https://github.com/paulscherrerinstitute/py_elog
from pyqtacc.bdbase.enumkind import MsgSeverity
from apps4ops.bdbase.enumkind import MsgSeverity
from apps4ops.bdbase.utils import _line
_version = "1.0.0"
_pymodule = os.path.basename(__file__)
_appname, _appext = _pymodule.split(".")
def _line():
"""Macro to return the current line number.
The current line number within the file is used when
reporting messages to the message logging window.
Returns:
int: Current line number.
"""
return inspect.currentframe().f_back.f_lineno
class QSendToELOGFrame(QDialog):
""" Graphical interface to elog