nexuslims_logger namespace
Submodules
nexuslims_logger.dbsessionlogger module
- class nexuslims_logger.dbsessionlogger.DBSessionLogger(dbapi_url, dbapi_username=None, dbapi_password=None, user=None, logger=None)[source]
Bases:
objectcommunicate with database.
- 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]
get instrument info (pid, schema name).
- 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
- 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’
nexuslims_logger.filewatcher module
FileWatcher will watch a directory,and sync with Cloud periodically.
It will upload any files (require file types match if specified) (modified after certain time if specified) that checksum changed wrt. cache (if any) to a GCP cloud bucket in a specified interval.
- class nexuslims_logger.filewatcher.FileWatcher(watch_dir, bucket_name, bucket_dir, credentials, cache_fn, project=None, interval=600, file_types=None, mtime_since=None, instr_info=None, logger=None)[source]
Bases:
object- property bucket_dir
- get_files_to_upload()[source]
find files to upload recursively and return list of abs file names and content checksum.
file satisfying the following condition will be considered for uploading: - file type is allowed (set in app config) - file modification timestamp is after the set threshold (session start time) - file content checksum does not exist in cache or updated.
- property instr_info
- property interval
- property mtime_since
nexuslims_logger.gui module
GUI impl
- class nexuslims_logger.gui.App(db_logger, instrument, filewatcher, screen_res=None, logger=None, log_text=None)[source]
Bases:
tkinter.Tk- done_loading()[source]
actions by the end of loading.
put off
setup_frame, put uprunning_frameand labels, enable buttons.
- draw_info()[source]
information section
incl. loading text, progress bar, instrument label, datetime
- session_end()[source]
routines for session ending.
signal
startup_threadto exit, startend_thread, change the frame, update loading text and progress bar.
- session_end_worker()[source]
session ending routine.
db_loggerperform ending actions, stop file syncing thread, final file syncing, tear downdb_logger
- session_startup_worker()[source]
session startup routine
setup db_logger, check if last session successfully ended; If so, starts a new session, otherwise a dialogue window should prompt user to decide whether to continue the unfinished session or start a new session.
After the
db_loggerhas been successfully setup, the information of the instrument attached with this computer (fetched bydb_logger) will be passed tofilewatcher. Thentimeloopthread will start to syncing the instrument outputs to the cloud storage.
- switch_gui_to_end()[source]
actions by the start of ending.
put off
running_frame; putupsetup_frame, diable buttons
- class nexuslims_logger.gui.ScreenRes(logger=None)[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
nexuslims_logger.instrument module
- class nexuslims_logger.instrument.GCPInstrument(output_dir, bucket_name, bucket_dir, credentials, project=None, logger=None)[source]
Bases:
nexuslims_logger.instrument.InstrumentMock an instrument with data stored in GCP.
nexuslims_logger.run module
nexuslims_logger.utils module
utility functions
- nexuslims_logger.utils.check_singleton()[source]
make sure only ONE instance of the program running.