def main(): from twisted.internet.app import Application factory = Factory() factory.protocol = Echo app = Application("echo") app.listenTCP(8000,factory) app.run(save=0)
def main(): from twisted.internet.app import Application from twisted.web import server app = Application("xmlrpc") r = xmlrpc.PB(Echoer()) app.listenTCP(7080, server.Site(r)) app.run(0)
def main(options=None): from twisted.runner import inetdtap as tap # Parse options, read various config files if not options: options = tap.Options() options.parseOptions() app = Application('tinet') tap.updateApplications(app, options) app.run(save=0)
def test1(): class MaildirTest(MaildirTwisted): def messageReceived(self, filename): print "changed:", filename from twisted.internet.app import Application #from maildir import MaildirTest # note that MaildirTest is really __main__.MaildirTest, which makes # maildir-test-shutdown.tap unusable app = Application("maildir-test") # add the service to the app m = MaildirTest("maildir", app, basedir="ddir") print "watching ddir/new/" app.run() print "done"
def main(): global DEBUG if not (os.path.exists(tmppath) and os.path.isdir(tmppath)): os.mkdir(tmppath) os.chdir(tmppath) app = Application("CommDetectServer") if len(sys.argv) >= 2 and sys.argv[1] == "debug": es = CommDetectServer(True) import commdetectcore commdetectcore.DEBUG = True else: es = CommDetectServer() _debug_('main: DEBUG=%s' % DEBUG, 0) if (DEBUG == 0): app.listenTCP(config.COMMDETECTSERVER_PORT, server.Site(es, logPath='/dev/null')) else: app.listenTCP(config.COMMDETECTSERVER_PORT, server.Site(es)) app.run(save=0)
def main(): global DEBUG #check for /tmp/encodingserver and if it doesn't exist make it if not (os.path.exists(tmppath) and os.path.isdir(tmppath)): os.mkdir(tmppath) #chdir to /tmp/encodingserver os.chdir(tmppath) app = Application("EncodingServer") if len(sys.argv) >= 2 and sys.argv[1] == "debug": es = EncodingServer(True) import encodingcore encodingcore.DEBUG = True else: es = EncodingServer() _debug_('main: DEBUG=%s' % DEBUG, 0) if (DEBUG == 0): app.listenTCP(config.ENCODINGSERVER_PORT, server.Site(es, logPath='/dev/null')) else: app.listenTCP(config.ENCODINGSERVER_PORT, server.Site(es)) app.run(save=0)
phoneCompany = cellphone.PhoneCompany("cellphone", app, auth) buggyWorld = metamorph.BuggyWorld("metamorph", app, auth) # Create Identities for Joe and Bob. def makeAccount(userName, phoneNumber, bugName, pw): # Create a cell phone for the player, so they can chat. phone = phoneCompany.createPerspective(phoneNumber) # Create a bug for the player, so they can play the game. bug = buggyWorld.createPerspective(bugName) # Create an identity for the player, so they can log in. i = auth.createIdentity(userName) i.setPassword(pw) # add perspectives to identity we created i.addKeyForPerspective(phone) i.addKeyForPerspective(bug) # Finally, commit the identity back to its authorizer. i.save() # Create both Bob's and Joe's accounts. makeAccount("joe", "222-303-8484", "fritz", "joepass") makeAccount("bob", "222-303-8485", "franz", "bobpass") app.listenTCP(portno, BrokerFactory(AuthRoot(auth))) from twisted.web.server import Site from twisted.web.static import File from twisted.web.script import ResourceScript f = File('.') f.processors = { '.rpy': ResourceScript } app.listenTCP(8080, Site(f)) app.run()
def main(): from twisted.internet.app import Application from twisted.cred.identity import Identity from twisted.cred.authorizer import DefaultAuthorizer from twisted.manhole.telnet import ShellFactory import flashweb import flash import bots def add_user(ident_name,password="",serv_name=""): persp_name = ident_name persp = svc.createPerspective(persp_name) ident = auth.createIdentity(ident_name) #ident.setPassword(password) ident.addKeyByString("unmovie_service", persp_name) auth.addIdentity(ident) return persp,ident def add_bot(ident_name,password="",params=[]): persp_name = ident_name + "_perspective" part,ident = add_user(ident_name,password) bot = bots.FlashBotChatter() bot.participant = part.attached(bot,ident_name) bot.service = svc bot.name = ident_name bot.setInitialValues(params) return bot appl = Application("unmovie") auth = DefaultAuthorizer(appl) svc = flash.FlashService("unmovie_service",appl,auth) svc.perspectiveClass = flash.FlashMember add_user("axel") add_user('philip') for x in range(0,2): add_user("me_%d" % x) for x in range(USERS_ALLOWED): add_user("you_%d" % x) # nietzsche = add_bot("nietzsche",params=[20,10,20,5,6,30]) # dylan = add_bot("dylan",params=[8,12,40,7,3,20]) # tark = add_bot("tark",params=[12,7,17,6,2,14]) # geisha = add_bot("geisha",params=[7,16,70,6,2,20]) # dogen = add_bot("dogen",params=[7,7,40,6,4,40]) nietzsche = add_bot("nietzsche",params=[20,10,20,5,6,10]) dylan = add_bot("dylan",params=[8,12,40,7,3,8]) tark = add_bot("tark",params=[12,7,17,6,2,6]) geisha = add_bot("geisha",params=[7,16,70,6,2,8]) dogen = add_bot("dogen",params=[7,7,40,6,4,7]) fls = FlashFactory(svc,"******","9998") # sf = ShellFactory() # sf.username = '******' # sf.password = '******' # sf.namespace['server'] = svc # sf.namespace['factory'] = fls # # appl.listenTCP(8780, sf) # adm = server.Site(flashweb.WordsGadget(svc)) appl.listenTCP(9998,fls) # appl.listenTCP(9996,pb.BrokerFactory(pb.AuthRoot(auth))) # appl.listenTCP(9997,adm) appl.run()
"""Thread that does processing on data received from Echo protocol""" def __init__(self, protocol): threading.Thread.__init__(self) self.protocol = protocol def run(self): while 1: # read data from queue data = self.protocol.messagequeue.get() if data != None: # write back data unchanged self.protocol.send(data) else: # connection was closed return ### Persistent Application Builder # This builds a .tap file if __name__ == '__main__': from twisted.internet.app import Application factory = Factory() factory.protocol = Echo app = Application("echo") app.listenTCP(8000, factory) app.run(save=0)