nexuslims_logger namespace¶
Submodules¶
nexuslims_logger.db_logger_gui module¶
- class nexuslims_logger.db_logger_gui.HangingSessionDialog(parent, db_logger, screen_res=None)[source]¶
Bases:
tkinter.Toplevel
- class nexuslims_logger.db_logger_gui.LogWindow(parent, is_error=False)[source]¶
Bases:
tkinter.Toplevel
- class nexuslims_logger.db_logger_gui.MainApp(db_logger, screen_res=None)[source]¶
Bases:
tkinter.Tk
- class nexuslims_logger.db_logger_gui.NoteWindow(parent, is_error=False)[source]¶
Bases:
tkinter.Toplevel
- class nexuslims_logger.db_logger_gui.PauseOrEndDialogue(parent, db_logger, screen_res=None)[source]¶
Bases:
tkinter.Toplevel
- class nexuslims_logger.db_logger_gui.ScreenRes(db_logger)[source]¶
Bases:
object- get_center_geometry_string(width, height)[source]¶
This method will return a Tkinter geometry string that will place a Toplevel window into the middle of the screen given the widget’s width and height (using a Windows command or xrandr as needed). If it fails for some reason, a basic resolution of 800x600 is assumed.
- Parameters
- Returns
geometry_string – The Tkinter geometry string that will put a window of width and height at the center of the screen given the current resolution (of the format “WIDTHxHEIGHT+XPOSITION+YPOSITION”)
- Return type
- class nexuslims_logger.db_logger_gui.ToolTip(wdgt, tooltip_font, msg=None, msgFunc=None, header_msg=None, delay=1, follow=True)[source]¶
Bases:
tkinter.ToplevelProvides a ToolTip widget for Tkinter. To apply a ToolTip to any Tkinter widget, simply pass the widget to the ToolTip constructor
- hide(event=None)[source]¶
Hides the ToolTip. Usually this is caused by leaving the widget :param event: The event that called this function
- nexuslims_logger.db_logger_gui.format_date(dt, with_newline=True)[source]¶
Format a datetime object in our preferred format
- Parameters
dt (datetime.datetime) –
- Returns
datestring – A datetime formatted in our preferred format
- Return type
nexuslims_logger.main module¶
nexuslims_logger.make_db_entry module¶
- class nexuslims_logger.make_db_entry.DBSessionLogger(config, verbosity=0, user=None)[source]¶
Bases:
object- check_exit_queue(thread_queue, exit_queue)[source]¶
Check to see if a queue (
exit_queue) has anything in it. If so, immediately exit.- Parameters
thread_queue (queue.Queue) –
exit_queue (queue.Queue) –
- db_logger_setup(thread_queue=None, exit_queue=None)[source]¶
setup routine: 1) mount network share. 2) check db exists. 3) get instrument info (pid, schema name).
- db_logger_teardown(thread_queue=None, exit_queue=None)[source]¶
teardown routine 1) unmount network share.
- get_instr_pid()[source]¶
Using the name of this computer, get the matching instrument PID from the database
- Returns
instrument_pid (str) – The PID for the instrument corresponding to this computer
instrument_schema_name (str) – The schema name for the instrument corresponding to this computer
filestore_path (str) – The filestore path for the instrument corresponding to this computer
- last_session_ended(thread_queue=None, exit_queue=None)[source]¶
Check the database for this instrument to make sure that the last entry in the db was an “END” (properly ended). If it’s not, return False so the GUI can query the user for additional input on how to proceed.
- Parameters
thread_queue (queue.Queue) – Main queue for communication with the GUI
exit_queue (queue.Queue) – Queue containing any errors so the GUI knows to exit as needed
- Returns
state_is_consistent – If the database is consistent (i.e. the last log for this instrument is an “END” log), return True. If not (it’s a “START” log), return False
- Return type
- log(to_print, this_verbosity)[source]¶
Log a message to the console, only printing if the given verbosity is equal to or lower than the global threshold. Also save it in this instance’s
log_textattribute (regardless of verbosity)
- log_exception(e)[source]¶
Log an exception to the console and the
log_text- Parameters
e (Exception) –
Mount the path containing the database to the first free drive letter found using Windows cmd. Due to some Windows limitations, this requires looking up the server’s IP address and mounting using the IP rather than the actual domain name
- Parameters
mount_point (str) – The mount point on the network drive. The default points to the self.db_path.
- process_end(thread_queue=None, exit_queue=None)[source]¶
Insert a session ‘END’ log for this computer’s instrument, and change the status of the corresponding ‘START’ entry from ‘WAITING_FOR_END’ to ‘TO_BE_BUILT’
- process_start(thread_queue=None, exit_queue=None)[source]¶
Insert a session ‘START’ log for this computer’s instrument
Returns True if successful, False if not
- run_cmd(cmd)[source]¶
Run a command using the subprocess module and return the output. Note that because we want to run the eventual logger without a console visible, we do not have access to the standard stdin, stdout, and stderr, and these need to be redirected
subprocesspipes, accordingly.
Unmount the network share using the Windows cmd
- nexuslims_logger.make_db_entry.get_drives()[source]¶
Get the drive letters (uppercase) in current use by Windows
Adapted from https://stackoverflow.com/a/827398/1435788
- Returns
drives – A list of drive letters currently in use
- Return type
listof str
- nexuslims_logger.make_db_entry.get_first_free_drive()[source]¶
Get the first available drive letter that is not being used on this computer
- Returns
first_free – The first free drive letter that should be safe to use with colon appended
- Return type
- nexuslims_logger.make_db_entry.get_free_drives()[source]¶
Get currently unused drive letters, leaving out A through G and M for safety (since those are often Windows drives and the M drive is used for
mmfnexus- Returns
not_in_use – A list of “safe” drive letters not currently in use
- Return type
listof str
- nexuslims_logger.make_db_entry.gui_end_callback(db_logger)[source]¶
Process the end of a session when the button is clicked or the GUI window is closed.
- Parameters
db_logger (DBSessionLogger) – The session logger instance for this session (contains all the information about instrument, computer, session_id, etc.)