def test_main_window(self): provide(PROD_DIR, stubs.StubProductDirectory([])) provide(PRODUCT_DATE_RANGE_CALCULATOR, mock.Mock()) managergui.MainWindow(backend=stubs.StubBackend(), ent_dir=stubs.StubCertificateDirectory([]), prod_dir=stubs.StubProductDirectory([]))
def main(): parser = OptionParser(usage=USAGE, formatter=WrappedIndentedHelpFormatter()) parser.add_option("--register", action='store_true', help=_("launches the registration dialog on startup")) options, args = parser.parse_args(args=sys.argv) log = logging.getLogger("rhsm-app.subscription-manager-gui") try: bus = dbus.SessionBus() except dbus.exceptions.DBusException as e: log.debug("Enabled to connect to dbus SessionBus") log.exception(e) # Just ignore it if for some reason we can't find the session bus bus = None if already_running(bus): # Attempt to raise the running instance to the forefront try: remote_object = bus.get_object(BUS_NAME, BUS_PATH) remote_object.show_window(dbus_interface=BUS_NAME) log.debug( "subscription-manager-gui already running, showing main window" ) except dbus.exceptions.DBusException as e: log.debug("Error attempting to show main window via dbus") log.debug("dbus remote_object with no show_window: %s" % remote_object) log.debug(e) # failed to raise the window, maybe we raced dbus? # fallback to opening a new window else: # we raised the existing window, we are done sys.exit() try: main = managergui.MainWindow(auto_launch_registration=options.register) # Hook into dbus service - only if it is available if bus: SubscriptionManagerService(main.main_window) # Exit the gtk loop when the window is closed main.main_window.connect('hide', ga_Gtk.main_quit) sys.exit(ga_Gtk.main() or 0) except SystemExit as e: # this is a non-exceptional exception thrown by Python 2.4, just # re-raise, bypassing handle_exception raise e except KeyboardInterrupt: system_exit(0, "\nUser interrupted process.") except Exception as e: log.exception(e) system_exit(1, e)
def test_main_window(self): managergui.ConsumerIdentity = stubs.StubConsumerIdentity installedtab.ConsumerIdentity = stubs.StubConsumerIdentity managergui.Backend = stubs.StubBackend managergui.Consumer = StubConsumer managergui.Facts = stubs.StubFacts() managergui.MainWindow(backend=stubs.StubBackend(), consumer=StubConsumer(), facts=stubs.StubFacts(), ent_dir=stubs.StubCertificateDirectory([]), prod_dir=stubs.StubProductDirectory([]))