Example #1
0
import time
from twisted.internet import ingtkernet
ingtkernet.install()

# Twisted Imports
from twisted.spread import pb
from twisted.spread.ui import gtkutil
from twisted.words.ui import im


class Group(pb.RemoteCache):
    """A local cache of a group.
    """


pb.setCopierForClass("twisted.words.service.Group", Group)


class AccountManager(gtk.GtkWindow):
    def __init__(self, imgui, *args, **kw):
        apply(gtk.GtkWindow.__init__, (self, ) + args, kw)
        self.imgui = imgui
        self.accounts = []
        vbox = gtk.GtkVBox(gtk.FALSE, 5)
        vbox.set_border_width(5)
        self.add(vbox)
        titles = ['Username', 'Online', 'Auto-Login', 'Gateway']
        clist = gtk.GtkCList(len(titles), titles)
        clist.signal_connect("select_row", self.rowSelected)
        clist.set_shadow_type(gtk.SHADOW_OUT)
        scrolled = gtk.GtkScrolledWindow(None, None)
Example #2
0
        self.setResponseCode  = self.remote.remoteMethod('setResponseCode')
        self.setLastModified  = self.remote.remoteMethod('setLastModified')

    def registerProducer(self, producer, streaming):
        self.remote.callRemote("registerProducer",
                               _ReferenceableProducerWrapper(producer),
                               streaming).addErrback(self.fail)

    def unregisterProducer(self):
        self.remote.callRemote("unregisterProducer").addErrback(self.fail)

    def fail(self, failure):
        log.err(failure)


pb.setCopierForClass(server.Request, Request)

class Issue:
    def __init__(self, request):
        self.request = request

    def finished(self, result):
        if result != NOT_DONE_YET:
            assert isinstance(result, types.StringType),\
                   "return value not a string"
            self.request.write(result)
            self.request.finish()

    def failed(self, failure):
        #XXX: Argh. FIXME.
        failure = str(failure)
Example #3
0
class SimpleCopy(pb.Copyable):
    def __init__(self):
        self.x = 1
        self.y = {"Hello":"World"}
        self.z = ['test']

class SimpleLocalCopy(pb.RemoteCopy):
    def check(self):
        # checks based on above '__init__'
        assert self.x == 1
        assert self.y['Hello'] == 'World'
        assert self.z[0] == 'test'
        return 1

pb.setCopierForClass(SimpleCopy, SimpleLocalCopy)

class SimpleFactoryCopy(pb.Copyable):
    allIDs = {}
    def __init__(self, id):
        self.id = id
        SimpleFactoryCopy.allIDs[id] = self

def createFactoryCopy(state):
    id = state.get("id", None)
    if not id:
        raise "factory copy state has no 'id' member %s" % repr(state)
    if not SimpleFactoryCopy.allIDs.has_key(id):
        raise "factory class has no ID: %s" % SimpleFactoryCopy.allIDs
    inst = SimpleFactoryCopy.allIDs[id]
    if not inst:
Example #4
0
        self.setResponseCode  = self.remote.remoteMethod('setResponseCode')
        self.setLastModified  = self.remote.remoteMethod('setLastModified')

    def registerProducer(self, producer, streaming):
        self.remote.callRemote("registerProducer",
                               _ReferenceableProducerWrapper(producer),
                               streaming).addErrback(self.fail)

    def unregisterProducer(self):
        self.remote.callRemote("unregisterProducer").addErrback(self.fail)

    def fail(self, failure):
        log.err(failure)


pb.setCopierForClass(server.Request, Request)

class Issue:
    def __init__(self, request):
        self.request = request

    def finished(self, result):
        if result != NOT_DONE_YET:
            assert isinstance(result, types.StringType),\
                   "return value not a string"
            self.request.write(result)
            self.request.finish()

    def failed(self, failure):
        #XXX: Argh. FIXME.
        failure = str(failure)
Example #5
0
            things = ''
            if obj.value.has_key('class'):
                things = "Class: %s\n" % (obj.value['class'],)
            if obj.value.has_key('self'):
                things = things + "Self: %s\n" % (obj.value['self'],)

            s = "%(name)s(%(arglist)s)\n%(things)s\n%(doc)s\n" % {
                'name': obj.value['name'],
                'doc': obj.value['doc'],
                'things': things,
                'arglist': string.join(arglist,", "),
                }
        else:
            s = str(obj) + '\n'

        self.toplevel.output.console([('stdout',s)])


if _GNOME_POWER:
    BrowserDisplay = spelunk_gnome.SpelunkDisplay
else:
    BrowserDisplay = LineOrientedBrowserDisplay

class Signature(pb.RemoteCopy, explorer.Signature):
    def __init__(self):
        pass

    __str__ = explorer.Signature.__str__

pb.setCopierForClass('twisted.manhole.explorer.Signature', Signature)
Example #6
0
# System Imports
import gtk
import time
from twisted.internet import ingtkernet
ingtkernet.install()

# Twisted Imports
from twisted.spread import pb
from twisted.spread.ui import gtkutil
from twisted.words.ui import im
class Group(pb.RemoteCache):
    """A local cache of a group.
    """

pb.setCopierForClass("twisted.words.service.Group", Group)


class AccountManager(gtk.GtkWindow):
    def __init__(self, imgui, *args, **kw):
        apply(gtk.GtkWindow.__init__, (self,)+args, kw)
        self.imgui = imgui
        self.accounts = []
        vbox = gtk.GtkVBox(gtk.FALSE, 5)
        vbox.set_border_width(5)
        self.add(vbox)
        titles = [
            'Username', 'Online', 'Auto-Login', 'Gateway'
            ]
        clist = gtk.GtkCList(len(titles), titles)
        clist.signal_connect("select_row", self.rowSelected)
Example #7
0
    def __init__(self):
        self.x = 1
        self.y = {"Hello": "World"}
        self.z = ['test']


class SimpleLocalCopy(pb.RemoteCopy):
    def check(self):
        # checks based on above '__init__'
        assert self.x == 1
        assert self.y['Hello'] == 'World'
        assert self.z[0] == 'test'
        return 1


pb.setCopierForClass(str(SimpleCopy), SimpleLocalCopy)


class NestedCopy(pb.Referenceable):
    def remote_getCopy(self):
        return SimpleCopy()


class SimpleCache(pb.Cacheable):
    def __init___(self):
        self.x = 1
        self.y = {"Hello": "World"}
        self.z = ['test']


class NestedComplicatedCache(pb.Referenceable):
Example #8
0
    def remote_getSimple(self):
        return SimpleRemote()


class SimpleCopy(pb.Copyable):
    def __init__(self):
        self.x = 1
        self.y = {"Hello": "World"}
        self.z = ['test']


class SimpleLocalCopy(pb.RemoteCopy):
    pass


pb.setCopierForClass(SimpleCopy, SimpleLocalCopy)


class SimpleFactoryCopy(pb.Copyable):
    """
    @cvar allIDs: hold every created instances of this class.
    @type allIDs: C{dict}
    """
    allIDs = {}

    def __init__(self, id):
        self.id = id
        SimpleFactoryCopy.allIDs[id] = self


def createFactoryCopy(state):
Example #9
0
class SimpleCopy(pb.Copyable):
    def __init__(self):
        self.x = 1
        self.y = {"Hello":"World"}
        self.z = ['test']

class SimpleLocalCopy(pb.RemoteCopy):
    def check(self):
        # checks based on above '__init__'
        assert self.x == 1
        assert self.y['Hello'] == 'World'
        assert self.z[0] == 'test'
        return 1

pb.setCopierForClass(str(SimpleCopy), SimpleLocalCopy)


class NestedCopy(pb.Referenceable):
    def remote_getCopy(self):
        return SimpleCopy()

class SimpleCache(pb.Cacheable):
    def __init___(self):
        self.x = 1
        self.y = {"Hello":"World"}
        self.z = ['test']

class NestedComplicatedCache(pb.Referenceable):
    def __init__(self):
        self.c = VeryVeryComplicatedCacheable()
Example #10
0
                text = remainder
            elif statement == "self_rebuild":
                rebuild.rebuild(explorer)
                if _GNOME_POWER:
                    rebuild.rebuild(gnomehole)
                rebuild.rebuild(sys.modules[__name__])
                return
        try:
            method(text)
        except pb.ProtocolError:
            # ASSUMPTION: pb.ProtocolError means we lost our connection.
            (eType, eVal, tb) = sys.exc_info()
            del tb
            s = string.join(traceback.format_exception_only(eType, eVal), "")
            self.toplevel.connectionLost(s)
        except:
            traceback.print_exc()
            gtk.mainquit()


class ObjectLink(pb.RemoteCopy, explorer.ObjectLink):
    """RemoteCopy of explorer.ObjectLink"""

    def __init__(self):
        pass

    __str__ = explorer.ObjectLink.__str__


pb.setCopierForClass("twisted.python.explorer.ObjectLink", ObjectLink)
Example #11
0
            elif statement == 'watch':
                method = self.toplevel.perspective.watch
                text = remainder
            elif statement == 'self_rebuild':
                rebuild.rebuild(explorer)
                if _GNOME_POWER:
                    rebuild.rebuild(gnomehole)
                rebuild.rebuild(sys.modules[__name__])
                return
        try:
            method(text)
        except pb.ProtocolError:
            # ASSUMPTION: pb.ProtocolError means we lost our connection.
            (eType, eVal, tb) = sys.exc_info()
            del tb
            s = string.join(traceback.format_exception_only(eType, eVal),
                            '')
            self.toplevel.connectionLost(s)
        except:
            traceback.print_exc()
            gtk.mainquit()

class ObjectLink(pb.RemoteCopy, explorer.ObjectLink):
    """RemoteCopy of explorer.ObjectLink"""
    def __init__(self):
        pass

    __str__ = explorer.ObjectLink.__str__

pb.setCopierForClass('twisted.python.explorer.ObjectLink', ObjectLink)
Example #12
0
            things = ''
            if obj.value.has_key('class'):
                things = "Class: %s\n" % (obj.value['class'],)
            if obj.value.has_key('self'):
                things = things + "Self: %s\n" % (obj.value['self'],)

            s = "%(name)s(%(arglist)s)\n%(things)s\n%(doc)s\n" % {
                'name': obj.value['name'],
                'doc': obj.value['doc'],
                'things': things,
                'arglist': string.join(arglist,", "),
                }
        else:
            s = str(obj) + '\n'

        self.toplevel.output.console([('stdout',s)])


if _GNOME_POWER:
    BrowserDisplay = spelunk_gnome.SpelunkDisplay
else:
    BrowserDisplay = LineOrientedBrowserDisplay

class Signature(pb.RemoteCopy, explorer.Signature):
    def __init__(self):
        pass

    __str__ = explorer.Signature.__str__

pb.setCopierForClass('twisted.manhole.explorer.Signature', Signature)