Пример #1
0
    def __init__(self,
                 parent=None,
                 id=-1,
                 title='Parallel IPython Shell',
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_FRAME_STYLE,
                 locals=None,
                 InterpClass=None,
                 *args,
                 **kwds):
        """Create ShellFrame instance."""
        frame.Frame.__init__(self, parent, id, title, pos, size, style)
        intro = 'Twisted Enabled PyShell for Parallel IPython'
        self.SetStatusText(intro.replace('\n', ', '))

        # Import twisted stuff
        from twisted.internet import threadedselectreactor
        threadedselectreactor.install()
        from twisted.internet import reactor
        from twisted.python import log
        self.reactor = reactor
        log.startLogging(sys.stdout)

        # Pass the reactor to the user namespace
        mylocals = locals
        if mylocals is None:
            mylocals = {'reactor': reactor}
        else:
            mylocals.update({'reactor': reactor})

        # Now creat a Shell object
        self.shell = Shell(parent=self,
                           id=-1,
                           introText=intro,
                           locals=mylocals,
                           InterpClass=InterpClass,
                           *args,
                           **kwds)

        # Override the shell so that status messages go to the status bar.
        self.shell.setStatusText = self.SetStatusText

        # Add a File->Exit event to shutdown the twisted reactor
        mb = self.GetMenuBar()
        m0 = mb.GetMenu(0)
        m0.Append(10101, "E&xit", "Exit")
        wx.EVT_MENU(self, 10101, self.DoExit)

        # Lastly interleave the twisted reactor with wx!
        reactor.interleave(wx.CallAfter)
Пример #2
0
#--------------------------------------------------------------------
import os
import wx
import wx.html
import datetime

import events
from doodle import DoodleWindow

from AccessGrid.SharedAppClient import SharedAppClient
from AccessGrid.Platform.Config import UserConfig
from AccessGrid.ClientProfile import ClientProfile

try:
    from twisted.internet import threadedselectreactor
    threadedselectreactor.install()
except:
    pass
from twisted.internet import reactor


##
#
# \brief Frame with menu and events
# \author William A. Romero R. (wil-rome[at]uniandes.edu.co)
# \version 1.2
# \date March 2007
#
class FrameExtended(wx.Frame):
    def __init__(self, parent, id, title, appUrl):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
Пример #3
0
#
# News Boy - A simple exercise in REST
#
# NewsBoy.py
#
# Copyright (c) 2006 Socialtext. All Rights Reserved.
#

# standard library
import sys, base64

import simplejson

# Twisted
from twisted.internet.threadedselectreactor import install
reactor = install()
from twisted.internet import defer
from twisted.web import client

# PyObjC
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder, AppHelper

import NewsBoyPreferencesController

NibClassBuilder.extractClasses("MainMenu")

class NewsBoyAppDelegate(NibClassBuilder.AutoBaseClass):

    def getWorkspaceURIFor(self, host):
Пример #4
0
import sys
from thread import get_ident

from qt import *

if len( sys.argv ) > 1 :
    from twisted.internet.threadedselectreactor import install
    install()
    
from twisted.internet import reactor
from twisted.spread import pb

PORT = 9991

DELAY         = 1
DOG_DELAY     = 2
RESTART_DELAY = 5

class Pinger:

    def __init__( self, host ):
        self.ping = None
        self.host = host
        self.ball = 0
        self._start()
        
    def _start( self ):
        print 'Waiting for Server...'
        client = pb.PBClientFactory()
        connector = reactor.connectTCP(host='127.0.0.1', port=PORT, factory=client, timeout=30)
        dfr = client.getRootObject()
Пример #5
0
# --- (begin) enable pygame use with twisted ---
global HaveTwisted 
HaveTwisted = False

try:
    from twisted.internet import threadedselectreactor
    HaveTwisted = True
except:
    try:
        from twisted.internet import _threadedselect as threadedselectreactor
        HaveTwisted = True
    except:
        HaveTwisted = False

try:
    threadedselectreactor.install()
except:
    pass

from pygame import event
if HaveTwisted: # if 'twisted' in globals():
    from twisted.internet import reactor
    TWISTEDEVENT = USEREVENT

def postTwistedEvent(func):
    # if not using pygame.fastevent, this can explode if the queue
    # fills up.. so that's bad.  Use pygame.fastevent, in pygame CVS
    # as of 2005-04-18.
    eventmodule.post(eventmodule.Event(TWISTEDEVENT, iterateTwisted=func))

# ----- newer example:
Пример #6
0
from PyObjCTools import AppHelper

from twisted.internet.threadedselectreactor import install
reactor = install()

# import classes required to start application
import WSTApplicationDelegateClass
import WSTConnectionWindowControllerClass

# pass control to the AppKit
AppHelper.runEventLoop()
Пример #7
0
from wx import xrc
from wx.xrc import XRCID, XRCCTRL

try:
    from twisted.internet import threadedselectreactor as tsr

    haveTwisted = True
except ImportError:
    from twisted.internet import _threadedselect as tsr

    haveTwisted = True
except ImportError:
    haveTwisted = False
finally:
    if haveTwisted == True:
        tsr.install()
        from twisted.internet import reactor

frozen = getattr(sys, 'frozen', None)
if frozen in ('dll', 'console_exe', 'windows_exe'):
    # Running inside py2exe
    # Do this so we can find PyOpenGL.
    sys.path.insert(1, os.curdir)
elif frozen in ('macosx_app',):
    # Running inside py2app
    pass

try:
    from wx import glcanvas

    haveGLCanvas = True
Пример #8
0
    def __init__(self,
                 parent=None,
                 id=-1,
                 title='Parallel IPython Crust',
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_FRAME_STYLE,
                 rootObject=None,
                 rootLabel=None,
                 rootIsNamespace=True,
                 locals=None,
                 InterpClass=None,
                 *args,
                 **kwds):
        """Create CrustFrame instance."""
        frame.Frame.__init__(self, parent, id, title, pos, size, style)
        intro = 'Twisted Enabled PyCrust for Parallel IPython'
        self.SetStatusText(intro.replace('\n', ', '))

        # Import twisted stuff
        from twisted.internet import threadedselectreactor
        threadedselectreactor.install()
        from twisted.internet import reactor
        from twisted.python import log
        self.reactor = reactor
        log.startLogging(sys.stdout)

        # Pass the reactor to the user namespace
        mylocals = locals
        if mylocals is None:
            mylocals = {'reactor': reactor}
        else:
            mylocals.update({'reactor': reactor})

        self.crust = Crust(parent=self,
                           intro=intro,
                           rootObject=rootObject,
                           rootLabel=rootLabel,
                           rootIsNamespace=rootIsNamespace,
                           locals=mylocals,
                           InterpClass=InterpClass,
                           *args,
                           **kwds)
        self.shell = self.crust.shell
        # Override the filling so that status messages go to the status bar.
        self.crust.filling.tree.setStatusText = self.SetStatusText
        # Override the shell so that status messages go to the status bar.
        self.shell.setStatusText = self.SetStatusText
        # Fix a problem with the sash shrinking to nothing.
        self.crust.filling.SetSashPosition(200)
        # Set focus to the shell editor.
        self.shell.SetFocus()

        # Add a File->Exit event to shutdown the twisted reactor
        mb = self.GetMenuBar()
        m0 = mb.GetMenu(0)
        m0.Append(10101, "E&xit", "Exit")
        wx.EVT_MENU(self, 10101, self.DoExit)

        # Lastly interleave the twisted reactor with wx!
        reactor.interleave(wx.CallAfter)
Пример #9
0
import sys
from thread import get_ident

from qt import *

if len(sys.argv) > 1:
    from twisted.internet.threadedselectreactor import install
    install()

from twisted.internet import reactor
from twisted.spread import pb

PORT = 9991

DELAY = 1
DOG_DELAY = 2
RESTART_DELAY = 5


class Pinger:
    def __init__(self, host):
        self.ping = None
        self.host = host
        self.ball = 0
        self._start()

    def _start(self):
        print 'Waiting for Server...'
        client = pb.PBClientFactory()
        connector = reactor.connectTCP(host='127.0.0.1',
                                       port=PORT,