def shutdown(): """Saves the data to disk.""" if parameters.filelock.own_lock(): parameters.user.write_to_file(filepath=parameters.userdatafile) config_parser.write_config(parameters.config, parameters.configfile) parameters.filelock.unlock() else: backupfile = parameters.userdatafile + ".backup" parameters.user.write_to_file(filepath=backupfile) logger.warning(_("Not owning the file lock. Backing up the data to %s"), backupfile) logging.shutdown()
def shutdown(): """Saves the data to disk.""" if parameters.filelock.own_lock(): parameters.user.write_to_file(filepath=parameters.userdatafile) config_parser.write_config(parameters.config, parameters.configfile) parameters.filelock.unlock() else: backupfile = parameters.userdatafile + '.backup' parameters.user.write_to_file(filepath=backupfile) logger.warning( _('Not owning the file lock. Backing up the data to %s'), backupfile) logging.shutdown()
def _set_datafilepath(filepath): """Updates the path to the file containing the weight data.""" filepath = os.path.expanduser(filepath) if not os.path.isabs(filepath): filepath = os.path.join(os.getcwd(), filepath) if not os.path.isdir(filepath): logger.info(_("Reading file %s"), filepath) parameters.userdatafile = filepath parameters.use_custom_file = True return else: logger.warning(_("You passed a directory, not a file!")) logger.warning(_("Using the standard file ~/.pondus/user_data.xml instead."))
def import_mpl(): """Tests availability of matplotlib and enables plotting, if possible.""" try: from matplotlib import dates except ImportError: logger.warning( \ _('python-matplotlib is not installed, plotting disabled!')) else: parameters.have_mpl = True # speed up opening of plot dialog by importing it here global PlotDialog if PlotDialog is None: from pondus.gui.dialog_plot import PlotDialog # enable plot action in main window mainwindow.set_plot_action_active() # set correct tooltip on plotbutton mainwindow.plotbutton.set_tooltip_text(_('Plot weight data'))