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

click_close()[source]
click_continue()[source]
click_new()[source]
show()[source]
class nexuslims_logger.db_logger_gui.LogWindow(parent, is_error=False)[source]

Bases: tkinter.Toplevel

change_close_button(num_to_show, state='disabled')[source]
copy_text_to_clipboard()[source]
class nexuslims_logger.db_logger_gui.MainApp(db_logger, screen_res=None)[source]

Bases: tkinter.Tk

close_warning(num_to_show)[source]
done_loading()[source]
on_closing()[source]
session_end()[source]
session_end_worker()[source]
session_startup()[source]
session_startup_worker()[source]
show_error_if_needed(res)[source]
switch_gui_to_end()[source]
watch_for_end_result()[source]

Check if there is something in the queue

watch_for_startup_result()[source]

Check if there is something in the queue

class nexuslims_logger.db_logger_gui.NoteWindow(parent, is_error=False)[source]

Bases: tkinter.Toplevel

change_close_button(num_to_show, state='disabled')[source]
copy_text_to_clipboard()[source]
delete_note()[source]
save_note()[source]
class nexuslims_logger.db_logger_gui.PauseOrEndDialogue(parent, db_logger, screen_res=None)[source]

Bases: tkinter.Toplevel

click_cancel()[source]
click_close()[source]
click_end()[source]
click_pause()[source]
show()[source]
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
  • width (int) – The width of the widget desired

  • height (int) – The height of the widget desired

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

str

class nexuslims_logger.db_logger_gui.ToolTip(wdgt, tooltip_font, msg=None, msgFunc=None, header_msg=None, delay=1, follow=True)[source]

Bases: tkinter.Toplevel

Provides 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

move(event)[source]

Processes motion within the widget. :param event: The event that called this function

show()[source]

Displays the ToolTip if the time delay has been long enough

spawn(event=None)[source]

Spawn the ToolTip. This simply makes the ToolTip eligible for display. Usually this is caused by entering the widget

Parameters

event – The event that called this function

nexuslims_logger.db_logger_gui.check_singleton()[source]
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

str

nexuslims_logger.db_logger_gui.resource_path(relative_path)[source]
nexuslims_logger.db_logger_gui.tendo_singleton()[source]

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
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

bool

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_text attribute (regardless of verbosity)

Parameters
  • to_print (str) – The message to log

  • this_verbosity (int) – The verbosity level (higher is more verbose)

log_exception(e)[source]

Log an exception to the console and the log_text

Parameters

e (Exception) –

mount_network_share(mount_point=None)[source]

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 subprocess pipes, accordingly.

Parameters

cmd (str) – The command to run (will be run in a new Windows cmd shell). stderr will be redirected for stdout and included in the returned output

Returns

output – The output of cmd

Return type

str

umount_network_share()[source]

Unmount the network share using the Windows cmd

nexuslims_logger.make_db_entry.cmdline_args()[source]
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

list of 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

str

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

list of 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.)

nexuslims_logger.make_db_entry.gui_start_callback(config, verbosity=2)[source]

Process the start of a session when the GUI is opened

Returns

db_logger – The session logger instance for this session (contains all the information about instrument, computer, session_id, etc.)

Return type

DBSessionLogger