Beispiel #1
0
    def __init__(self, glade_file, initial_widget_names=[]):
        """
        Creates a new tab widget, given the specified glade file and a list of
        widget names to extract to instance variables.
        """
        # Mix the specified widgets with standard names in the
        # glade file by convention
        super(SubscriptionManagerTab, self).__init__(glade_file)
        self.content.unparent()

        # grid lines seem busted in rhel5, so we disable
        # in glade and turn on here for unbroken versions
        if gtk.check_version(self.MIN_GTK_MAJOR_GRID,
                             self.MIN_GTK_MINOR_GRID,
                             self.MIN_GTK_MICRO_GRID) is None:
            self.top_view.set_enable_tree_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)

        self.store = self.get_store()
        self.top_view.set_model(self.store)

        selection = self.top_view.get_selection()
        selection.connect('changed', self._selection_callback)

        def on_cert_update(filemonitor):
            self._set_next_update()

        # For updating the 'Next Update' time
        file_monitor.Monitor(UPDATE_FILE).connect('changed', on_cert_update)
    def __init__(self, glade_file):
        """
        Creates a new tab widget, given the specified glade file and a list of
        widget names to extract to instance variables.
        """
        # Mix the specified widgets with standard names in the
        # glade file by convention
        super(SubscriptionManagerTab, self).__init__(glade_file)
        self.content.unparent()

        # In the allsubs tab, we don't show the treeview until it is populated
        if self.top_view is None:
            self.top_view = gtk.TreeView()

        # grid lines seem busted in rhel5, so we disable
        # in glade and turn on here for unbroken versions
        if gtk.check_version(self.MIN_GTK_MAJOR_GRID,
                             self.MIN_GTK_MINOR_GRID,
                             self.MIN_GTK_MICRO_GRID) is None:
            self.top_view.set_enable_tree_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)

        self.store = self.get_store()
        self.top_view.set_model(self.store)

        selection = self.top_view.get_selection()
        selection.connect('changed', self._selection_callback)
Beispiel #3
0
    def __init__(self, glade_file):
        """
        Creates a new tab widget, given the specified glade file and a list of
        widget names to extract to instance variables.
        """
        # Mix the specified widgets with standard names in the
        # glade file by convention
        super(SubscriptionManagerTab, self).__init__(glade_file)
        self.content.unparent()

        # In the allsubs tab, we don't show the treeview until it is populated
        if self.top_view is None:
            self.top_view = gtk.TreeView()

        # grid lines seem busted in rhel5, so we disable
        # in glade and turn on here for unbroken versions
        if gtk.check_version(self.MIN_GTK_MAJOR_GRID, self.MIN_GTK_MINOR_GRID,
                             self.MIN_GTK_MICRO_GRID) is None:
            self.top_view.set_enable_tree_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)

        self.store = self.get_store()
        self.top_view.set_model(self.store)

        selection = self.top_view.get_selection()
        selection.connect('changed', self._selection_callback)
Beispiel #4
0
 def __create_trayicon(self):
     if gtk.check_version(2, 10, 0) is not None:
         log.debug("Disabled Tray Icon. It needs PyGTK >= 2.10.0")
         return
     self.tray = gtk.StatusIcon()
     self.tray.set_from_pixbuf(self.load_image('turpial-tray.png', True))
     self.tray.set_tooltip('Turpial')
     self.tray.connect("activate", self.__on_trayicon_click)
     self.tray.connect("popup-menu", self.__show_tray_menu)
Beispiel #5
0
 def __create_trayicon(self):
     if gtk.check_version(2, 10, 0) is not None:
         self.log.debug("Disabled Tray Icon. It needs PyGTK >= 2.10.0")
         return
     self.tray = gtk.StatusIcon()
     self.tray.set_from_pixbuf(self.load_image('turpial_icon.png', True))
     self.tray.set_tooltip('Turpial')
     self.tray.connect("activate", self.__on_trayicon_click)
     self.tray.connect("popup-menu", self.__show_tray_menu)
 def __create_trayicon(self):
     if gtk.check_version(2, 10, 0) is not None:
         self.log.debug("Disabled Tray Icon. It needs PyGTK >= 2.10.0")
         return
     self.tray = gtk.StatusIcon()
     self.tray.set_from_file(os.path.join(self.img_path,'gmediafinder.png'))
     self.tray.set_tooltip('Gmediafinder')
     self.tray.connect("activate", self.__on_trayicon_click)
     self.tray.connect("popup-menu", self.__show_tray_menu)
class TestLinkify(unittest.TestCase):
    no_url = "this does not have a url"
    https_url = "https://www.redhat.com"
    http_url = "http://www.redhat.com"
    expected_http_url = """<a href="%s">%s</a>""" % (http_url, http_url)
    expected_https_url = """<a href="%s">%s</a>""" % (https_url, https_url)

    http_url_dash = "http://example.com/something-foo/blah_something/"
    expected_http_url_dash = """<a href="%s">%s</a>""" % (http_url_dash,
                                                          http_url_dash)

    nested_space = """<small>http://www.redhat.com </small>"""
    nested = """<small>http://www.redhat.com</small>"""
    expected_nested = """<small><a href="%s">%s</a></small>""" % (http_url,
                                                                  http_url)
    expected_nested_space = """<small><a href="%s">%s</a> </small>""" % (
        http_url, http_url)

    example_1 = """https://access.redhat.com/kb/docs/DOC-45563"""
    example_2 = """https://www.redhat.com/wapps/sso/rhn/lostPassword.html"""
    expected_example_1 = """<a href="%s">%s</a>""" % (example_1, example_1)
    expected_example_2 = """<a href="%s">%s</a>""" % (example_2, example_2)

    if gtk.check_version(MIN_GTK_MAJOR, MIN_GTK_MINOR, MIN_GTK_MICRO):
        __test__ = False

    def test_no_url(self):
        ret = utils.linkify(self.no_url)
        self.assertEquals(ret, self.no_url)

    def test_https_url(self):
        ret = utils.linkify(self.https_url)
        self.assertEquals(ret, self.expected_https_url)

    def test_http_url(self):
        ret = utils.linkify(self.http_url)
        self.assertEquals(ret, self.expected_http_url)

    def test_http_nested_space(self):
        ret = utils.linkify(self.nested_space)
        self.assertEquals(ret, self.expected_nested_space)

    def test_nested(self):
        ret = utils.linkify(self.nested)
        self.assertEquals(ret, self.expected_nested)

    def test_dash(self):
        ret = utils.linkify(self.http_url_dash)
        self.assertEquals(ret, self.expected_http_url_dash)

    def test_example_1(self):
        ret = utils.linkify(self.example_1)
        self.assertEquals(ret, self.expected_example_1)

    def test_example_2(self):
        ret = utils.linkify(self.example_2)
        self.assertEquals(ret, self.expected_example_2)
Beispiel #8
0
def linkify(msg):
    """
    Parse a string for any urls and wrap them in a hrefs, for use in a
    gtklabel.
    """
    # http (non whitespace or . or
    #  ? or () or - or / or ;
    url_regex = re.compile("""https?://[\w\.\?\(\)\-\/]*""")

    if gtk.check_version(MIN_GTK_MAJOR, MIN_GTK_MINOR, MIN_GTK_MICRO):
        return msg

    def add_markup(mo):
        url = mo.group(0)
        return '<a href="%s">%s</a>' % (url, url)

    return url_regex.sub(add_markup, msg)
Beispiel #9
0
def linkify(msg):
    """
    Parse a string for any urls and wrap them in a hrefs, for use in a
    gtklabel.
    """
    # http (non whitespace or . or
    #  ? or () or - or / or ;
    url_regex = re.compile("""https?://[\w\.\?\(\)\-\/]*""")

    if gtk.check_version(MIN_GTK_MAJOR, MIN_GTK_MINOR, MIN_GTK_MICRO):
        return msg

    def add_markup(mo):
        url = mo.group(0)
        return '<a href="%s">%s</a>' % (url, url)

    return url_regex.sub(add_markup, msg)
Beispiel #10
0
    def make_info_dialog(self):
        # type: () -> gtk.MessageDialog
        """Initialize and return the top-level dialog"""

        # pylint: disable=no-member
        dialog = gtk.MessageDialog(parent=None,
                                   flags=0,
                                   type=gtk.MESSAGE_WARNING,
                                   buttons=gtk.BUTTONS_NONE)
        dialog.set_title(_("Bug Detected"))
        if gtk.check_version(2, 4, 0) is not None:
            dialog.set_has_separator(False)

        primary = _("<big><b>A programming error has been detected during the "
                    "execution of this program.</b></big>")
        secondary = _("It probably isn't fatal, but should be reported to the "
                      "developers nonetheless.")

        if self.email:
            dialog.add_button(_("Report..."), 3)
        else:
            secondary += _("\n\nPlease remember to include the contents of "
                           "the Details dialog.")
        try:
            setsec = dialog.format_secondary_text
        except AttributeError:
            raise
            # TODO
            # dialog.vbox.get_children()[0].get_children()[1].set_markup(
            #    '%s\n\n%s' % (primary, secondary))
            # lbl.set_property("use-markup", True)
        else:
            del setsec
            dialog.set_markup(primary)
            dialog.format_secondary_text(secondary)

        dialog.add_button(_("Details..."), 2)
        dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
        dialog.add_button(gtk.STOCK_QUIT, 1)

        return dialog
Beispiel #11
0
    def make_info_dialog(self):
        # type: () -> gtk.MessageDialog
        """Initialize and return the top-level dialog"""

        # pylint: disable=no-member
        dialog = gtk.MessageDialog(parent=None, flags=0,
                                   type=gtk.MESSAGE_WARNING,
                                   buttons=gtk.BUTTONS_NONE)
        dialog.set_title(_("Bug Detected"))
        if gtk.check_version(2, 4, 0) is not None:
            dialog.set_has_separator(False)

        primary = _("<big><b>A programming error has been detected during the "
                    "execution of this program.</b></big>")
        secondary = _("It probably isn't fatal, but should be reported to the "
                      "developers nonetheless.")

        if self.email:
            dialog.add_button(_("Report..."), 3)
        else:
            secondary += _("\n\nPlease remember to include the contents of "
                           "the Details dialog.")
        try:
            setsec = dialog.format_secondary_text
        except AttributeError:
            raise
            # TODO
            # dialog.vbox.get_children()[0].get_children()[1].set_markup(
            #    '%s\n\n%s' % (primary, secondary))
            # lbl.set_property("use-markup", True)
        else:
            del setsec
            dialog.set_markup(primary)
            dialog.format_secondary_text(secondary)

        dialog.add_button(_("Details..."), 2)
        dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
        dialog.add_button(gtk.STOCK_QUIT, 1)

        return dialog
Beispiel #12
0
def _gtkexcepthook(exception_type, instance, traceback):
    """
    Display a GTK dialog informing the user that an unhandled
    exception has occurred.  Log the exception and provide the
    option to continue or quit.

    TODO: Should have a way to report bugs.
    """
    trace_log = trace = analyse(exception_type, instance, traceback)
    
    log = logging.getLogger("gtkexcepthook")
    log.error("%s caught.  Traceback follows \n%s" % 
        (exception_type, trace_log.getvalue()))
    
    dialog = gtk.MessageDialog(
        parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE)
    dialog.set_title("")
    
    # TODO: is this needed?
    if gtk.check_version (2, 4, 0) is not None:
        dialog.set_has_separator (False)

    primary = "<big><b>An unhandled exception has been logged.</b></big>"
    secondary = "It may be possible to continue normally, or you may choose to exit NoStaples and restart."

    dialog.set_markup(primary)
    dialog.format_secondary_text(secondary)

    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button(gtk.STOCK_QUIT, 1)

    response = dialog.run()
    
    if response == 1 and gtk.main_level() > 0:
        gtk.main_quit()
    else:
        pass
    
    dialog.destroy()
Beispiel #13
0
def front_end(no_interp=None):
    global startupfiles
    global gtk_options
    global randomseed
    ## From here on is the serial version.

    # When loading modules, use utils.OOFexec so that names are
    # imported into the oof environment, not the oof.run environment.
    if not (runtimeflags.text_mode or config.no_gui()):
        # The gtk import dance described below doesn't work when the program
        # has been packaged by cx_freeze.
        # TODO LATER: is checking frozen required for gtk2?
        frozen = hasattr(sys, 'frozen')
        if not frozen:
            import pygtk
            pygtk.require("2.0")
            import gtk
            msg = gtk.check_version(2, 6, 0)
            if msg:
                print msg
                sys.exit(3)

        import ooflib.common.IO.GUI.initialize
        # temporarily disable the engine, tutorials, orientationmap
        # for 3D development
        import ooflib.engine.IO.GUI.initialize
        import ooflib.image.IO.GUI.initialize
        if config.dimension() == 2:
            import ooflib.orientationmap.GUI.initialize
            import ooflib.tutorials.initialize
        if replaydelay is not None:
            from ooflib.common.IO.GUI import gtklogger
            gtklogger.set_delay(int(replaydelay))
    else:  # text mode
        import ooflib.common.initialize
        import ooflib.engine.initialize
        import ooflib.image.initialize
        if config.dimension() == 2:
            import ooflib.orientationmap.initialize
    import ooflib.EXTENSIONS.initialize

    # The random number generator must be seeded *after* the gui has
    # been started, because libfontconfig is using random numbers.  We
    # want the numbers to be the same in text and gui modes, so that
    # the test suite gets predictable answers.
    if debug.debug() or randomseed is not None:
        if randomseed is None:
            randomseed = 17
        random.seed(randomseed)
        crandom.rndmseed(randomseed)

    for module in startupimports:
        exec('import ' + module)

    if not (runtimeflags.text_mode or config.no_gui()):
        reporter.report("Welcome to OOF2 version %s!" % oofversion.version)
        ## The files to be loaded must be loaded *after* the GUI
        ## starts, but this routine doesn't regain control once it
        ## starts the GUI. So we have to install the file loader
        ## (loadStartUpFiles) as an idle callback, which will run on
        ## the main thread.  loadStartUpFiles just issues menu
        ## commands that load the files, and if it runs on the main
        ## thread those menu commands will run by Workers on
        ## subthreads, and won't be run sequentially.  So, instead of
        ## installing loadStartUpFiles as an idle callback, we install
        ## subthread.execute and have it call loadStartUpFiles, since
        ## workers on subthreads don't create additional subthreads to
        ## run their menu items.
        if startupfiles:
            # startupfiles won't be run until after the GUI starts.
            mainthread.run(subthread.execute_immortal,
                           (loadStartUpFiles, (startupfiles, )))
        if not no_interp:  # Default case, run on local thread.
            from ooflib.common.IO.GUI import oofGUI
            oofGUI.start()  # This call never returns.
            print "This line should never be printed.  rank =", _rank
        else:
            # TODO LATER: The gui and no_interp combination is
            # thinkable, but has problems.  You have to run the GUI on
            # a separate thread, but then exceptions show up as modal
            # dialog boxes in the GUI, and block the menu items which
            # raised them, causing a loss of control.  Also, the
            # current threading scheme requires that all gtk activity
            # happen on the main thread.
            print "GUI no_interp mode not implemented.  Sorry."
            raise NotImplementedError("GUI no_interp mode")

    else:  # text mode
        from ooflib.common import quit
        # Allow exceptions to propagate to the user if in batch mode
        # or not running an interpreter.  Otherwise, exceptions are
        # caught and reported to the user, but the program keeps
        # running.
        if runtimeflags.batch_mode or no_interp:
            from ooflib.common import worker
            worker.propagate_exceptions = True
        if startupfiles:
            loadStartUpFiles(startupfiles)
            if runtimeflags.batch_mode:
                # Batch mode runs startupfiles and quits immediately.
                quit.set_quiet()
                quit.quit()
                if sys.exc_info()[0] is not None:
                    sys.exit(1)
                sys.exit(0)
        # Format the banner for the current line width.
        if not quit.quiet():
            width = utils.screenwidth()
            wiggles = "//=*=\\\\=*="
            nwiggles = (width - 2) / len(wiggles)
            welcome = "Welcome to OOF2 version %s!" % oofversion.version
            nblanks = (width - len(welcome)) / 2
            banner = wiggles*nwiggles + "//\n\n" \
                     + " "*nblanks + welcome + "\n" + \
                     string.join(utils.format(banner1, width),"\n") + \
                     "\n\n" +  wiggles*nwiggles + "//\n" + \
                     string.join(utils.format(banner2, width), "\n")
        else:
            banner = ""

        if not no_interp:
            import code
            # Try to import readline, which allows command line
            # editing in text mode.  If it's not there, don't worry --
            # it's possible to live without it.  Some systems don't
            # seem to have it, although it's supposedly available on
            # all Unix systems.
            try:
                import readline
            except ImportError:
                pass
            # Start up the interpreter in the __main__ namespace.
            # This is the namespace that utils.OOFeval and OOFdefine
            # use.  It's not necessarily *this* namespace.
            interp = code.InteractiveConsole(sys.modules['__main__'].__dict__)
            interp.interact(banner)
Beispiel #14
0
def front_end(no_interp=None):
    global startupfiles
    global gtk_options
    global randomseed
    ## From here on is the serial version.

    # VTK is started even in text mode to allow off-screen rendering,
    # interpretation of scripted mouse clicks, etc.
    from ooflib.SWIG.common.IO import vtkutils
    vtkutils.initialize_vtk()

    # When loading modules, use utils.OOFexec so that names are
    # imported into the oof environment, not the oof.run environment.
    if not (runtimeflags.text_mode or config.no_gui()):
        # The gtk import dance described below doesn't work when the program
        # has been packaged by cx_freeze.
        # TODO 3.1: is checking frozen required for gtk2?
        frozen = hasattr(sys, 'frozen')
        if not frozen:
            import pygtk
            pygtk.require("2.0")
            import gtk
            msg = gtk.check_version(2, 6, 0)
            if msg:
                print msg
                sys.exit(3)

        # The GUI initialization modules must be called before any
        # calls to mainthread.run(), because mainthread.run() is
        # redefined when mainthreadGUI.py is loaded (by
        # common/IO/GUI/initialize.py)
        import ooflib.common.IO.GUI.initialize
        import ooflib.engine.IO.GUI.initialize
        import ooflib.image.IO.GUI.initialize
        import ooflib.orientationmap.GUI.initialize
        import ooflib.tutorials.initialize

        if replaydelay is not None:
            from ooflib.common.IO.GUI import gtklogger
            gtklogger.set_delay(int(replaydelay))
    else:  # text mode
        # Load non-gui initialization modules.
        import ooflib.common.initialize
        import ooflib.engine.initialize
        import ooflib.image.initialize
        import ooflib.orientationmap.initialize

    import ooflib.EXTENSIONS.initialize

    # The random number generator must be seeded *after* the gui has
    # been started, because libfontconfig is using random numbers.  We
    # want the numbers to be the same in text and gui modes, so that
    # the test suite gets predictable answers.
    if debug.debug() or randomseed is not None:
        if randomseed is None:
            randomseed = 17
        random.seed(randomseed)
        crandom.rndmseed(randomseed)

    for module in startupimports:
        exec('import ' + module)

    if not (runtimeflags.text_mode or config.no_gui()):
        reporter.report("Welcome to %s version %s!" %
                        (program_name.upper(), oofversion.version))
        if not no_interp:  # Default case, run on local thread.
            from ooflib.common.IO.GUI import oofGUI
            oofGUI.start(files=startupfiles)  # This call never returns.
            print "This line should never be printed.  rank =", _rank
        else:
            # TODO 3.1: The gui and no_interp combination is
            # thinkable, but has problems.  You have to run the GUI on
            # a separate thread, but then exceptions show up as modal
            # dialog boxes in the GUI, and block the menu items which
            # raised them, causing a loss of control.  Also, the
            # current threading scheme requires that all gtk activity
            # happen on the main thread.
            print "GUI no_interp mode not implemented.  Sorry."
            raise NotImplementedError("GUI no_interp mode")

    else:  # text mode
        from ooflib.common import quit
        # Allow exceptions to propagate to the user if in batch mode
        # or not running an interpreter.  Otherwise, exceptions are
        # caught and reported to the user, but the program keeps
        # running.
        if runtimeflags.batch_mode or no_interp:
            from ooflib.common import worker
            worker.propagate_exceptions = True

        threadstate.textMode()
        lock.disableLocks()  # disables Locks, but not SLocks

        if startupfiles:
            loadStartUpFiles(startupfiles)
            if runtimeflags.batch_mode:
                # Batch mode runs startupfiles and quits immediately.
                quit.set_quiet()
                quit.quit()
                if sys.exc_info()[0] is not None:
                    sys.exit(1)
                sys.exit(0)
        # Format the banner for the current line width.
        if not quit.quiet():
            width = utils.screenwidth()
            wiggles = "//=*=\\\\=*="
            nwiggles = (width - 2) / len(wiggles)
            welcome = "Welcome to %s version %s!" % (program_name.upper(),
                                                     oofversion.version)
            nblanks = (width - len(welcome)) / 2
            banner = (
                wiggles * nwiggles + "//\n\n" + " " * nblanks + welcome +
                "\n" + string.join(
                    utils.format(banner1 % {'name': program_name.upper()},
                                 width), "\n") + "\n\n" + wiggles * nwiggles +
                "//\n" + string.join(
                    utils.format(banner2 % {'name': program_name.upper()},
                                 width), "\n"))
        else:
            banner = ""

        if not no_interp:
            import code
            # Try to import readline, which allows command line
            # editing in text mode.  If it's not there, don't worry --
            # it's possible to live without it.  Some systems don't
            # seem to have it, although it's supposedly available on
            # all Unix systems.
            try:
                import readline
            except ImportError:
                pass
            # Start up the interpreter in the __main__ namespace.
            # This is the namespace that utils.OOFeval and OOFdefine
            # use.  It's not necessarily *this* namespace.
            interp = code.InteractiveConsole(sys.modules['__main__'].__dict__)
            interp.interact(banner)
Beispiel #15
0
def main():
    # pylint: disable-msg=R0912, R0914, R0915
    # lots of different cases to consider, so long and has lots of variables
    # and if statement
    """Start the Sutekh Gui.

       Check that database exists, doesn't need to be upgraded, then
       pass control off to SutekhMainWindow
       Save preferences on exit if needed
       """
    # Print nice complaint if not under a windowing system
    if gtk.gdk.screen_get_default() is None:
        print "Unable to find windowing system. Aborting"
        return 1
    # handle exceptions with a GUI dialog
    sys.excepthook = exception_handler

    # Disable Unity's moving of menubars to the appmenu at
    # the top of the screen since this moves the panel menus
    # into limbo.
    # TODO: we should only disable this on the panel menus
    os.environ["UBUNTU_MENUPROXY"] = "0"

    oOptParser, (oOpts, aArgs) = parse_options(sys.argv)
    sPrefsDir = prefs_dir("Sutekh")

    if len(aArgs) != 1:
        oOptParser.print_help()
        return 1

    if oOpts.sRCFile is None:
        ensure_dir_exists(sPrefsDir)
        oOpts.sRCFile = os.path.join(sPrefsDir, "sutekh.ini")

    oConfig = ConfigFile(oOpts.sRCFile)
    # initial config validation to set sane defaults
    # (re-validated later after plugins are loaded)
    oConfig.validate()

    if not oConfig.check_writeable():
        # Warn the user
        iRes = do_complaint_warning('Unable to write to the config file %s.\n'
                'Config changes will NOT be saved.\n'
                'Do you wish to continue?' % oOpts.sRCFile)
        if iRes == gtk.RESPONSE_CANCEL:
            return 1

    if oOpts.db is None:
        oOpts.db = oConfig.get_database_uri()

    if oOpts.db is None:
        # No commandline + no rc entry
        ensure_dir_exists(sPrefsDir)
        oOpts.db = sqlite_uri(os.path.join(sPrefsDir, "sutekh.db?cache=False"))
        oConfig.set_database_uri(oOpts.db)

    oConn = connectionForURI(oOpts.db)
    sqlhub.processConnection = oConn

    if oOpts.sql_debug:
        oConn.debug = True

    # Check we have the correct gtk version
    sMessage = gtk.check_version(2, 16, 0)
    if sMessage is not None:
        do_complaint_error('Incorrect gtk version. Sutekh requires at least'
                ' gtk 2.16.0.\nError reported %s' % sMessage)
        return 1

    # construct Window
    oMainWindow = SutekhMainWindow()

    # Test on some tables where we specify the table name
    if not oConn.tableExists('abstract_card') or \
            not oConn.tableExists('physical_map'):
        if not initialize_db(oMainWindow):
            return 1

    aTables = [VersionTable] + TABLE_LIST
    aVersions = []

    for oTable in aTables:
        aVersions.append(oTable.tableversion)

    oVer = DatabaseVersion()

    if not oVer.check_tables_and_versions(aTables, aVersions) and \
            not oOpts.ignore_db_version:
        aLowerTables, aHigherTables = oVer.get_bad_tables(aTables, aVersions)
        if not do_db_upgrade(aLowerTables, aHigherTables):
            return 1

    _oRootLogger = setup_logging(oOpts)

    oMainWindow.setup(oConfig)
    oMainWindow.run()

    # Save Config Changes
    try:
        oConfig.write()
    except IOError, oExp:
        sMesg = 'Unable to write the configuration file\n' \
                'Error was: %s' % oExp
        do_exception_complaint(sMesg)
Beispiel #16
0
def _info (exctyp, value, tb):
	trace = None
	dialog = gtk.MessageDialog (parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE)
	dialog.set_title (_("Bug Detected"))
	if gtk.check_version (2, 4, 0) is not None:
		dialog.set_has_separator (False)

	primary = _("<big><b>A programming error has been detected during the execution of this program.</b></big>")
	secondary = _("It probably isn't fatal, but should be reported to the developers nonetheless.")

	try:
		setsec = dialog.format_secondary_text
	except AttributeError:
		raise
		dialog.vbox.get_children()[0].get_children()[1].set_markup ('%s\n\n%s' % (primary, secondary))
		#lbl.set_property ("use-markup", True)
	else:
		del setsec
		dialog.set_markup (primary)
		dialog.format_secondary_text (secondary)

	dialog.add_button (_("Details..."), 2)
	dialog.add_button (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
	dialog.add_button (gtk.STOCK_QUIT, 1)

	while True:
		resp = dialog.run()
		if resp == 2:
			if trace == None:
				trace = analyse (exctyp, value, tb)

			# Show details...
			details = gtk.Dialog (_("Bug Details"), dialog,
			  gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
			  (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE, ))
			details.set_property ("has-separator", False)

			details.add_button("Save to file...", 3)
			textview = gtk.TextView(); textview.show()
			textview.set_editable (False)
			textview.modify_font (pango.FontDescription ("Monospace"))

			sw = gtk.ScrolledWindow(); sw.show()
			sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
			sw.add (textview)
			details.vbox.add (sw)
			textbuffer = textview.get_buffer()
			textbuffer.set_text (trace.getvalue())

			monitor = gtk.gdk.screen_get_default ().get_monitor_at_window (dialog.window)
			area = gtk.gdk.screen_get_default ().get_monitor_geometry (monitor)
			try:
				w = area.width // 1.6
				h = area.height // 1.6
			except SyntaxError:
				# python < 2.2
				w = area.width / 1.6
				h = area.height / 1.6
			details.set_default_size (int (w), int (h))

			detResp = details.run()
			if detResp != gtk.RESPONSE_CLOSE:
				saveStackTrace(trace.getvalue())

			details.destroy()

		elif resp == 1 and gtk.main_level() > 0:
			gtk.main_quit()
			break
		else:
			break

	dialog.destroy()
Beispiel #17
0
def _info(exctyp, value, tb):
    trace = None
    dialog = gtk.MessageDialog(parent=None,
                               flags=0,
                               type=gtk.MESSAGE_WARNING,
                               buttons=gtk.BUTTONS_NONE)
    dialog.set_title(_("Bug Detected"))
    if gtk.check_version(2, 4, 0) is not None:
        dialog.set_has_separator(False)

    primary = _(
        "<big><b>A programming error has been detected during the execution of this program.</b></big>"
    )
    secondary = _(
        "It probably isn't fatal, but should be reported to the developers nonetheless."
    )

    try:
        setsec = dialog.format_secondary_text
    except AttributeError:
        raise
        dialog.vbox.get_children()[0].get_children()[1].set_markup(
            '%s\n\n%s' % (primary, secondary))
        #lbl.set_property ("use-markup", True)
    else:
        del setsec
        dialog.set_markup(primary)
        dialog.format_secondary_text(secondary)

    dialog.add_button(_("Details..."), 2)
    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button(gtk.STOCK_QUIT, 1)

    while True:
        resp = dialog.run()
        if resp == 2:
            if trace == None:
                trace = analyse(exctyp, value, tb)

            # Show details...
            details = gtk.Dialog(
                _("Bug Details"), dialog,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (
                    gtk.STOCK_CLOSE,
                    gtk.RESPONSE_CLOSE,
                ))
            details.set_property("has-separator", False)

            details.add_button("Save to file...", 3)
            textview = gtk.TextView()
            textview.show()
            textview.set_editable(False)
            textview.modify_font(pango.FontDescription("Monospace"))

            sw = gtk.ScrolledWindow()
            sw.show()
            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            sw.add(textview)
            details.vbox.add(sw)
            textbuffer = textview.get_buffer()
            textbuffer.set_text(trace.getvalue())

            monitor = gtk.gdk.screen_get_default().get_monitor_at_window(
                dialog.window)
            area = gtk.gdk.screen_get_default().get_monitor_geometry(monitor)
            try:
                w = area.width // 1.6
                h = area.height // 1.6
            except SyntaxError:
                # python < 2.2
                w = area.width / 1.6
                h = area.height / 1.6
            details.set_default_size(int(w), int(h))

            detResp = details.run()
            if detResp != gtk.RESPONSE_CLOSE:
                saveStackTrace(trace.getvalue())

            details.destroy()

        elif resp == 1 and gtk.main_level() > 0:
            gtk.main_quit()
            break
        else:
            break

    dialog.destroy()
'''
this is a part of the heybuddy project
copyright 2010 jezra lickter http://www.jezra.net
'''
import gtk
#this might be on Maemo
try:
	import hildon
	has_hildon = True
except:
	has_hildon = False

#the gtk version may not handle links
if gtk.check_version(2,18,0)!=None:
	links_unavailable=True
else:
	links_unavailable=False

def ScrollThingy() :
  if has_hildon:
    try:
      #this will only work on maemo5; f**k Nokia's shitty documentation
      the_scroll_thing = hildon.PannableArea()
    except:
      # a simple version check would be better, but the documentation is crap
      the_scroll_thing = gtk.ScrolledWindow()
      hildon.hildon_helper_set_thumb_scrollbar(the_scroll_thing, True)
      the_scroll_thing.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
      the_scroll_thing.set_shadow_type(gtk.SHADOW_NONE)
  else:
    the_scroll_thing = gtk.ScrolledWindow()
Beispiel #19
0
def _info(exctyp, value, tb):
    # First output the exception to stderr
    orig_excepthook(exctyp, value, tb)

    try:
        import pdb
    except ImportError:
        # py2exe
        pdb = None

    if exctyp is KeyboardInterrupt:
        sys.exit(1)
    trace = None
    dialog = gtk.MessageDialog(parent=None,
                               flags=0,
                               type=gtk.MESSAGE_WARNING,
                               buttons=gtk.BUTTONS_NONE)
    dialog.set_title(_("Bug Detected"))
    if gtk.check_version(2, 4, 0) is not None:
        dialog.set_has_separator(False)

    primary = _("<big><b>A programming error has been detected.</b></big>")
    secondary = _("Please report it by clicking the 'Report' button. Thanks!")

    dialog.set_markup(primary)
    dialog.format_secondary_text(secondary)

    dialog.add_button(_("Report..."), 3)

    dialog.add_button(_("Details..."), 2)
    if pdb:
        dialog.add_button(_("Debug..."), 4)
    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)

    while True:
        resp = dialog.run()
        if resp == 4:
            pdb.post_mortem(tb)

        if resp == 3:
            if trace == None:
                trace = analyse(exctyp, value, tb)

            bug_report(dialog, _gladefile, trace)

        elif resp == 2:
            if trace == None:
                trace = analyse(exctyp, value, tb)

            # Show details...
            details = gtk.Dialog(
                _("Bug Details"), dialog,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (
                    gtk.STOCK_CLOSE,
                    gtk.RESPONSE_CLOSE,
                ))
            details.set_property("has-separator", False)

            textview = gtk.TextView()
            textview.show()
            textview.set_editable(False)
            textview.modify_font(pango.FontDescription("Monospace"))

            sw = gtk.ScrolledWindow()
            sw.show()
            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            sw.add(textview)
            details.vbox.add(sw)
            textbuffer = textview.get_buffer()
            textbuffer.set_text(trace)

            monitor = gtk.gdk.screen_get_default().get_monitor_at_window(
                dialog.window)
            area = gtk.gdk.screen_get_default().get_monitor_geometry(monitor)
            w = area.width // 1.6
            h = area.height // 1.6
            details.set_default_size(int(w), int(h))

            details.run()
            details.destroy()

        else:
            break

    dialog.destroy()
Beispiel #20
0
def _info (exctyp, value, tb):
	if exctyp.__name__=='KeyboardInterrupt':
		sys.stderr.write ('%s: %s\n' % (exctyp.__name__, value))
		sys.exit(1)

	trace = None
	dialog = gtk.MessageDialog (parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE)
	dialog.set_title (_("Bug Detected"))
	if gtk.check_version (2, 4, 0) is not None:
		dialog.set_has_separator (False)

	primary = _("<big><b>A programming error has been detected during the execution of this program.</b></big>")
	secondary = _("It probably isn't fatal, but should be reported to the developers nonetheless.")

	try:
		setsec = dialog.format_secondary_text
	except AttributeError:
		raise
		dialog.vbox.get_children()[0].get_children()[1].set_markup ('%s\n\n%s' % (primary, secondary))
		#lbl.set_property ("use-markup", True)
	else:
		del setsec
		dialog.set_markup (primary)
		dialog.format_secondary_text (secondary)

	try:
		email = feedback
		dialog.add_button (_("Report..."), 3)
	except NameError:
		# could ask for an email address instead...
		pass
	dialog.add_button (_("Details..."), 2)
	dialog.add_button (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
	dialog.add_button (gtk.STOCK_QUIT, 1)
	dialog.add_button (_("Report Bug"),3)

	while True:
		resp = dialog.run()
		if resp == 3:
#if trace == None:
#				trace = analyse (exctyp, value, tb)

			# TODO: prettyprint, deal with problems in sending feedback, &tc
			handle = webbrowser.get()
			print dir(handle)
			handle.open("http://bugs.ascend4.org/bug_report_page.php")
			if trace == None:
				trace = analyse (exctyp, value, tb)
			print trace.getvalue()
			

#			try:
#				server = smtphost
#			except NameError:
#				server = 'localhost'
#
#			message = 'From: buggy_application"\nTo: bad_programmer\nSubject: Exception feedback\n\n%s' % trace.getvalue()
#
#			s = SMTP()
#			s.connect (server)
#			s.sendmail (email, (email,), message)
#			s.quit()
			break

		elif resp == 2:
			if trace == None:
				trace = analyse (exctyp, value, tb)

			# Show details...
			details = gtk.Dialog (_("Bug Details"), dialog,
			  gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
			  (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE, ))
			details.set_property ("has-separator", False)

			textview = gtk.TextView(); textview.show()
			textview.set_editable (False)
			textview.modify_font (pango.FontDescription ("Monospace"))

			sw = gtk.ScrolledWindow(); sw.show()
			sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
			sw.add (textview)
			details.vbox.add (sw)
			textbuffer = textview.get_buffer()

#			envtext = "\n".join(["%s = %s" % (k,os.environ[k]) for k in sorted(os.environ.keys())])
#			textbuffer.set_text (trace.getvalue() + "\n\n\nENVIRONMENT\n\n" +  envtext)
			textbuffer.set_text (trace.getvalue())

			monitor = gtk.gdk.screen_get_default ().get_monitor_at_window (dialog.window)
			area = gtk.gdk.screen_get_default ().get_monitor_geometry (monitor)
			try:
				w = area.width // 1.6
				h = area.height // 1.6
			except SyntaxError:
				# python < 2.2
				w = area.width / 1.6
				h = area.height / 1.6
			details.set_default_size (int (w), int (h))

			details.run()
			details.destroy()

		elif resp == 1 and gtk.main_level() > 0:
			gtk.main_quit()
			break
		else:
			break

	dialog.destroy()
Beispiel #21
0
def _info (exctyp, value, tb):
    try:
        import pdb
    except ImportError:
        # py2exe
        pdb = None
        
    if exctyp is KeyboardInterrupt:
        sys.exit(1)
    trace = None
    dialog = gtk.MessageDialog (parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE)
    dialog.set_title (_("Bug Detected"))
    if gtk.check_version (2, 4, 0) is not None:
        dialog.set_has_separator (False)

    primary = _("<big><b>A programming error has been detected.</b></big>")
    secondary = _("Please report it by copying the information that appears "
                  "when you click the \"Details\" button and submitting a bug "
                  "report by choosing Help->Report a Problem. Thanks!")

    dialog.set_markup (primary)
    dialog.format_secondary_text (secondary)

    if feedback is not None:
        dialog.add_button (_("Report..."), 3)
        
    dialog.add_button (_("Details..."), 2)
    if pdb:
        dialog.add_button (_("Debug..."), 4)
    dialog.add_button (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button (gtk.STOCK_QUIT, 1)

    while True:
        resp = dialog.run()
        if resp == 4:
            pdb.post_mortem(tb)
            
        if resp == 3:
#            if trace == None:
#                trace = analyse (exctyp, value, tb)
#
#            # TODO: prettyprint, deal with problems in sending feedback, &tc
#            try:
#                server = smtphost
#            except NameError:
#                server = 'localhost'
#
#            message = 'From: buggy_application"\nTo: bad_programmer\nSubject: Exception feedback\n\n%s' % trace.getvalue()
#
#            s = SMTP()
#            s.connect (server)
#            s.sendmail (feedback, (feedback,), message)
#            s.quit()
            break

        elif resp == 2:
            if trace == None:
                trace = analyse (exctyp, value, tb)

            # Show details...
            details = gtk.Dialog (_("Bug Details"), dialog,
              gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
              (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE, ))
            details.set_property ("has-separator", False)

            textview = gtk.TextView(); textview.show()
            textview.set_editable (False)
            textview.modify_font (pango.FontDescription ("Monospace"))

            sw = gtk.ScrolledWindow(); sw.show()
            sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            sw.add (textview)
            details.vbox.add (sw)
            textbuffer = textview.get_buffer()
            textbuffer.set_text (trace)

            monitor = gtk.gdk.screen_get_default ().get_monitor_at_window (dialog.window)
            area = gtk.gdk.screen_get_default ().get_monitor_geometry (monitor)
            w = area.width // 1.6
            h = area.height // 1.6
            details.set_default_size (int (w), int (h))

            details.run()
            details.destroy()

        elif resp == 1 and gtk.main_level() > 0:
            sys.exit(1)
        else:
            break

    dialog.destroy()
Beispiel #22
0
#!/usr/bin/env python

import sys
import gtk, pango

ver = gtk.check_version(2,12,0)
if ver:
	raise Exception,ver

import gobject
from time import *
from episodes_pb2 import All

import fetch

class EpgrabberGUI:
	def _addrow(self,row):
		iter = None
		try:
			iter = self.episodes.append(row)
		except TypeError:
			self.episodes.remove(self.episodes[-1].iter)
			newrow = []
			for (t,val) in zip(self.types,row):
				if t == gobject.TYPE_STRING:
					if val == None:
						newrow.append("")
					else:
						newrow.append(str(val))
				elif t == gobject.TYPE_UINT:
					if val == None:
Beispiel #23
0
def _info(exctyp, value, tb):
    global exception_dialog_active
    if exctyp is KeyboardInterrupt:
        return original_excepthook(exctyp, value, tb)
    sys.stderr.write(analyse_simple(exctyp, value, tb).getvalue())
    if exception_dialog_active:
        return

    gtk.gdk.pointer_ungrab()
    gtk.gdk.keyboard_ungrab()

    exception_dialog_active = True
    trace = None
    dialog = gtk.MessageDialog(parent=None,
                               flags=0,
                               type=gtk.MESSAGE_WARNING,
                               buttons=gtk.BUTTONS_NONE)
    dialog.set_title(_("Bug Detected"))
    if gtk.check_version(2, 4, 0) is not None:
        dialog.set_has_separator(False)

    primary = "<big><b>%s</b></big>" % _("A programming error has been "
                                         "detected.")
    primary += '\n\n<span color="red">' + str(value) + '</span>'
    secondary = _("It probably isn't fatal, but the details should be "
                  "reported to the developers nonetheless.")

    try:
        setsec = dialog.format_secondary_text
    except AttributeError:
        raise
        dialog.vbox.get_children()[0].get_children()[1].set_markup(
            '%s\n\n%s' % (primary, secondary))
        #lbl.set_property ("use-markup", True)
    else:
        del setsec
        dialog.set_markup(primary)
        dialog.format_secondary_text(secondary)

    try:
        email = feedback
        dialog.add_button(_("Report..."), 3)
    except NameError:
        # could ask for an email address instead...
        pass
    dialog.add_button(_("Details..."), 2)
    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button(gtk.STOCK_QUIT, 1)

    while True:
        resp = dialog.run()
        if resp == 3:
            if trace == None:
                trace = analyse(exctyp, value, tb)

            # TODO: prettyprint, deal with problems in sending feedback, &tc
            try:
                server = smtphost
            except NameError:
                server = 'localhost'

            message = _(
                'From: buggy_application"\nTo: bad_programmer\nSubject: Exception feedback\n\n%s'
            ) % trace.getvalue()

            s = SMTP()
            s.connect(server)
            s.sendmail(email, (email, ), message)
            s.quit()
            break

        elif resp == 2:
            if trace == None:
                trace = analyse(exctyp, value, tb)

            # Show details...
            details = gtk.Dialog(
                _("Bug Details"), dialog,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (
                    gtk.STOCK_CLOSE,
                    gtk.RESPONSE_CLOSE,
                ))
            details.set_property("has-separator", False)

            textview = gtk.TextView()
            textview.show()
            textview.set_editable(False)
            textview.modify_font(pango.FontDescription("Monospace"))

            sw = gtk.ScrolledWindow()
            sw.show()
            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            sw.add(textview)
            details.vbox.add(sw)
            textbuffer = textview.get_buffer()
            textbuffer.set_text(trace.getvalue())

            monitor = gtk.gdk.screen_get_default().get_monitor_at_window(
                dialog.window)
            area = gtk.gdk.screen_get_default().get_monitor_geometry(monitor)
            try:
                w = area.width // 1.6
                h = area.height // 1.6
            except SyntaxError:
                # python < 2.2
                w = area.width / 1.6
                h = area.height / 1.6
            details.set_default_size(int(w), int(h))

            details.run()
            details.destroy()

        elif resp == 1 and gtk.main_level() > 0:
            #gtk.main_quit() - why...? Exit code 0 is bad for IDEs.
            sys.exit(1)
            break
        else:
            break

    dialog.destroy()
    exception_dialog_active = False
def _info(exctyp, value, tb):
    trace = None
    dialog = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE)
    dialog.set_title(_("Bug Detected"))
    if gtk.check_version(2, 4, 0) is not None:
        dialog.set_has_separator(False)

    primary = _("<big><b>A programming error has been detected during the execution of this program.</b></big>")
    secondary = _("It probably isn't fatal, but should be reported to the developers nonetheless.")

    try:
        email = feedback
        dialog.add_button(_("Report..."), 3)
    except NameError:
        secondary += _("\n\nPlease remember to include the contents of the Details dialog.")
        # could ask for an email address instead...
        pass

    try:
        setsec = dialog.format_secondary_text
    except AttributeError:
        raise
        dialog.vbox.get_children()[0].get_children()[1].set_markup('%s\n\n%s' % (primary, secondary))
        #lbl.set_property("use-markup", True)
    else:
        del setsec
        dialog.set_markup(primary)
        dialog.format_secondary_text(secondary)

    dialog.add_button(_("Details..."), 2)
    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button(gtk.STOCK_QUIT, 1)

    while True:
        resp = dialog.run()
        if resp == 3:
            if trace is None:
                trace = analyse(exctyp, value, tb)

            # TODO: prettyprint, deal with problems in sending feedback, &tc
            try:
                server = smtphost
            except NameError:
                server = 'localhost'

            message = 'From: buggy_application"\nTo: bad_programmer\nSubject: Exception feedback\n\n%s' % trace.getvalue()

            s = SMTP()
            s.connect(server)
            s.sendmail(email, (email,), message)
            s.quit()
            break

        elif resp == 2:
            if trace is None:
                trace = analyse(exctyp, value, tb)

            # Show details...
            details = gtk.Dialog(_("Bug Details"), dialog,
              gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
              (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE, ))
            details.set_property("has-separator", False)

            textview = gtk.TextView()
            textview.show()
            textview.set_editable(False)
            textview.modify_font(pango.FontDescription("Monospace"))

            sw = gtk.ScrolledWindow()
            sw.show()
            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            sw.add(textview)
            details.vbox.add(sw)
            textbuffer = textview.get_buffer()
            textbuffer.set_text(trace.getvalue())

            monitor = gtk.gdk.screen_get_default().get_monitor_at_window(dialog.window)
            area = gtk.gdk.screen_get_default().get_monitor_geometry(monitor)
            try:
                w = area.width // 1.6
                h = area.height // 1.6
            except SyntaxError:
                # python < 2.2
                w = area.width / 1.6
                h = area.height / 1.6
            details.set_default_size(int(w), int(h))

            details.run()
            details.destroy()

        elif resp == 1 and gtk.main_level() > 0:
            gtk.main_quit()
            break
        else:
            break

    dialog.destroy()
#    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 emesene; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import os
import gtk
import gobject

disabled = False
type_ = 'gtk'

if not gtk.check_version( 2, 10, 0 ) == None:
    if os.name == 'posix':
        try:
            import egg.trayicon
            type_ = 'egg'
        except:
            print 'No tray icon library detected'
            disabled = True
    elif os.name == 'nt':
        try:
            from gtkwin32 import *
            WM_LBUTTONUP = 0x0202
            WM_RBUTTONUP = 0x0205
            type_ = 'win'
        except:
            print 'No tray icon library detected'
Beispiel #26
0
def _info (exctyp, value, tb):
    global exception_dialog_active
    if exctyp is KeyboardInterrupt:
        return original_excepthook(exctyp, value, tb)
    sys.stderr.write(analyse_simple (exctyp, value, tb).getvalue())
    if exception_dialog_active:
        return

    gtk.gdk.pointer_ungrab()
    gtk.gdk.keyboard_ungrab()

    exception_dialog_active = True
    # Create the dialog
    dialog = gtk.MessageDialog (parent=None, flags=0, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_NONE)
    dialog.set_title (_("Bug Detected"))
    if gtk.check_version (2, 4, 0) is not None:
        dialog.set_has_separator (False)

    primary = _("<big><b>A programming error has been detected.</b></big>")
    secondary = _("It probably isn't fatal, but the details should be reported to the developers nonetheless.")

    try:
        setsec = dialog.format_secondary_text
    except AttributeError:
        raise
        dialog.vbox.get_children()[0].get_children()[1].set_markup ('%s\n\n%s' % (primary, secondary))
        #lbl.set_property ("use-markup", True)
    else:
        del setsec
        dialog.set_markup (primary)
        dialog.format_secondary_text (secondary)

    dialog.add_button (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button (gtk.STOCK_QUIT, RESPONSE_QUIT)

    # Add an expander with details of the problem to the dialog
    def expander_cb(expander, *ignore):
        # Ensures that on deactivating the expander, the dialog is resized down
        if expander.get_expanded():
            dialog.set_resizable(True)
        else:
            dialog.set_resizable(False)
    details_expander = gtk.Expander(_("Details..."))
    details_expander.connect("notify::expanded", expander_cb)

    textview = gtk.TextView(); textview.show()
    textview.set_editable (False)
    textview.modify_font (pango.FontDescription ("Monospace"))

    sw = gtk.ScrolledWindow(); sw.show()
    sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    sw.set_size_request(800, 400)
    sw.add (textview)

    details_expander.add (sw)
    details_expander.show_all()
    dialog.get_content_area().pack_start(details_expander)

    # Get the traceback and set contents of the details
    try:
        trace = analyse (exctyp, value, tb).getvalue()
    except:
        try:
            trace = _("Exception while analyzing the exception.") + "\n"
            trace += analyse_simple (exctyp, value, tb).getvalue()
        except:
            trace = _("Exception while analyzing the exception.")
    if type(value) == common.errors.UnknownCoreException:
        trace = value.get_tracebackstring()
    buf = textview.get_buffer()
    buf.set_text (trace)
    ## Would be nice to scroll to the bottom automatically, but @#&%*@
    #first, last = buf.get_bounds()
    #buf.place_cursor(last)
    #mark = buf.get_insert()
    ##buf.scroll_mark_onscreen()
    ##textview.scroll_mark_onscreen(buf.get_insert(), 0)
    #textview.scroll_to_mark(mark, 0.0)

    # Connect callback and present the dialog
    dialog.connect('response', _dialog_response_cb, trace)
    #dialog.set_modal(True) # this might actually be contra-productive...
    dialog.show()
Beispiel #27
0
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygtk
pygtk.require('2.0')
import gtk
import gobject
import pango
import webbrowser
import logging
import config
import dades
import domini
from domini import Classe, Horari, Cerca, ErrorDades, ErrorOpcions
from thread import start_new_thread

gtk_versio_2_10 = gtk.check_version(2, 10, 0) is None


def inicia():
    if not gtk_versio_2_10:
        logging.warning("La versió de GTK és inferior a la 2.10.")
    gtk.gdk.threads_init()
    gtk.gdk.threads_enter()
    gtk.about_dialog_set_url_hook(obre_enllac_web)
    f = Finestra()
    f.show()
    try:
        gtk.main()
    except KeyboardInterrupt:
        pass
    gtk.gdk.threads_leave()
Beispiel #28
0
def _info (exctyp, value, tb):
        global exception_dialog_active
        if exctyp is KeyboardInterrupt:
                return original_excepthook(exctyp, value, tb)
        sys.stderr.write(analyse_simple (exctyp, value, tb).getvalue())
        if exception_dialog_active:
                return

        gtk.gdk.pointer_ungrab()
        gtk.gdk.keyboard_ungrab()

        exception_dialog_active = True
        trace = None
        dialog = gtk.MessageDialog (parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE)
        dialog.set_title(_("Bug Detected"))
        if gtk.check_version (2, 4, 0) is not None:
                dialog.set_has_separator (False)

        primary = "<big><b>%s</b></big>" % _("A programming error has been "
                                             "detected.")
        primary += '\n\n<span color="red">'+str(value)+'</span>'
        secondary = _("It probably isn't fatal, but the details should be "
                      "reported to the developers nonetheless.")

        try:
                setsec = dialog.format_secondary_text
        except AttributeError:
                raise
                dialog.vbox.get_children()[0].get_children()[1].set_markup ('%s\n\n%s' % (primary, secondary))
                #lbl.set_property ("use-markup", True)
        else:
                del setsec
                dialog.set_markup (primary)
                dialog.format_secondary_text (secondary)

        try:
                email = feedback
                dialog.add_button(_("Report..."), 3)
        except NameError:
                # could ask for an email address instead...
                pass
        dialog.add_button (_("Details..."), 2)
        dialog.add_button (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
        dialog.add_button (gtk.STOCK_QUIT, 1)

        while True:
                resp = dialog.run()
                if resp == 3:
                        if trace == None:
                                trace = analyse (exctyp, value, tb)

                        # TODO: prettyprint, deal with problems in sending feedback, &tc
                        try:
                                server = smtphost
                        except NameError:
                                server = 'localhost'

                        message = _('From: buggy_application"\nTo: bad_programmer\nSubject: Exception feedback\n\n%s') % trace.getvalue()

                        s = SMTP()
                        s.connect (server)
                        s.sendmail (email, (email,), message)
                        s.quit()
                        break

                elif resp == 2:
                        if trace == None:
                                trace = analyse (exctyp, value, tb)

                        # Show details...
                        details = gtk.Dialog (_("Bug Details"), dialog,
                          gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                          (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE, ))
                        details.set_property ("has-separator", False)

                        textview = gtk.TextView(); textview.show()
                        textview.set_editable (False)
                        textview.modify_font (pango.FontDescription ("Monospace"))

                        sw = gtk.ScrolledWindow(); sw.show()
                        sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
                        sw.add (textview)
                        details.vbox.add (sw)
                        textbuffer = textview.get_buffer()
                        textbuffer.set_text (trace.getvalue())

                        monitor = gtk.gdk.screen_get_default ().get_monitor_at_window (dialog.window)
                        area = gtk.gdk.screen_get_default ().get_monitor_geometry (monitor)
                        try:
                                w = area.width // 1.6
                                h = area.height // 1.6
                        except SyntaxError:
                                # python < 2.2
                                w = area.width / 1.6
                                h = area.height / 1.6
                        details.set_default_size (int (w), int (h))

                        details.run()
                        details.destroy()

                elif resp == 1 and gtk.main_level() > 0:
                        #gtk.main_quit() - why...? Exit code 0 is bad for IDEs.
                        sys.exit(1)
                        break
                else:
                        break

        dialog.destroy()
        exception_dialog_active = False
Beispiel #29
0
from gtk import gdk
import pango

import os
from xml.sax import saxutils

import musicapplet.conf
import musicapplet.defs
import musicapplet.manager
import musicapplet.widgets

STOCK_ICON = "music-applet"
STOCK_SET_STAR = "music-applet-set-star"
STOCK_UNSET_STAR = "music-applet-unset-star"

USE_GTK_TOOLTIP = (gtk.check_version (2,12,0) == None)


class MusicApplet:
    """
    The actual applet part of Music Applet.
    """

    ##################################################################
    #
    # Construction
    #
    ##################################################################

    def __init__ (self, applet):
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""

APP_NAME = "FindThatWord"
APP_VERSION = '0.1'
FILE_EXT = "ftw"
COPYRIGHT = 'Copyright Jonny Jones and Ieuan Jones 2009'
AUTHORS = ['Jonny Jones', 'Ieuan Jones']

import sys
try:
    import pygtk
    import gtk
    a = gtk.check_version(2, 10, 0)
    if a:
        print a
        sys.exit(1)
except:
    print "Please install pyGTK version 2.10 or later"
    sys.exit(1)
try:
    import time
    import datetime
    import gtk.glade
    import cairo
    import pango
    import pangocairo
    import gobject
    import os
Beispiel #31
0
def _info(exctyp, value, tb):
    global exception_dialog_active
    if exctyp is KeyboardInterrupt:
        return original_excepthook(exctyp, value, tb)
    sys.stderr.write(analyse_simple(exctyp, value, tb).getvalue())
    if exception_dialog_active:
        return

    gtk.gdk.pointer_ungrab()
    gtk.gdk.keyboard_ungrab()

    exception_dialog_active = True
    # Create the dialog
    dialog = gtk.MessageDialog(parent=None,
                               flags=0,
                               type=gtk.MESSAGE_ERROR,
                               buttons=gtk.BUTTONS_NONE)
    dialog.set_title(_("Bug Detected"))
    if gtk.check_version(2, 4, 0) is not None:
        dialog.set_has_separator(False)

    primary = _("<big><b>A programming error has been detected.</b></big>")
    secondary = _(
        "It probably isn't fatal, but the details should be reported to the developers nonetheless."
    )

    try:
        setsec = dialog.format_secondary_text
    except AttributeError:
        raise
        dialog.vbox.get_children()[0].get_children()[1].set_markup(
            '%s\n\n%s' % (primary, secondary))
        #lbl.set_property ("use-markup", True)
    else:
        del setsec
        dialog.set_markup(primary)
        dialog.format_secondary_text(secondary)

    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button(gtk.STOCK_QUIT, RESPONSE_QUIT)

    # Add an expander with details of the problem to the dialog
    def expander_cb(expander, *ignore):
        # Ensures that on deactivating the expander, the dialog is resized down
        if expander.get_expanded():
            dialog.set_resizable(True)
        else:
            dialog.set_resizable(False)

    details_expander = gtk.Expander(_("Details..."))
    details_expander.connect("notify::expanded", expander_cb)

    textview = gtk.TextView()
    textview.show()
    textview.set_editable(False)
    textview.modify_font(pango.FontDescription("Monospace"))

    sw = gtk.ScrolledWindow()
    sw.show()
    sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    sw.set_size_request(800, 400)
    sw.add(textview)

    details_expander.add(sw)
    details_expander.show_all()
    dialog.get_content_area().pack_start(details_expander)

    # Get the traceback and set contents of the details
    try:
        trace = analyse(exctyp, value, tb).getvalue()
    except:
        try:
            trace = _("Exception while analyzing the exception.") + "\n"
            trace += analyse_simple(exctyp, value, tb).getvalue()
        except:
            trace = _("Exception while analyzing the exception.")
    if type(value) == common.errors.UnknownCoreException:
        trace = value.get_tracebackstring()
    buf = textview.get_buffer()
    buf.set_text(trace)
    ## Would be nice to scroll to the bottom automatically, but @#&%*@
    #first, last = buf.get_bounds()
    #buf.place_cursor(last)
    #mark = buf.get_insert()
    ##buf.scroll_mark_onscreen()
    ##textview.scroll_mark_onscreen(buf.get_insert(), 0)
    #textview.scroll_to_mark(mark, 0.0)

    # Connect callback and present the dialog
    dialog.connect('response', _dialog_response_cb, trace)
    #dialog.set_modal(True) # this might actually be contra-productive...
    dialog.show()
Beispiel #32
0
def _info(exctyp, value, tb):
    # DONE: Si se puede enviar por correo, enviar por correo y no abrir 
    # siquiera la ventana. O guardar a log o algo así si no se puede. Lo de 
    # preguntar al usuario se tiene que quedar como última opción, porque 
    # siempre pasan del tema. Solo mostrar una ventana si no se puede continuar 
    # la ejecución del programa de ninguna de las maneras.
    trace = None
    dialog = gtk.MessageDialog(parent=None, flags=0, 
                                type=gtk.MESSAGE_WARNING, 
                                buttons=gtk.BUTTONS_NONE)
    dialog.set_title(_("Bug Detected"))
    if gtk.check_version(2, 4, 0) is not None:
        dialog.set_has_separator(False)

    primary = _("<big><b>A programming error has been detected during the execution of this program.</b></big>")
    secondary = _("It probably isn't fatal, but should be reported to the developers nonetheless.")

    try:
        setsec = dialog.format_secondary_text
    except AttributeError:
        raise
        dialog.vbox.get_children()[0].get_children()[1].set_markup('%s\n\n%s' 
            % (primary, secondary))
        #lbl.set_property("use-markup", True)
    else:
        del setsec
        dialog.set_markup(primary)
        dialog.format_secondary_text(secondary)

    try:
        email = feedback #@UndefinedVariable
        dialog.add_button(_("Report..."), 3)
        autosend = True
    except NameError:
        # could ask for an email address instead...
        autosend = False
    dialog.add_button(_("Details..."), 2)
    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button(gtk.STOCK_QUIT, 1)
    dialog.add_button(_("Close all"), 4)

    while True:
        if not autosend:
            resp = dialog.run()
        else:
            resp = 3    # Emulo que se ha pulsado el botón.
        if resp == 3:
            vpro = VentanaActividad(
                texto = "Enviando informe de error. Por favor, espere...\n"
                        "(Si esta ventana persiste, reinicie la aplicación)")
            # TODO: PLAN: Si la ventana lleva más de un minuto sin enviar el
            # correo, ya no lo hará casi seguro. Cerrarla programáticamente.
            vpro.mostrar()
            vpro.mover()
            if trace == None:
                trace = analyse(exctyp, value, tb)
            vpro.mover()
            # TODO: prettyprint, deal with problems in sending feedback, &tc
            try:
                server = smtphost #@UndefinedVariable
            except NameError:
                server = 'localhost'
            vpro.mover()
            msgmail = MIMEMultipart("alternative")
            msgmail["Subject"] = "Geotex-INN -- Excepción capturada"
            msgmail["From"] = email
            msgmail["To"] = "Soporte G-INN"
            traza = trace.getvalue()
            message = 'From: %s"\nTo: %s\nSubject: Geotex-INN'\
                      ' -- Excepción capturada.\n\n%s'%(msgmail["From"], 
                                                        msgmail["To"], 
                                                        traza)
            text_version = message
            html_version = prettyprint_html(traza)
            ferrname = traza.split("\n")[-1].split(":")[0]
            if not ferrname:
                ferrname = "error_ginn"
            #import re
            #regexpline = re.compile("line [0-9]+")
            #try:
            #    linea = regexplline.findall(traza)[-1]
            #except IndexError:
            #    pass
            #else:
            #    ferrname += "_" + linea.replace(" ", "_")
            # XXX: Test del HTML. En el navegador se ve fetén, pero en el 
            #      thunderbird no carga el prettyPrint()
            #      Tristeza infinita.
            if False:
                tempfile = open("/tmp/%s.html" % ferrname, "w")
                tempfile.write(html_version)
                tempfile.close()
                os.system("xdg-open /tmp/%s.html" % ferrname)
            # XXX
            part1 = MIMEText(text_version, "plain")
            part2 = MIMEText(html_version, "html")
            msgmail.attach(part1)
            msgmail.attach(part2)
            adjunto = MIMEBase("text", "html")
            adjunto.set_payload(html_version)
            encoders.encode_base64(adjunto)
            adjunto.add_header("Content-Disposition", 
                               "attachment;filename=%s.html" % (ferrname))
            msgmail.attach(adjunto)
            vpro.mover()
            # Aparte de enviarlo por correo, si tengo consola, vuelco.
            try:
                sys.stderr.write("\n")
                sys.stderr.write("="*79)
                sys.stderr.write(datetime.datetime.now().strftime(
                    "%Y%m%d %H:%M:%S").center(80))
                sys.stderr.write("="*79)
                sys.stderr.write("\n")
                sys.stderr.write(message)
                sys.stderr.write("\n")
            except:
                pass
            s = SMTP()
            vpro.mover()
            try:
                s.connect(server, port) #@UndefinedVariable
            except NameError:
                s.connect(server)
            vpro.mover()
            try:
                passoteword = password #@UndefinedVariable
            except NameError:
                pass
            vpro.ocultar()
            try:
                try:
                    if not passoteword:
                        txt="Introduzca contraseña del servidor de correo %s"%(
                            server)
                        passoteword = fdialogo(titulo = "CONTRASEÑA:", 
                                               texto = txt, 
                                               pwd = True) 
                        if passoteword == None:
                            continue
                except NameError, msg:
                    txt="Introduzca contraseña del servidor de correo %s"%(
                        server)
                    passoteword = fdialogo(titulo = "CONTRASEÑA:", 
                                                        texto = txt, 
                                                        pwd = True) 
                    if passoteword == None:
                        continue
                vpro.mostrar()
                vpro.mover()
                try:
                    if ssl: #@UndefinedVariable
                        s.ehlo()
                        s.starttls()
                        s.ehlo()
                except NameError, msg:
                    pass    # No hay variable ssl. No cifrado.
                vpro.mover()
                try:
                    s.login(email, passoteword)
                except SMTPException:
                    print msg
                    pass    # Servidor no necesita autenticación.
                vpro.mover()
            except NameError, msg:
                pass    # No se ha especificado contraseña, será que no 
def _info(exctyp, value, tb):
    if exctyp.__name__ == 'KeyboardInterrupt':
        sys.stderr.write('%s: %s\n' % (exctyp.__name__, value))
        sys.exit(1)

    trace = None
    dialog = gtk.MessageDialog(parent=None,
                               flags=0,
                               type=gtk.MESSAGE_WARNING,
                               buttons=gtk.BUTTONS_NONE)
    dialog.set_title(_("Bug Detected"))
    if gtk.check_version(2, 4, 0) is not None:
        dialog.set_has_separator(False)

    primary = _(
        "<big><b>A programming error has been detected during the execution of this program.</b></big>"
    )
    secondary = _(
        "It probably isn't fatal, but should be reported to the developers nonetheless."
    )

    try:
        setsec = dialog.format_secondary_text
    except AttributeError:
        raise
        dialog.vbox.get_children()[0].get_children()[1].set_markup(
            '%s\n\n%s' % (primary, secondary))
        #lbl.set_property ("use-markup", True)
    else:
        del setsec
        dialog.set_markup(primary)
        dialog.format_secondary_text(secondary)

    try:
        email = feedback
        dialog.add_button(_("Report..."), 3)
    except NameError:
        # could ask for an email address instead...
        pass
    dialog.add_button(_("Details..."), 2)
    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button(gtk.STOCK_QUIT, 1)

    while True:
        resp = dialog.run()
        if resp == 3:
            if trace == None:
                trace = analyse(exctyp, value, tb)

            # TODO: prettyprint, deal with problems in sending feedback, &tc
            try:
                server = smtphost
            except NameError:
                server = 'localhost'

            message = 'From: buggy_application"\nTo: bad_programmer\nSubject: Exception feedback\n\n%s' % trace.getvalue(
            )

            s = SMTP()
            s.connect(server)
            s.sendmail(email, (email, ), message)
            s.quit()
            break

        elif resp == 2:
            if trace == None:
                trace = analyse(exctyp, value, tb)

            # Show details...
            details = gtk.Dialog(
                _("Bug Details"), dialog,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (
                    gtk.STOCK_CLOSE,
                    gtk.RESPONSE_CLOSE,
                ))
            details.set_property("has-separator", False)

            textview = gtk.TextView()
            textview.show()
            textview.set_editable(False)
            textview.modify_font(pango.FontDescription("Monospace"))

            sw = gtk.ScrolledWindow()
            sw.show()
            sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            sw.add(textview)
            details.vbox.add(sw)
            textbuffer = textview.get_buffer()

            #			envtext = "\n".join(["%s = %s" % (k,os.environ[k]) for k in sorted(os.environ.keys())])
            #			textbuffer.set_text (trace.getvalue() + "\n\n\nENVIRONMENT\n\n" +  envtext)
            textbuffer.set_text(trace.getvalue())

            monitor = gtk.gdk.screen_get_default().get_monitor_at_window(
                dialog.window)
            area = gtk.gdk.screen_get_default().get_monitor_geometry(monitor)
            try:
                w = area.width // 1.6
                h = area.height // 1.6
            except SyntaxError:
                # python < 2.2
                w = area.width / 1.6
                h = area.height / 1.6
            details.set_default_size(int(w), int(h))

            details.run()
            details.destroy()

        elif resp == 1 and gtk.main_level() > 0:
            gtk.main_quit()
            break
        else:
            break

    dialog.destroy()
Beispiel #34
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# Contact: http://fxk.de.vu/

import sys
import os
import dri
import pygtk
pygtk.require("2.0")
import gtk
import gobject
import argparse

if gtk.check_version(2, 4, 0):
    print "Error: DRIconf requires GTK 2.4 or newer."
    sys.exit(1)

import driconf_commonui
import driconf_complexui
import driconf_simpleui

commonui = driconf_commonui  # short cuts
complexui = driconf_complexui
simpleui = driconf_simpleui

from driconf_commonui import _


def main():
Beispiel #35
0
#    emesene 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 emesene; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import os
import gtk

disabled = False
type_ = "gtk"

if not gtk.check_version(2, 10, 0) == None:
    if os.name == "posix":
        try:
            import egg.trayicon

            type_ = "egg"
            disabled = False
        except:
            print "No tray icon library detected"
            disabled = True
    elif os.name == "nt":
        try:
            from gtkwin32 import *

            WM_LBUTTONUP = 0x0202
            WM_RBUTTONUP = 0x0205
Beispiel #36
0
def _info (exctyp, value, tb):
    global exception_dialog_active
    if exctyp is KeyboardInterrupt:
        return original_excepthook(exctyp, value, tb)
    sys.stderr.write(analyse_simple (exctyp, value, tb).getvalue())
    if exception_dialog_active:
        return

    gtk.gdk.pointer_ungrab()
    gtk.gdk.keyboard_ungrab()

    exception_dialog_active = True
    # Create the dialog
    dialog = gtk.MessageDialog (parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE)
    dialog.set_title (_("Info"))
    if gtk.check_version (2, 4, 0) is not None:
        dialog.set_has_separator (False)

    primary = _("<big><b>Info</b></big>")
    secondary = _(value.__str__())

    try:
        setsec = dialog.format_secondary_text
    except AttributeError:
        raise
        dialog.vbox.get_children()[0].get_children()[1].set_markup ('%s\n\n%s' % (primary, secondary))
        #lbl.set_property ("use-markup", True)
    else:
        del setsec
        dialog.set_markup (primary)
        dialog.format_secondary_text (secondary)

    dialog.add_button (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button (gtk.STOCK_QUIT, RESPONSE_QUIT)

    # Add an expander with details of the problem to the dialog
    def expander_cb(expander, *ignore):
        # Ensures that on deactivating the expander, the dialog is resized down
        if expander.get_expanded():
            dialog.set_resizable(True)
        else:
            dialog.set_resizable(False)
    if exctyp is not Exception:
        details_expander = gtk.Expander(_("Details..."))
        details_expander.connect("notify::expanded", expander_cb)

        textview = gtk.TextView(); textview.show()
        textview.set_editable (False)
        textview.modify_font (pango.FontDescription ("Monospace"))

        sw = gtk.ScrolledWindow(); sw.show()
        sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_size_request(800, 400)
        sw.add (textview)

        details_expander.add (sw)
        details_expander.show_all()
        dialog.get_content_area().pack_start(details_expander)

        # Get the traceback and set contents of the details
    try:
       trace = analyse (exctyp, value, tb).getvalue()
    except:
        try:
            trace = _("Exception while analyzing the exception.") + "\n"
            trace += analyse_simple (exctyp, value, tb).getvalue()
        except:
            trace = _("Exception while analyzing the exception.")

    if exctyp is not Exception:
        buf = textview.get_buffer()
        buf.set_text (trace)

    dialog.connect('response', _dialog_response_cb, trace)
    dialog.show()
Beispiel #37
0
def _info (exctyp, value, tb):
    # First output the exception to stderr
    orig_excepthook(exctyp, value, tb)
    
    try:
        import pdb
    except ImportError:
        # py2exe
        pdb = None
        
    if exctyp is KeyboardInterrupt:
        sys.exit(1)
    trace = None
    dialog = gtk.MessageDialog (parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE)
    dialog.set_title (_("Bug Detected"))
    if gtk.check_version (2, 4, 0) is not None:
        dialog.set_has_separator (False)

    primary = _("<big><b>A programming error has been detected.</b></big>")
    secondary = _("Please report it by clicking the 'Report' button. Thanks!")

    dialog.set_markup (primary)
    dialog.format_secondary_text (secondary)

    dialog.add_button (_("Report..."), 3)
        
    dialog.add_button (_("Details..."), 2)
    if pdb:
        dialog.add_button (_("Debug..."), 4)
    dialog.add_button (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)

    while True:
        resp = dialog.run()
        if resp == 4:
            pdb.post_mortem(tb)
            
        if resp == 3:
            if trace == None:
                trace = analyse (exctyp, value, tb)
            
            bug_report(dialog, _gladefile, trace)

        elif resp == 2:
            if trace == None:
                trace = analyse (exctyp, value, tb)

            # Show details...
            details = gtk.Dialog (_("Bug Details"), dialog,
              gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
              (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE, ))
            details.set_property ("has-separator", False)

            textview = gtk.TextView(); textview.show()
            textview.set_editable (False)
            textview.modify_font (pango.FontDescription ("Monospace"))

            sw = gtk.ScrolledWindow(); sw.show()
            sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            sw.add (textview)
            details.vbox.add (sw)
            textbuffer = textview.get_buffer()
            textbuffer.set_text (trace)

            monitor = gtk.gdk.screen_get_default ().get_monitor_at_window (dialog.window)
            area = gtk.gdk.screen_get_default ().get_monitor_geometry (monitor)
            w = area.width // 1.6
            h = area.height // 1.6
            details.set_default_size (int (w), int (h))

            details.run()
            details.destroy()

        else:
            break

    dialog.destroy()
Beispiel #38
0
from gtk import gdk
import pango

import os
from xml.sax import saxutils

import musicapplet.conf
import musicapplet.defs
import musicapplet.manager
import musicapplet.widgets

STOCK_ICON = "music-applet"
STOCK_SET_STAR = "music-applet-set-star"
STOCK_UNSET_STAR = "music-applet-unset-star"

USE_GTK_TOOLTIP = (gtk.check_version(2, 12, 0) == None)


class MusicApplet:
    """
    The actual applet part of Music Applet.
    """

    ##################################################################
    #
    # Construction
    #
    ##################################################################

    def __init__(self, applet):
Beispiel #39
0
def _info(exctyp, value, tb):
    trace = None
    dialog = gtk.MessageDialog(parent = None, flags = 0, 
                               type = gtk.MESSAGE_WARNING, 
                               buttons = gtk.BUTTONS_NONE)
    dialog.set_title(_("Bug Detected"))
    if gtk.check_version(2, 4, 0) is not None:
        dialog.set_has_separator(False)

    primary = _("<big><b>A programming error has been detected during "
                "the execution of this program.</b></big>")
    secondary = _("It probably isn't fatal, but should be reported to the "
                  "developers nonetheless.")

    try:
        setsec = dialog.format_secondary_text
    except AttributeError:
        raise
        dialog.vbox.get_children()[0].get_children()[1].set_markup('%s\n\n%s' 
            % (primary, secondary))
        #lbl.set_property ("use-markup", True)
    else:
        del setsec
        dialog.set_markup(primary)
        dialog.format_secondary_text(secondary)

    try:
        email = feedback 
        dialog.add_button(_("Report..."), 3)
    except NameError:
        # could ask for an email address instead...
        pass
    dialog.add_button(_("Details..."), 2)
    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    dialog.add_button(gtk.STOCK_QUIT, 1)
    dialog.add_button(_("Close all"), 4)

    while True:
        resp = dialog.run()
        if resp == 3:
            if trace == None:
                trace = analyse(exctyp, value, tb)

            # TODO: prettyprint, deal with problems in sending feedback, etc.
            try:
                server = smtphost 
            except NameError:
                server = 'localhost'
            try:
                usuario = usuario_aplicacion
            except NameError:
                usuario = None

            message = 'From: {0}"\n'\
                      'To: {1}\n'\
                      'Subject: Exception feedback\n\n{3}'.format(
                        email, 
                        _("CICAN support{0}").format(
                            usuario and " ("+usuario+")" or ""), 
                        trace.getvalue())
            s = SMTP()
            try:
                s.connect(server, port) 
            except NameError:
                s.connect(server)
            try:
                passoteword = password 
            except NameError:
                pass
            try:
                try:
                    if not passoteword:
                        txt = _("Introduzca contraseña del servidor de correo"
                                " %s") % (server)
                        passoteword = fdialogo(titulo = _("CONTRASEÑA:"), 
                                               texto = txt, 
                                               pwd = True) 
                        if passoteword == None:
                            continue
                except NameError, msg:
                    txt = (_("Introduzca contraseña del servidor de correo %s")
                           % server)
                    passoteword = fdialogo(titulo = _("CONTRASEÑA:"), 
                                                        texto = txt, 
                                                        pwd = True) 
                    if passoteword == None:
                        continue
                try:
                    if ssl: 
                        s.ehlo()
                        s.starttls()
                        s.ehlo()
                except NameError, msg:
                    pass    # No hay variable ssl. No cifrado.
                try:
                    s.login(email, passoteword)
                except SMTPException:
                    print msg
                    pass    # Servidor no necesita autenticación.
            except NameError, msg:
                pass    # No se ha especificado contraseña, será que no 
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
"""

APP_NAME = "Wesnoth-TC"
APP_VERSION = '1.5.0'

import sys

try:
    import pygtk
    import gtk
    a = gtk.check_version(2, 10, 0)
    if a:
        print a
        sys.exit(1)
except:
    print "Please install pyGTK version 2.10 or later"
    sys.exit(1)
try:
    import gtk.glade
    import gobject
    import cairo
    import os
except ImportError, error_message:
    error_dialog = gtk.MessageDialog(None
                      , gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
                      , gtk.MESSAGE_ERROR
Beispiel #41
0
          "your system.\n*** Unless you tweaked setup.cfg you can probably " \
          "delete them:"
    for f in obsoleteFiles:
        print "***\t%s" % f

#
# Check if required packages are installed
#
errors = 0
try:
    import pygtk
    pygtk.require("2.0")
    import gtk
except:
    print "\n*** Warning: importing GTK version 2 doesn't work."
    errors = 1
else:
    if gtk.check_version(2, 4, 0):
        print "\n*** Warning: DRIconf requires GTK 2.4 or newer."
        errors = 1
try:
    import xml.parsers.expat
except:
    if not errors:
        print
    print "*** Warning: importing xml.parsers.expat doesn't work."
    errors = 1

if errors:
    print "*** Warning: DRIconf will probably not work for the above reason(s)."
Beispiel #42
0
def front_end(no_interp=None):
    global startupfiles
    global gtk_options
    global randomseed
    ## From here on is the serial version.
        
    # When loading modules, use utils.OOFexec so that names are
    # imported into the oof environment, not the oof.run environment.
    if not (runtimeflags.text_mode or config.no_gui()):
	# The gtk import dance described below doesn't work when the program
        # has been packaged by cx_freeze.
        # TODO LATER: is checking frozen required for gtk2?
        frozen = hasattr(sys, 'frozen')
	if not frozen:
            import pygtk
            pygtk.require("2.0")
            import gtk
            msg = gtk.check_version(2, 6, 0)
            if msg:
                print msg
                sys.exit(3)

        import ooflib.common.IO.GUI.initialize
        # temporarily disable the engine, tutorials, orientationmap
        # for 3D development
        import ooflib.engine.IO.GUI.initialize
        import ooflib.image.IO.GUI.initialize
        if config.dimension() == 2:
            import ooflib.orientationmap.GUI.initialize
            import ooflib.tutorials.initialize
        if replaydelay is not None:
            from ooflib.common.IO.GUI import gtklogger
            gtklogger.set_delay(int(replaydelay))
    else:                               # text mode
        import ooflib.common.initialize
        import ooflib.engine.initialize
        import ooflib.image.initialize
        if config.dimension() == 2:
            import ooflib.orientationmap.initialize
    import ooflib.EXTENSIONS.initialize

    # The random number generator must be seeded *after* the gui has
    # been started, because libfontconfig is using random numbers.  We
    # want the numbers to be the same in text and gui modes, so that
    # the test suite gets predictable answers.
    if debug.debug() or randomseed is not None:
        if randomseed is None:
            randomseed = 17
        random.seed(randomseed)
        crandom.rndmseed(randomseed)

    for module in startupimports:
        exec('import ' + module)

    if not (runtimeflags.text_mode or config.no_gui()):
        reporter.report("Welcome to OOF2 version %s!" % oofversion.version)
        ## The files to be loaded must be loaded *after* the GUI
        ## starts, but this routine doesn't regain control once it
        ## starts the GUI. So we have to install the file loader
        ## (loadStartUpFiles) as an idle callback, which will run on
        ## the main thread.  loadStartUpFiles just issues menu
        ## commands that load the files, and if it runs on the main
        ## thread those menu commands will run by Workers on
        ## subthreads, and won't be run sequentially.  So, instead of
        ## installing loadStartUpFiles as an idle callback, we install
        ## subthread.execute and have it call loadStartUpFiles, since
        ## workers on subthreads don't create additional subthreads to
        ## run their menu items.
        if startupfiles:
            # startupfiles won't be run until after the GUI starts.
            mainthread.run(subthread.execute_immortal,
                           (loadStartUpFiles, (startupfiles,)))
        if not no_interp: # Default case, run on local thread.
            from ooflib.common.IO.GUI import oofGUI
            oofGUI.start()      # This call never returns.
            print "This line should never be printed.  rank =", _rank
        else:
            # TODO LATER: The gui and no_interp combination is
            # thinkable, but has problems.  You have to run the GUI on
            # a separate thread, but then exceptions show up as modal
            # dialog boxes in the GUI, and block the menu items which
            # raised them, causing a loss of control.  Also, the
            # current threading scheme requires that all gtk activity
            # happen on the main thread.
            print "GUI no_interp mode not implemented.  Sorry."
            raise NotImplementedError("GUI no_interp mode")
            
    else:                               # text mode
        from ooflib.common import quit
        # Allow exceptions to propagate to the user if in batch mode
        # or not running an interpreter.  Otherwise, exceptions are
        # caught and reported to the user, but the program keeps
        # running.
        if runtimeflags.batch_mode or no_interp:
            from ooflib.common import worker
            worker.propagate_exceptions = True
        if startupfiles:
            loadStartUpFiles(startupfiles)
            if runtimeflags.batch_mode:
                # Batch mode runs startupfiles and quits immediately.
                quit.set_quiet()
                quit.quit()
                if sys.exc_info()[0] is not None:
                    sys.exit(1)
                sys.exit(0)
        # Format the banner for the current line width.
        if not quit.quiet():
            width = utils.screenwidth()
            wiggles = "//=*=\\\\=*="
            nwiggles = (width-2)/len(wiggles)
            welcome = "Welcome to OOF2 version %s!" % oofversion.version
            nblanks = (width - len(welcome))/2
            banner = wiggles*nwiggles + "//\n\n" \
                     + " "*nblanks + welcome + "\n" + \
                     string.join(utils.format(banner1, width),"\n") + \
                     "\n\n" +  wiggles*nwiggles + "//\n" + \
                     string.join(utils.format(banner2, width), "\n")
        else:
            banner = ""
            
        if not no_interp:
            import code
            # Try to import readline, which allows command line
            # editing in text mode.  If it's not there, don't worry --
            # it's possible to live without it.  Some systems don't
            # seem to have it, although it's supposedly available on
            # all Unix systems.
            try:
                import readline
            except ImportError:
                pass
            # Start up the interpreter in the __main__ namespace.
            # This is the namespace that utils.OOFeval and OOFdefine
            # use.  It's not necessarily *this* namespace.
            interp = code.InteractiveConsole(sys.modules['__main__'].__dict__)
            interp.interact(banner)