Пример #1
0
def boot(path, gtk=False, gst=True, installReactor=True):
    # python 2.5 and twisted < 2.5 don't work together
    pythonMM = sys.version_info[0:2]
    from twisted.copyright import version
    twistedMM = tuple([int(n) for n in version.split('.')[0:2]])
    if pythonMM >= (2, 5) and twistedMM < (2, 5):
        raise SystemError(
            "Twisted versions older than 2.5.0 do not work with "
            "Python 2.5 and newer.  "
            "Please upgrade Twisted or downgrade Python.")

    if gtk or gst:
        init_gobject()

    if gtk:
        init_kiwi()

    if gst:
        from flumotion.configure import configure
        configure.gst_version = init_gst()
        from gi.repository import GstNet

    global USE_GTK, USE_GST
    USE_GTK=gtk
    USE_GST=gst
    init_option_parser(gtk, gst)

    # installing the reactor could override our packager's import hooks ...
    if installReactor:
        from twisted.internet import gtk3reactor
        try:
            gtk3reactor.install()
        except RuntimeError, e:
            safeprintf(sys.stderr, 'ERROR: %s\n', e)
            sys.exit(1)
Пример #2
0
def install_reactor():
    from twisted.internet import gtk3reactor
    from twisted.internet.error import ReactorAlreadyInstalledError
    try:
        # needed for GLib.idle_add, and signals
        gtk3reactor.install()
    except ReactorAlreadyInstalledError:
        pass
Пример #3
0
def main(port=4118, parentpid=None):
    import os
    os.environ['NO_GAIL'] = '1'
    os.environ['NO_AT_BRIDGE'] = '1'

    import twisted
    gtkVersion = None
    try:
        from gi.repository import Gtk
        gtkVersion = Gtk._version
    except:
        pass
    if not gtkVersion or gtkVersion == '2.0':
       # As per Ubuntu 11.10, twisted glib2reactor
       # works with gtk2, which fails with gtk3
       from twisted.internet import glib2reactor
       glib2reactor.install()
    elif gtkVersion >= '3.0':
        try:
            # Exist in Ubuntu 12.04, but not on
            # Ubuntu 11.10 / Fedora 16
            from twisted.internet import gtk3reactor
            gtk3reactor.install()
        except:
            pass
    from twisted.internet import reactor
    from twisted.web import server, xmlrpc
    from xmlrpc_daemon import XMLRPCLdtpd
    import twisted.internet
    import socket
    import pyatspi
    import traceback

    _ldtp_debug = os.environ.get('LDTP_DEBUG', None)
    _ldtp_debug_file = os.environ.get('LDTP_DEBUG_FILE', None)

    try:
        pyatspi.setCacheLevel(pyatspi.CACHE_PROPERTIES)
        r = XMLRPCLdtpd()
        xmlrpc.addIntrospection(r)
        if parentpid:
            reactor.callWhenRunning(SignalParent(parentpid).send_later)
        reactor.listenTCP(port, server.Site(r))
        reactor.run()
    except twisted.internet.error.CannotListenError:
        if _ldtp_debug:
            print(traceback.format_exc())
    except socket.error:
        if _ldtp_debug:
            print(traceback.format_exc())
        if _ldtp_debug_file:
            with open(_ldtp_debug_file, "a") as fp:
                fp.write(traceback.format_exc())
Пример #4
0
def main(port=4118, parentpid=None):
    import os
    os.environ['NO_GAIL'] = '1'
    os.environ['NO_AT_BRIDGE'] = '1'

    import twisted
    gtkVersion = None
    try:
        from gi.repository import Gtk
        gtkVersion = Gtk._version
    except:
        pass
    if not gtkVersion or gtkVersion == '2.0':
        # As per Ubuntu 11.10, twisted glib2reactor
        # works with gtk2, which fails with gtk3
        from twisted.internet import glib2reactor
        glib2reactor.install()
    elif gtkVersion >= '3.0':
        try:
            # Exist in Ubuntu 12.04, but not on
            # Ubuntu 11.10 / Fedora 16
            from twisted.internet import gtk3reactor
            gtk3reactor.install()
        except:
            pass
    from twisted.internet import reactor
    from twisted.web import server, xmlrpc
    from xmlrpc_daemon import XMLRPCLdtpd
    import twisted.internet
    import socket
    import pyatspi
    import traceback

    _ldtp_debug = os.environ.get('LDTP_DEBUG', None)
    _ldtp_debug_file = os.environ.get('LDTP_DEBUG_FILE', None)

    try:
        pyatspi.setCacheLevel(pyatspi.CACHE_PROPERTIES)
        r = XMLRPCLdtpd()
        xmlrpc.addIntrospection(r)
        if parentpid:
            reactor.callWhenRunning(SignalParent(parentpid).send_later)
        reactor.listenTCP(port, server.Site(r))
        reactor.run()
    except twisted.internet.error.CannotListenError:
        if _ldtp_debug:
            print(traceback.format_exc())
    except socket.error:
        if _ldtp_debug:
            print(traceback.format_exc())
        if _ldtp_debug_file:
            with open(_ldtp_debug_file, "a") as fp:
                fp.write(traceback.format_exc())
Пример #5
0
def _setup_pre_reactor():
    # Some packagers do not include pygtkcompat, yet the Twisted GTK 3 reactor
    # setup always expects it. gi seems to do the necessary checks so make a
    # dummy module to keep Twisted happy.
    # TODO: check since which version gi checks for conflict.
    try:
        import gi.pygtkcompat as _pygtkcompat
    except ImportError:
        _pygtkcompat = SimpleNamespace(enable=lambda: None)
        sys.modules["gi.pygtkcompat"] = gi.pygtkcompat = _pygtkcompat

    from twisted.internet import gtk3reactor
    gtk3reactor.install()
    Gtk.init()
Пример #6
0
def run():
    """Start Cournal"""
    if False:
        locale_dir = os.path.realpath(os.path.dirname(sys.argv[0]))
        gettext.install("cournal", locale_dir)
    else:
        # locale_dir = os.path.join(sys.prefix, "local", "share", "locale")
        gettext.install("cournal")  # , locale_dir)

    gtk3reactor.install()
    from twisted.internet import reactor
    from cournal.mainwindow import MainWindow

    Gtk.IconTheme.get_default().prepend_search_path("./icons")

    window = MainWindow()
    window.connect("destroy", lambda _: reactor.stop())
    window.show_all()

    reactor.run()  # aka Gtk.main()
def maybeInstallReactor():
    import sys
    try:
        from twisted.internet import gtk3reactor # s/2/3 if you're using gtk3
        reactor = gtk3reactor.install()
        reactor.startRunning()
        reactor._simulate()
        return reactor
    except:
        try:
            from twisted.internet import gtk2reactor
            reactor = gtk2reactor.install()
            reactor.startRunning()
            reactor._simulate()
            return reactor
        except:
            print "This plugin requires twisted to be installed"
            exit(-1)
def maybeInstallReactor():
    import sys
    try:
        from twisted.internet import gtk3reactor  # s/2/3 if you're using gtk3
        reactor = gtk3reactor.install()
        reactor.startRunning()
        reactor._simulate()
        return reactor
    except:
        try:
            from twisted.internet import gtk2reactor
            reactor = gtk2reactor.install()
            reactor.startRunning()
            reactor._simulate()
            return reactor
        except:
            print "This plugin requires twisted to be installed"
            exit(-1)
Пример #9
0
gi.require_version("Gdk", "3.0")

from gi.repository import GObject
GObject.set_prgname("deluge")

# Install the twisted reactor
from twisted.internet import gtk3reactor

try:
    from twisted.internet.error import ReactorAlreadyInstalledError
except ImportError:
    # ReactorAlreadyInstalledError not available in Twisted version < 10
    pass

try:
    reactor = gtk3reactor.install()
except ReactorAlreadyInstalledError:
    # Running unit tests so trial already installed a rector
    pass

import gettext
import locale
import pkg_resources
from gi.repository import Gtk, Gdk
from gi.repository.Gtk import events_pending
import sys
import warnings

try:
    from setproctitle import setproctitle, getproctitle
except ImportError:
Пример #10
0
def run():
    import gi
    gi.require_version("Gtk", "3.0")
    from twisted.internet import gtk3reactor
    gtk3reactor.install()
    app.run_app(app.LockedApplication(make_application), app.Options())
Пример #11
0
# Main script to run a number of nodes and optionally
# display a visualization of the local nodes and
# their neighbors.

import argparse
import logging
import sys

from twisted.application.internet import TimerService

import gi
gi.require_version('Gtk', '3.0')
from twisted.internet import gtk3reactor
gtk3reactor.install() # If this does not happen right here, importing the reactor won't work.
from twisted.internet import reactor

from skiphash.skipplus import SkipNode, SkipNodeFactory
from skiphash.view import Visualizer

# For twisted reactor method calls:
# pylint: disable=maybe-no-member

# setup stdout logging

rootLogger = logging.getLogger()
rootLogger.setLevel(logging.INFO)

streamHandler = logging.StreamHandler(sys.stdout)
streamHandler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
streamHandler.setFormatter(formatter)
Пример #12
0
def start_client(interacting_function, queue_dict):
    from rafcon.gui.config import global_gui_config
    import os

    from rafcon.utils.i18n import setup_l10n
    setup_l10n()
    from rafcon.gui.controllers.main_window import MainWindowController
    from rafcon.gui.views.main_window import MainWindowView
    import rafcon.gui.singleton as gui_singletons
    from rafcon.gui.runtime_config import global_runtime_config
    from rafcon.gui.start import signal_handler

    import rafcon
    from rafcon.utils import log
    from rafcon.utils import plugins

    from rafcon.core.config import global_config
    from rafcon.core.storage import storage as global_storage
    from rafcon.core.state_machine import StateMachine
    from rafcon.core.states.hierarchy_state import HierarchyState
    import rafcon.core.singleton as core_singletons
    from rafcon.core.start import setup_environment

    # load all plugins specified in the RAFCON_PLUGIN_PATH
    plugins.load_plugins()
    from tests import utils as testing_utils

    # check if twisted is imported
    if "twisted" in sys.modules:
        from twisted.internet import gtk3reactor
        # needed for GLib.idle_add, and signals
        gtk3reactor.install()
        from twisted.internet import reactor
    else:
        print("Twisted not imported! Thus the gkt2reatcor is not installed!")
        exit()

    plugins.run_pre_inits()

    setup_logger()
    logger = log.get_logger("start")
    logger.info("RAFCON launcher")

    setup_environment()

    signal.signal(signal.SIGINT, signal_handler)

    global_config.load(path=os.path.dirname(os.path.abspath(__file__)))
    global_gui_config.load(path=os.path.dirname(os.path.abspath(__file__)))
    global_runtime_config.load(path=os.path.dirname(os.path.abspath(__file__)))

    setup_config = dict()
    setup_config["net_config_path"] = os.path.abspath(path=os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                                                        "client"))

    # Initialize library
    core_singletons.library_manager.initialize()

    # Create the GUI
    main_window_view = MainWindowView()

    state_machine = global_storage.load_state_machine_from_path(
        testing_utils.get_test_sm_path(os.path.join("unit_test_state_machines", "99_bottles_of_beer_monitoring")))

    sm_id = rafcon.core.singleton.state_machine_manager.add_state_machine(state_machine)
    # the active_state_machine_id must be set here, as the state machine can be active (e.g. if the server started the sm already)
    # although it is not yet started on the client
    rafcon.core.singleton.state_machine_manager.active_state_machine_id = sm_id

    sm_manager_model = gui_singletons.state_machine_manager_model
    main_window_controller = MainWindowController(sm_manager_model, main_window_view)

    plugins.run_post_inits(setup_config)

    import threading
    # this is not recognized by pycharm as the module is loaded in plugins.load_plugins()
    from monitoring.monitoring_manager import global_monitoring_manager
    interacting_thread = threading.Thread(target=interacting_function, args=[main_window_controller,
                                                                             global_monitoring_manager,
                                                                             queue_dict,
                                                                             sm_id])
    testing_utils.wait_for_gui()
    interacting_thread.start()

    # check if twisted is imported
    if "twisted" in sys.modules:
        reactor.run()
    else:
        logger.error("Client: Twisted is not in sys.modules or twisted is not working! Exiting program ... !")
        os._exit(0)

    logger.info("Joined root state")

    # If there is a running state-machine, wait for it to be finished before exiting
    sm = core_singletons.state_machine_manager.get_active_state_machine()
    if sm:
        sm.root_state.join()

    logger.info("Exiting ...")

    # this is a ugly process shutdown method but works if gtk or twisted process are still blocking
    os._exit(0)
Пример #13
0
# lots of little imports done before anything else so that
# we don't get weird stray module errors

from flumotion.common import boot

boot.init_gobject()
boot.init_gst()

import gst
import gst.interfaces
e = gst.element_factory_make('fakesrc')

from twisted.internet import gtk3reactor
gtk3reactor.install(useGtk=True)

import pyexpat

# fake out pychecker
import gobject
import gtk
import gtk.glade
loop = gobject.MainLoop()
gtk.main_iteration()

m = pyexpat
Пример #14
0
gi.require_version("Gdk", "3.0")

from gi.repository import GObject
GObject.set_prgname("deluge")

# Install the twisted reactor
from twisted.internet import gtk3reactor

try:
    from twisted.internet.error import ReactorAlreadyInstalledError
except ImportError:
    # ReactorAlreadyInstalledError not available in Twisted version < 10
    pass

try:
    reactor = gtk3reactor.install()
except ReactorAlreadyInstalledError:
    # Running unit tests so trial already installed a rector
    pass

import gettext
import locale
import pkg_resources
from gi.repository import Gtk, Gdk
from gi.repository.Gtk import events_pending
import sys
import warnings

try:
    from setproctitle import setproctitle, getproctitle
except ImportError:
Пример #15
0
# Licensed under GNU General Public License 3.0 or later.
# Some rights reserved. See COPYING, AUTHORS.
"""
Signup server and form.
"""

import gi

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio
import os
import time
from twisted.internet.protocol import Factory
from twisted.internet import gtk3reactor

gtk3reactor.install()
from twisted.internet import reactor
from twisted.protocols.basic import LineReceiver

import common
import config
import dialogs
import user_form
import paths


class Registrations(LineReceiver):
    def __init__(self, connections, requests, gui, system, groups, roles):
        self.connections = connections
        self.requests = requests
        self.gui = gui
Пример #16
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from gi.repository import Gtk, GLib, Gdk
#from communicator import CommThread, ClientCommand, ServerReply, Reciever, ClientFac
from communicator import ClientFac
import Queue
import threading
import string
import random

from twisted.internet import protocol, gtk3reactor
gtk3reactor.install()
from twisted.internet import reactor

class TISCaPClient:
    def __init__(self):
        self.server = None
        
        self.uname = None
        
        self.builder = None
        self.window = None
        
        #This should be eliminated
        self.o_c_tag = None
        self.m_c_tag = None
        #End elimination...
    
    def start(self):         
        self.builder = Gtk.Builder()
Пример #17
0
import pygtk
pygtk.require('2.0')
import gtk
import gtk.gdk
import pango
import gobject

#import pygst
#pygst.require('0.10')
import gst

import debugslider

from twisted.internet import gtk3reactor
gtk3reactor.install(useGtk=False)
from twisted.internet import reactor


data = ("checkTVCard('/dev/video0')",
        "checkTVCard('/dev/video1')",
        "checkWebcam('/dev/video0')",
        "checkWebcam('/dev/video1')",
        "checkMixerTracks('alsasrc', 'hw:0')",
        "checkMixerTracks('osssrc', '/dev/dsp')",
        "check1394()")


def make_model():
    from flumotion.worker.checks import video