def StartServer(log=None): if IMPORT_TWISTED == False : log.EcritLog(_(u"Erreur : Problème d'importation de Twisted")) return try : factory = protocol.ServerFactory() factory.protocol = Echo factory.protocol.log = log reactor.registerWxApp(wx.GetApp()) port = int(UTILS_Config.GetParametre("synchro_serveur_port", defaut=PORT_DEFAUT)) reactor.listenTCP(port, factory) # IP locale #ip_local = socket.gethostbyname(socket.gethostname()) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('jsonip.com', 80)) ip_local = s.getsockname()[0] s.close() log.EcritLog(_(u"IP locale : %s") % ip_local) # IP internet ip_internet = json.loads(urlopen("http://jsonip.com").read())["ip"] log.EcritLog(_(u"IP internet : %s") % ip_internet) # Port log.EcritLog(_(u"Serveur prêt sur le port %d") % port) log.SetImage("on") reactor.run() except Exception, err : print ("Erreur lancement serveur nomade :", err) log.EcritLog(_(u"Erreur dans le lancement du serveur Nomadhys :") ) log.EcritLog(err)
def main(): log.startLogging(sys.stdout) app = MedicalookApp() reactor.registerWxApp(app) reactor.run()
def run(self, gui=None): reactor.registerWxApp(gui) # @UndefinedVariable bindPort = self.portOpen() p = reactor.listenTCP(bindPort, self.server) # @UndefinedVariable self.tryConnect(DUMMY_PUBLIC_IP, DUMMY_SVPORT) reactor.callInThread(self.test, p.getHost().port) # @UndefinedVariable reactor.run() # @UndefinedVariable
def main(): """main entry point into MicroView""" # Run the main application app = MicroViewApp(False) reactor.registerWxApp(app) reactor.run()
def OnInit(self): self.SetAppName("rss_downloader") # For debugging self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG) # initialize config before anything else self.Config = ConfigManager() reactor.registerWxApp(self) self.Bind(EVT_NEW_TORRENT_SEEN, self.OnNewTorrentSeen) self.Bind(EVT_TORRENT_DOWNLOADED, self.OnTorrentDownloaded) self.growler = growler.Growler() self.db_engine = db.Database() self.db_engine.connect() self.db_engine.init() self.db = db.DBSession() self.icon = wx.IconFromBitmap(self.load_app_image('16-rss-square.png').ConvertToBitmap()) self.feed_checker = FeedChecker() self.download_queue = DownloadQueue() self.download_queue.run() self.feed_checker.run() self.mainwindow = mainwin.MainWindow() self.mainwindow.Bind(wx.EVT_CLOSE, self.Shutdown) return True
def start(): # Initiliaze MyApp app = PlotServerApp(False) # Make wx application twisted aware # Have to run "wxreactor.install()" on top before reactor.registerWxApp(app) # Make a XML-RPC Server listening on a port port = common.defaultPort # Add introspection so doc strings will show up on client side # (TODO: Adding introspection doesn't seem to work) xmlrpc.addIntrospection(app) root = resource.Resource() root.putChild('RPC2', app) #root.putChild('SOAP', app) # TODO: make it possible to pass in the interface to use, rather than # restricting it unconditionally to localhost reactor.listenTCP(port, server.Site(root), interface='127.0.0.1') # Start both reactor parts (wx MainLoop and XML-RPC server) reactor.run() # restore stdout/stderr sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__
def runClient(): parser = argparse.ArgumentParser() parser.add_argument( '-s', '--server' ) parser.add_argument( '-t', '--teamname' ) args = parser.parse_args() if args.server is None: args.server = 'localhost' log.msg('Client start') npc_factory = NPCServer() app = wx.App() frame_1 = MyFrame( None, -1, "", size=(1000, 1000), factory = npc_factory, teamname=args.teamname ) app.SetTopWindow(frame_1) frame_1.Show() reactor.registerWxApp(app) reactor.connectTCP(args.server, 22517, npc_factory) reactor.run() log.msg('end client')
def main(cmd_args=None): parser =optparse.OptionParser() parser.add_option('-s','--service', action='store_true', dest='serviceOnly', default=False, help='Start dMilo with only the web service.') parser.add_option('-n','--new', action='store_true', dest='newdb', default=False, help='Initialize a new Database') if cmd_args: (options, args) = parser.parse_args() else: (options, args) = parser.parse_args(cmd_args) #: Set the Preferences. if not os.path.exists(dotDmiloPath): os.makedirs(dotDmiloPath) if options.newdb or not os.path.exists( os.path.join(dotDmiloPath, 'dmilo.db')): ModelStore(os.path.join(dotDmiloPath, 'dmilo.db')).newStore() ModelStore(os.path.join(dotDmiloPath, 'dmilo.db')) #: Start the Application if options.serviceOnly: app = serviceOnlyApp( False ) else: app = xrcApp(False) #: Add the Application to the Event Loop. reactor.registerWxApp(app) #: Start the Event Loop. reactor.run()
def demo(): log.startLogging(sys.stdout) # register the App instance with Twisted: app = MyApp(0) reactor.registerWxApp(app) # start the event loop: reactor.run()
def twist(app, rpc): """ This runs the (optional xml-rpc server) Ref: http://code.activestate.com/recipes/298985/ """ reactor.registerWxApp(app) reactor.listenTCP(RPC_PORT, server.Site(rpc)) reactor.run()
def serve_udp(engine=None, port=9007, logto=sys.stdout): """Serve the `M2UDP` protocol using the given `engine` on the specified `port` logging messages to given `logto` which is a file-like object. This function will block till the service is closed. There is no need to call `mlab.show()` after or before this. The Mayavi UI will be fully responsive. **Parameters** :engine: Mayavi engine to use. If this is `None`, `mlab.get_engine()` is used to find an appropriate engine. :port: int: port to serve on. :logto: file : File like object to log messages to. If this is `None` it disables logging. **Examples** Here is a very simple example:: from mayavi import mlab from mayavi.tools import server mlab.test_plot3d() server.serve_udp() Test it like so:: import socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind(('', 9008)) s.sendto('camera.azimuth(10)', ('', 9007)) **Warning** Data sent is exec'd so this is a security hole. """ from mayavi import mlab e = engine or mlab.get_engine() # Setup the protocol with the right attributes. proto = M2UDP() proto.engine = e proto.scene = e.current_scene.scene proto.mlab = mlab if logto is not None: log.startLogging(logto) log.msg('Serving Mayavi2 UDP server on port', port) log.msg('Using Engine', e) # Register the running wxApp. reactor.registerWxApp(wx.GetApp()) # Listen on port 9007 using above protocol. reactor.listenUDP(port, proto) # Run the server + app. This will block. reactor.run()
def OnInit(self): ''' Called by wxWindows to initialize our application :returns: Always True ''' log.debug("application initialize event called") reactor.registerWxApp(self) frame = SimulatorFrame(None, -1, "Pymodbus Simulator") frame.CenterOnScreen() frame.Show(True) self.SetTopWindow(frame) return True
def main(): app = GMApp() reactor.registerWxApp(app) setLogFunction(LogText) # reactor.callLater(.1,ShowLoginDialog,app.mainFrame) try: reactor.run() except: traceback.print_exc()
def main(): #register the app app = wx.PySimpleApp() reactor.registerWxApp(app) #create the application and client addressBookApp = AddressBookApplication() factory = pb.PBClientFactory() reactor.connectTCP("localhost", 8789, factory) factory.getRootObject().addCallback(addressBookApp.connected) #start reactor reactor.run(True)
def main(): log.set_log_file("message.log") type_descriptor.load_xml("attributes.xml", "typedescriptors.xml") app = wx.App(False) # NOTE: frame must exist before run frame = MainFrame() frame.Show() reactor.registerWxApp(app) reactor.listenUDP(34888, DestAddressProtocol(frame)) reactor.run()
def initdisplay(self): # try a wx window control pane self.displayapp = wx.PySimpleApp() # create a window/frame, no parent, -1 is default ID, title, size self.displayframe = wx.Frame(None, -1, "HtmlWindow()", size=(1000, 600)) # call the derived class, -1 is default ID self.display=self.HtmlPanel(self.displayframe,-1,self) # show the frame #self.displayframe.Show(True) myWxAppInstance = self.displayapp reactor.registerWxApp(myWxAppInstance) splash="<html><body><h2>GLab Python Manager</h2></body></html>" print self.xstatus() print self.xstatus("html") self.display.updateHTML(splash+self.xstatus("html"))
def StartServer(log=None): if IMPORT_TWISTED == False : log.EcritLog(_(u"Erreur : Problème d'importation de Twisted")) return try : factory = protocol.ServerFactory() factory.protocol = Echo factory.protocol.log = log reactor.registerWxApp(wx.GetApp()) port = int(UTILS_Config.GetParametre("synchro_serveur_port", defaut=PORT_DEFAUT)) reactor.listenTCP(port, factory) except Exception, err: print ("Erreur lancement serveur Nomadhys :", err) log.EcritLog(_(u"Erreur dans le lancement du serveur Nomadhys [factory] :") ) log.EcritLog(err)
def run_main_view_wx(config): """ Runs main UI view based on wx framework. """ # imports import wx import socket # might be some cross platform (windows) issues reported with wxReactor from twisted.internet import wxreactor # add twisted / wx interaction support wxreactor.install() # add logging observer from twisted.python.log import PythonLoggingObserver observer = PythonLoggingObserver() observer.start() # then can do normal reactor imports from twisted.internet import reactor # and wx specific implementations from ui.view_model_wx import MainViewController from ui.view_model_wx import MainViewModel from ui.main_view_wx import MainWindow # ip address *much* faster than by device name ipaddr = socket.gethostbyname(config.server_name) logging.debug("RPC:\tServer name %s resolved to IP address %s" % (config.server_name, ipaddr)) # create rpc client from web.webclient import RPCClient, RPCClientFactory rpc_client = RPCClient() # create view model view_model = MainViewModel() # create view controller controller = MainViewController(rpc_client, view_model, config) # create wxApp and main window wxApp = wx.App(False) frame = MainWindow(None, "fishpi - Proof Of Concept Vehicle control", controller, ipaddr, config.rpc_port, config.camera_port) frame.Show() # run reactor rather than usual 'wxApp.MainLoop()' reactor.registerWxApp(wxApp) logging.debug("RPC:\tconnecting to %s (%s) on port %s" % (config.server_name, ipaddr, config.rpc_port)) reactor.connectTCP(ipaddr, config.rpc_port, RPCClientFactory(controller)) #reactor.callLater(5, update_callback) reactor.run()
def run(): app = wx.App(False) app.path = os.path.dirname(sys.argv[0]) from window.main import Main import prefs import worlds prefs.Initialize() worlds.Initialize() frame = Main(None, "wxpymoo") frame.Show(True) reactor.registerWxApp(app) reactor.run() app.MainLoop()
def run_main_view_wx(server, rpc_port, camera_port): """ Runs main UI view based on wx framework. """ # imports import wx import socket # might be some cross platform (windows) issues reported with wxReactor from twisted.internet import wxreactor # add twisted / wx interaction support wxreactor.install() # add logging observer from twisted.python.log import PythonLoggingObserver observer = PythonLoggingObserver() observer.start() # add some extra logging (temp - merge later) #from sys import stdout #from twisted.python.log import startLogging, err #startLogging(stdout) # then can do normal reactor imports from twisted.internet import reactor from ui.main_view_wx import MainWindow # ip address *much* faster than by device name ipaddr = socket.gethostbyname(server) # create rpc client from web.webclient import RPCClient, RPCClientFactory rpc_client = RPCClient() # create wxApp and main window wxApp = wx.App(False) frame = MainWindow(None, "fishpi - Proof Of Concept Vehicle control", ipaddr, rpc_port, camera_port) frame.Show() # run reactor rather than usual 'wxApp.MainLoop()' reactor.registerWxApp(wxApp) logging.debug("RPC:\tconnecting to %s (%s) on port %s" % (server, ipaddr, rpc_port)) reactor.connectTCP(ipaddr, rpc_port, RPCClientFactory(frame)) #reactor.callLater(5, update_callback) reactor.run()
def init(icons_path, icons_files=None): global _IconObject global _IconsDict global USE_TRAY_ICON if not USE_TRAY_ICON: return if icons_files: _IconsDict = icons_files import wx from twisted.internet import reactor def create_menu_item(menu, label, func, icon=None): item = wx.MenuItem(menu, -1, label) menu.Bind(wx.EVT_MENU, func, id=item.GetId()) if icon is not None: item.SetBitmap(wx.Bitmap(icon)) menu.AppendItem(item) return item def icons_dict(): global _IconsDict return _IconsDict class MyTaskBarIcon(wx.TaskBarIcon): def __init__(self, icons_path, current_icon_name=None): super(MyTaskBarIcon, self).__init__() self.icons_path = icons_path self.icons = {} for name, filename in icons_dict().items(): self.icons[name] = wx.IconFromBitmap(wx.Bitmap(os.path.join(icons_path, filename))) if len(self.icons) == 0: self.icons['default'] = '' if current_icon_name is not None and current_icon_name in self.icons.keys(): self.current = current_icon_name else: self.current = self.icons.keys()[0] self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down) self.select_icon(self.current) def items_dict(self): return { 'show': os.path.join(self.icons_path, 'expand24x24.png'), 'hide': os.path.join(self.icons_path, 'collapse24x24.png'), 'toolbar': os.path.join(self.icons_path, 'tools24x24.png'), 'restart': os.path.join(self.icons_path, 'restart24x24.png'), 'reconnect':os.path.join(self.icons_path, 'network24x24.png'), 'shutdown': os.path.join(self.icons_path, 'shutdown24x24.png'),} def CreatePopupMenu(self): menu = wx.Menu() icons = self.items_dict() create_menu_item(menu, 'show', self.on_show, icons.get('show', None)) create_menu_item(menu, 'hide', self.on_hide, icons.get('hide', None)) create_menu_item(menu, 'toolbar', self.on_toolbar, icons.get('toolbar', None)) menu.AppendSeparator() create_menu_item(menu, 'reconnect', self.on_reconnect, icons.get('reconnect', None)) create_menu_item(menu, 'restart', self.on_restart, icons.get('restart', None)) create_menu_item(menu, 'shutdown', self.on_exit, icons.get('shutdown', None)) self.menu = menu return menu def on_left_down(self, event): control('show') def on_show(self, event): control('show') def on_hide(self, event): control('hide') def on_restart(self, event): control('restart') def on_exit(self, event): control('exit') def on_reconnect(self, event): control('reconnect') def on_toolbar(self, event): control('toolbar') def select_icon(self, icon_name): if icon_name in self.icons.keys(): self.current = icon_name self.SetIcon(self.icons.get(self.current, self.icons.values()[0]), LABEL) class MyApp(wx.App): def __init__(self, icons_path): self.icons_path = icons_path wx.App.__init__(self, False) def OnInit(self): # print 'OnInit' self.trayicon = MyTaskBarIcon(self.icons_path) return True def OnExit(self): # print 'OnExit' self.trayicon.Destroy() def SetIcon(self, name): # if self.trayicon.IsAvailable(): self.trayicon.select_icon(name) _IconObject = MyApp(icons_path) reactor.registerWxApp(_IconObject)
def demo(): log.startLogging(sys.stdout) app = MyApp(0) reactor.registerWxApp(app) reactor.run()
def startClient(server, port, delegate, wxApp, ipv6=False): SyncClient(server, port, delegate) reactor.registerWxApp(wxApp) reactor.run()
def startServer(port, delegate, wxApp, ipv6=False): SyncServer(port, delegate) delegate.handle_ServerLaunched() reactor.registerWxApp(wxApp) reactor.run()
self._temperature_text.SetFont(font) self.temperature_value.SetFont(font) self._humdity_text = wx.StaticText(panel, label="humidity: ", pos=(20, 180)) self.humidity_value = wx.StaticText(panel, label="?", pos=(400, 180)) self._humdity_text.SetFont(font) self.humidity_value.SetFont(font) self.Show() self.Maximize(True) if __name__ == '__main__': yadp.debug() device = Device(urn='urn:xwot:Display', location=xwot_app.http_addr, descriptions=[xwot_app.yadp_description]) service = service() service.register(device=device, passive=True) client = client() gui_app = wx.App() frame = MyFrame() _loop = task.LoopingCall(loop, client, service, device, frame) _loop.start(5.0) client.browse() reactor.registerWxApp(gui_app) app.run(host='0.0.0.0', port=xwot_app.port)
def serve_tcp(engine=None, port=8007, logto=sys.stdout, max_connect=1): """Serve the `M2TCP` protocol using the given `engine` on the specified `port` logging messages to given `logto` which is a file-like object. This function will block till the service is closed. There is no need to call `mlab.show()` after or before this. The Mayavi UI will be fully responsive. **Parameters** :engine: Mayavi engine to use. If this is `None`, `mlab.get_engine()` is used to find an appropriate engine. :port: int: port to serve on. :logto: file: File like object to log messages to. If this is `None` it disables logging. :max_connect: int: Maximum number of simultaneous connections to support. **Examples** Here is a very simple example:: from mayavi import mlab from mayavi.tools import server mlab.test_plot3d() server.serve_tcp() The TCP server will listen on port 8007 by default in the above. Any data sent to the server is simply exec'd, meaning you can do pretty much anything you want. The `engine`, `scene`, `camera` and `mlab` are all available and can be used. For example after running the above you can do this:: $ telnet localhost 8007 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. scene.camera.azimuth(45) mlab.clf() mlab.test_contour3d() scene.camera.zoom(1.5) **Warning** Data sent is exec'd so this is a security hole. """ from mayavi import mlab e = engine or mlab.get_engine() # Setup the factory with the right attributes. factory = Factory() factory.protocol = M2TCP factory.maxConnect = max_connect factory.numConnect = 0 factory.engine = e factory.scene = e.current_scene.scene factory.mlab = mlab if logto is not None: log.startLogging(logto) log.msg('Serving Mayavi2 TCP server on port', port) log.msg('Using Engine', e) # Register the running wxApp. reactor.registerWxApp(wx.GetApp()) # Listen on port 9007 using above protocol. reactor.listenTCP(port, factory) # Run the server + app. This will block. reactor.run()
def init(icons_path, icons_files=None): global _IconObject global _IconsDict global USE_TRAY_ICON if not USE_TRAY_ICON: return if icons_files: _IconsDict = icons_files else: if platform.uname()[0] == 'Linux' or platform.uname()[0] == 'Darwin': _IconsDict = _LinuxIcons else: _IconsDict = _WindowsIcons import wx from twisted.internet import reactor def create_menu_item(menu, label, func, icon=None): item = wx.MenuItem(menu, -1, label) menu.Bind(wx.EVT_MENU, func, id=item.GetId()) if icon is not None: item.SetBitmap(icon) menu.AppendItem(item) return item class MyTaskBarIcon(wx.TaskBarIcon): def __init__(self, icons_path, current_icon_name=None): super(MyTaskBarIcon, self).__init__() self.icons_path = icons_path self.icons = {} self.popup_icons = {} for name, filename in icons_dict().items(): self.icons[name] = wx.IconFromBitmap(wx.Bitmap(os.path.join(icons_path, filename))) for name, filename in popup_icons_dict().items(): self.popup_icons[name] = wx.Bitmap(os.path.join(icons_path, filename)) if len(self.icons) == 0: self.icons['default'] = '' if current_icon_name is not None and current_icon_name in self.icons.keys(): self.current = current_icon_name else: self.current = self.icons.keys()[0] self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down) self.select_icon(self.current) def CreatePopupMenu(self): menu = wx.Menu() create_menu_item(menu, 'open', self.on_show, self.popup_icons.get('open', None)) create_menu_item(menu, 'synchronize', self.on_sync, self.popup_icons.get('sync', None)) create_menu_item(menu, 'reconnect', self.on_reconnect, self.popup_icons.get('reconnect', None)) create_menu_item(menu, 'restart', self.on_restart, self.popup_icons.get('restart', None)) create_menu_item(menu, 'exit', self.on_exit, self.popup_icons.get('shutdown', None)) self.menu = menu return menu def on_left_down(self, event): control('show') def on_show(self, event): control('show') def on_sync(self, event): control('sync') def on_hide(self, event): control('hide') def on_restart(self, event): control('restart') def on_exit(self, event): control('exit') def on_reconnect(self, event): control('reconnect') def on_toolbar(self, event): control('toolbar') def select_icon(self, icon_name): # print 'select_icon', icon_name, self.icons if icon_name in self.icons.keys(): self.current = icon_name self.SetIcon(self.icons.get(self.current, self.icons.values()[0]), LABEL) def clear_icon(self): self.RemoveIcon() class MyApp(wx.App): def __init__(self, icons_path): self.icons_path = icons_path wx.App.__init__(self, False) def OnInit(self): self.trayicon = MyTaskBarIcon(self.icons_path) print 'OnInit' return True def OnExit(self): print 'OnExit' try: self.trayicon.Destroy() except: pass def SetIcon(self, name): # if self.trayicon.IsAvailable(): print 'try' self.trayicon.select_icon(name) print 'ok' def Stop(self): self.trayicon.clear_icon() try: self.trayicon.Destroy() except: pass _IconObject = MyApp(icons_path) reactor.registerWxApp(_IconObject) reactor.addSystemEventTrigger('before', 'shutdown', main_porcess_stopped)
import wx from gui.main_gui import MainFrame from twisted.internet import wxreactor wxreactor.install() from twisted.internet import reactor if __name__ == '__main__': app_instance = wx.App() app_size = wx.Size(800, 600) main_frame = MainFrame('MC Bot Manager', app_size) reactor.registerWxApp(app_instance) reactor.run()
def startMulticonsoleProgram(): from twisted.internet import reactor reactor.registerWxApp(BoaApp(0)) reactor.run()#this will not return until main window closed
def install_wx(app): # not tested #del sys.modules['twisted.internet.reactor'] from twisted.internet import wxreactor wxreactor.install() from twisted.internet import reactor reactor.registerWxApp(app)
uiDebug( "serverManagerUi OnMenu_aboutMenuItem()") info = wx.AboutDialogInfo() info.Name = "xdIm" info.Version = "0.2.0" info.Copyright = "(C) 2008-2010 Programmers and Coders Everywhere" info.Description = wordwrap( "\n\nxdIm program is a software program \n\n", 350, wx.ClientDC(self)) info.WebSite = ("http://www.xdIm.org/", "xdIm home page") info.Developers = ["xd"] wx.AboutBox(info) #!XRCED:end-block:xrcserverManagerFrame.OnMenu_aboutMenuItem if __name__ == '__main__': # app = wx.PySimpleApp() # frame = serverManager(None) # frame.Show() # app.MainLoop() # app = MyApp(0) # app.MainLoop() app = wx.App() server_twisted.frame = serverManager(None) server_twisted.frame.Show() reactor.registerWxApp(app) reactor.run()
def __init__(self, url, app): WebSocketClientFactory.__init__(self, url) self._app = app self._proto = None if __name__ == '__main__': import sys from twisted.internet import wxreactor wxreactor.install() from twisted.internet import reactor from twisted.python import log log.startLogging(sys.stdout) app = wx.App(False) app._factory = None app._frame = MyFrame(app) app._frame.Show() reactor.registerWxApp(app) app._factory = MyClientFactory("ws://localhost:9000", app) reactor.connectTCP("127.0.0.1", 9000, app._factory) reactor.run()