def main(args): """ args is the list of arguments passed """ # arguments handling parser = argparse.ArgumentParser(prog="odemis-cli", description=odemis.__fullname__) parser.add_argument('--version', dest="version", action='store_true', help="show program's version number and exit") parser.add_argument('--standalone', dest="standalone", action='store_true', default=False, help="just display simple interface, " "without trying to connect to the back-end") parser.add_argument("--log-level", dest="loglev", metavar="<level>", type=int, default=0, help="set verbosity level (0-2, default = 0)") options = parser.parse_args(args[1:]) # Cannot use the internal feature, because it doesn't support multiline if options.version: print (odemis.__fullname__ + " " + odemis.__version__ + "\n" + odemis.__copyright__ + "\n" + "Licensed under the " + odemis.__license__) return 0 # Set up logging before everything else if options.loglev < 0: parser.error("log-level must be positive.") loglev_names = [logging.WARNING, logging.INFO, logging.DEBUG] loglev = loglev_names[min(len(loglev_names) - 1, options.loglev)] log.init_logger(loglev) if 'linux' in sys.platform: # Set WM_CLASS on linux, needed to get connected to the right icon. # wxPython doesn't do it, see http://trac.wxwidgets.org/ticket/12778 try: # Also possible via Xlib, but more complicated import gtk # without it, it will crash cf https://groups.google.com/forum/#!topic/wxpython-users/KO_hmLxeDKA gtk.remove_log_handlers() # Must be done before the first window is displayed name = "Odemis" if options.standalone: name += "-standalone" gtk.gdk.set_program_class(name) except Exception: logging.info("Failed to set WM_CLASS") # Create application app = OdemisGUIApp(standalone=options.standalone) # Change exception hook so unexpected exception # get caught by the logger backup_excepthook, sys.excepthook = sys.excepthook, app.excepthook # Start the application app.MainLoop() app.Destroy() sys.excepthook = backup_excepthook
def run(flavor): args = sys.argv # arguments handling parser = argparse.ArgumentParser(prog="odemis-viewer", description=odemis.__fullname__) # nargs="?" to allow to pass just -f without argument, for the Linux desktop # file to work easily. parser.add_argument('-f', '--file', dest="file_name", nargs="?", default=None, help="File to display") parser.add_argument("--log-level", dest="loglev", metavar="<level>", type=int, default=0, help="set verbosity level (0-2, default = 0)") options = parser.parse_args(args[1:]) # Set up logging before everything else if options.loglev < 0: parser.error("log-level must be positive.") installThreadExcepthook() loglev_names = [logging.WARNING, logging.INFO, logging.DEBUG] loglev = loglev_names[min(len(loglev_names) - 1, options.loglev)] log.init_logger(loglev) app = OdemisGUIApp(standalone=flavor, file_name=options.file_name) # Change exception hook so unexpected exception # get caught by the logger backup_excepthook, sys.excepthook = sys.excepthook, app.excepthook # Start the application app.MainLoop() app.Destroy() sys.excepthook = backup_excepthook
def main(args): """ args is the list of arguments passed """ # HACK: odemis.model sets it at 16, because some hardware components needs # a lot of simultaneous connections. One the client side, there is almost # no server created, so it's useless... excepted for the callback of # RemoteFutures (corresponding to actuator moves). But even in such case, # 1 connection should be enough in every case. To be safe, we set it to 2. # That helps to reduce memory usage. Pyro4.config.THREADPOOL_MINTHREADS = 2 # arguments handling parser = argparse.ArgumentParser(prog="odemis-gui", description=odemis.__fullname__) # nargs="?" to allow to pass just -f without argument, for the Linux desktop # file to work easily. parser.add_argument('-f', '--file', dest="file_name", nargs="?", default=None, help="File to display") parser.add_argument('--version', dest="version", action='store_true', help="show program's version number and exit") parser.add_argument('--standalone', dest="standalone", action='store_true', default=False, help="just display simple interface, " "without trying to connect to the back-end") parser.add_argument("--log-level", dest="loglev", metavar="<level>", type=int, default=0, help="set verbosity level (0-2, default = 0)") parser.add_argument('--log-target', dest='logtarget', help="Location of the GUI log file") options = parser.parse_args(args[1:]) # Cannot use the internal feature, because it doesn't support multiline if options.version: print(odemis.__fullname__ + " " + odemis.__version__ + "\n" + odemis.__copyright__ + "\n" + "Licensed under the " + odemis.__license__) return 0 # Set up logging before everything else if options.loglev < 0: parser.error("log-level must be positive.") loglev_names = [logging.WARNING, logging.INFO, logging.DEBUG] loglev = loglev_names[min(len(loglev_names) - 1, options.loglev)] log.init_logger(loglev, options.logtarget) if 'linux' in sys.platform: # Set WM_CLASS on linux, needed to get connected to the right icon. # wxPython doesn't do it, see http://trac.wxwidgets.org/ticket/12778 try: import gi from gi.repository import GLib # Must be done before the first window is displayed name = odemis.__shortname__ if options.standalone: name += "-standalone" GLib.set_prgname(name) except Exception: logging.info("Failed to set WM_CLASS") logging.info("\n\n************ Starting Odemis GUI ************\n") logging.info("Odemis GUI v%s (from %s) using Python %d.%d", odemis.__version__, __file__, sys.version_info[0], sys.version_info[1]) logging.info("wxPython v%s", wx.version()) if wx.MAJOR_VERSION <= 3: logging.error("wxPython 3 is not supported anymore") app = wx.App() wx.MessageBox("Your system is using an old version of wxPython (%s) which is not supported anymore.\n" "Please update with \"sudo apt install python3-wxgtk4.0\"." % (wx.version(),), "Library needs to be updated", style=wx.OK | wx.ICON_ERROR) return 129 # Create application app = OdemisGUIApp(standalone=options.standalone, file_name=options.file_name) # Change exception hook so unexpected exception get caught by the logger, # and warnings are shown as warnings in the log. backup_excepthook, sys.excepthook = sys.excepthook, app.excepthook warnings.showwarning = app.showwarning # Start the application app.MainLoop() app.Destroy() sys.excepthook = backup_excepthook
def main(args): """ args is the list of arguments passed """ # HACK: odemis.model sets it at 16, because some hardware components needs # a lot of simultaneous connections. One the client side, there is almost # no server created, so it's useless... excepted for the callback of # RemoteFutures (corresponding to actuator moves). But even in such case, # 1 connection should be enough in every case. To be safe, we set it to 2. # That helps to reduce memory usage. Pyro4.config.THREADPOOL_MINTHREADS = 2 # arguments handling parser = argparse.ArgumentParser(prog="odemis-gui", description=odemis.__fullname__) # nargs="?" to allow to pass just -f without argument, for the Linux desktop # file to work easily. parser.add_argument('-f', '--file', dest="file_name", nargs="?", default=None, help="File to display") parser.add_argument('--version', dest="version", action='store_true', help="show program's version number and exit") parser.add_argument('--standalone', dest="standalone", action='store_true', default=False, help="just display simple interface, " "without trying to connect to the back-end") parser.add_argument("--log-level", dest="loglev", metavar="<level>", type=int, default=0, help="set verbosity level (0-2, default = 0)") parser.add_argument('--log-target', dest='logtarget', help="Location of the GUI log file") options = parser.parse_args(args[1:]) # Cannot use the internal feature, because it doesn't support multiline if options.version: print(odemis.__fullname__ + " " + odemis.__version__ + "\n" + odemis.__copyright__ + "\n" + "Licensed under the " + odemis.__license__) return 0 # Set up logging before everything else if options.loglev < 0: parser.error("log-level must be positive.") loglev_names = [logging.WARNING, logging.INFO, logging.DEBUG] loglev = loglev_names[min(len(loglev_names) - 1, options.loglev)] log.init_logger(loglev, options.logtarget) if 'linux' in sys.platform: # Set WM_CLASS on linux, needed to get connected to the right icon. # wxPython doesn't do it, see http://trac.wxwidgets.org/ticket/12778 try: import gi from gi.repository import GLib # Must be done before the first window is displayed name = odemis.__shortname__ if options.standalone: name += "-standalone" GLib.set_prgname(name) except Exception: logging.info("Failed to set WM_CLASS") # Create application app = OdemisGUIApp(standalone=options.standalone, file_name=options.file_name) # Change exception hook so unexpected exception get caught by the logger, # and warnings are shown as warnings in the log. backup_excepthook, sys.excepthook = sys.excepthook, app.excepthook warnings.showwarning = app.showwarning # Start the application app.MainLoop() app.Destroy() sys.excepthook = backup_excepthook
Odemis is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Odemis. If not, see http://www.gnu.org/licenses/. """ import logging from odemis.gui import test, log import random import threading import unittest log.init_logger(logging.DEBUG) test.goto_manual() LOG_FUNCTIONS = (logging.debug, logging.info, logging.warn, logging.error, logging.exception) class TestLogWindow(test.GuiTestCase): frame_class = test.test_gui.xrclog_frame frame_size = (800, 200) def test_log_window(self): log.create_gui_logger(self.frame.txt_log) def log_msg(): for i in xrange(50000):
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Odemis. If not, see http://www.gnu.org/licenses/. """ import logging from odemis.gui import test, log import random import threading import unittest log.init_logger(logging.DEBUG) test.goto_manual() LOG_FUNCTIONS = (logging.debug, logging.info, logging.warn, logging.error, logging.exception) class TestLogWindow(test.GuiTestCase): frame_class = test.test_gui.xrclog_frame frame_size = (800, 200) def test_log_window(self): log.create_gui_logger(self.frame.txt_log) def log_msg(): for i in xrange(50000): random.choice(LOG_FUNCTIONS)("WEEEEEE %d" % i)