Пример #1
0
    def __run_httpd(self):
        if not self._name_replacement:
            config_path, _ = os.path.split(
                os.path.normpath(edconfig.get_instance().get_netlog_path()))
            config_path = os.path.join(config_path, "AppConfig.xml")

            edparser.parse_past_logs(edconfig.get_instance().get_netlog_path(),
                                     edutils.get_logfile_prefix(config_path),
                                     self.__log_parser)
            edconfig.get_instance().set_image_name_replacement(
                self._name_replacement)

        try:
            self._observer.start()
        except:
            pass
Пример #2
0
    def __websocket_server_thread(self):
        image_path = edconfig.get_instance().get_image_path()
        print image_path
        settings = {"static_path": image_path}
        _app = tornado.web.Application(
            [(r'/v1', WebSocketHandler, dict(websocket_server=self)),
             (r'/(.+\..+)', PictureWebHandler,
              dict(path=settings['static_path']))], **settings)
        _http_server = _app.listen(self._port)

        tornado.ioloop.IOLoop.instance().start()
        _http_server.stop()
Пример #3
0
def _test_past_logs():
    import cProfile, pstats, StringIO
    pr = cProfile.Profile()
    pr.enable()

    parse_past_logs(edconfig.get_instance().get_netlog_path(), "netLog",
                    __log_parser)

    pr.disable()
    s = StringIO.StringIO()
    ps = pstats.Stats(pr, stream=s).sort_stats('cumulative')
    ps.print_stats()
    print s.getvalue()
Пример #4
0
    def __init__(self, *args, **kwargs):
        wx.Dialog.__init__(self, *args, **kwargs)
        
        self._edconfig = edconfig.get_instance()
        
        self._start_on_launch = wx.CheckBox(self, label = "Start proxy on Edproxy launch")
        self._start_on_startup = wx.CheckBox(self, label = "Start Edproxy on system startup")
        self._start_minimized = wx.CheckBox(self, label = "Start Edproxy minimized")
        self._local_system_db = wx.CheckBox(self, label = "Maintain local system database")

        self._discovery_ttl = wx.TextCtrl(self) #, wx.ID_ANY, _(self._edconfig.get_netlog_path()))
        
        self._netlog_path = wx.TextCtrl(self) #, wx.ID_ANY, _(self._edconfig.get_netlog_path()))
        self._netlog_browse_button = wx.Button(self, wx.ID_ANY, _("Browse"))

        self._appconfig_path = wx.TextCtrl(self) #, wx.ID_ANY, _(self._edconfig.get_netlog_path()))
        self._appconfig_browse_button = wx.Button(self, wx.ID_ANY, _("Browse"))

        self._journal_path = wx.TextCtrl(self) #, wx.ID_ANY, _(self._edconfig.get_netlog_path()))
        self._journal_browse_button = wx.Button(self, wx.ID_ANY, _("Browse"))

        self._image_path = wx.TextCtrl(self) #, wx.ID_ANY, _(self._edconfig.get_image_path()))
        self._image_browse_button = wx.Button(self, wx.ID_ANY, _("Browse"))

        self._image_delete = wx.CheckBox(self, label = "Delete original after conversion")
        self._image_format = wx.Choice(self, choices = [ edpicture.IMAGE_CONVERT_FORMAT.BMP, edpicture.IMAGE_CONVERT_FORMAT.PNG, edpicture.IMAGE_CONVERT_FORMAT.JPG ])
        self._image_replace = wx.Choice(self, choices = [ "Keep Space", "Underscore", "Hyphen", "Period" ])

        self._wipe_database_button = wx.Button(self, wx.ID_ANY, _("Wipe Database"))

        self._netlog_path.SetMinSize((467, 29))
        self._appconfig_path.SetMinSize((467, 29))
        self._image_path.SetMinSize((467, 29))
        self._journal_path.SetMinSize((467, 29))

        self.Bind(wx.EVT_BUTTON, self.__on_ok, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.__on_netlog_browse, self._netlog_browse_button)
        self.Bind(wx.EVT_BUTTON, self.__on_appconfig_browse, self._appconfig_browse_button)
        self.Bind(wx.EVT_BUTTON, self.__on_image_browse, self._image_browse_button)
        self.Bind(wx.EVT_BUTTON, self.__on_journal_browse, self._journal_browse_button)
        self.Bind(wx.EVT_BUTTON, self.__on_wipe_database, self._wipe_database_button)
  
        # Add in 3rd Party Plugins
        self._plugin_list = list()
        self._plugin_list.append(edsm.EDSMSettings(self))
        
        self.__do_defaults()    
        self.__do_layout()
Пример #5
0
    def __init__(self, *args, **kwargs):
        wx.Dialog.__init__(self, *args, **kwargs)

        self._edconfig = edconfig.get_instance()

        self._import_path = wx.TextCtrl(self)
        self._import_browse_button = wx.Button(self, wx.ID_ANY, _("Browse"))

        self._import_db = wx.Choice(self, choices=["EDDiscovery"])

        self._import_path.SetMinSize((467, 29))
        self._import_path.ChangeValue(
            db_path_selector[self._import_db.GetSelection()])

        #         self.Bind(wx.EVT_BUTTON, self.__on_ok, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.__on_import_browse,
                  self._import_browse_button)

        self.__do_layout()
Пример #6
0
    def __init__(self, *args, **kwds):
        self.log = logging.getLogger("com.fussyware.edproxy");
        self.log.setLevel(logging.DEBUG)
        
        # begin wxGlade: EDProxyFrame.__init__
        kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.CLIP_CHILDREN
        wx.Frame.__init__(self, *args, **kwds)

        menu_bar = wx.MenuBar()
        settings_menu = wx.Menu()
        self._import_menu = settings_menu.Append(wx.ID_ANY, "&Import\tCTRL+I")
        pref_menu = settings_menu.Append(wx.ID_PREFERENCES, "&Preferences\tCTRL+,", "Configure Edproxy Settings.")
        about_menu = settings_menu.Append(wx.ID_ABOUT, "&About", "About Edproxy")
        exit_menu = settings_menu.Append(wx.ID_EXIT, "&Exit", "Exit Edproxy.")
        menu_bar.Append(settings_menu, "&File")
        self.SetMenuBar(menu_bar)
        
        self._import_menu.Enable(False)
        
        self.start_button = wx.Button(self, wx.ID_ANY, _("Start"))
        self.stop_button = wx.Button(self, wx.ID_ANY, _("Stop"))
        
        self.client_listview = wx.ListView(self, style = wx.LC_REPORT | wx.BORDER_SUNKEN)
        self.plugin_listview = wx.ListView(self, style = wx.LC_REPORT | wx.BORDER_SUNKEN)
        
        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_MENU, self.__on_import_menu, self._import_menu)
        self.Bind(wx.EVT_MENU, self.__on_pref_menu, pref_menu)
        self.Bind(wx.EVT_MENU, self.__on_exit_menu, exit_menu)
        self.Bind(wx.EVT_MENU, self.__on_about_menu, about_menu)
        self.Bind(wx.EVT_BUTTON, self.on_start, self.start_button)
        self.Bind(wx.EVT_BUTTON, self.on_stop, self.stop_button)
        
        # end wxGlade

        self.Bind(wx.EVT_CLOSE, self.on_win_close)
        
        self._edconfig = edconfig.get_instance()

        wx.CallLater(10, self.__finish_init_thread)
Пример #7
0
    def __run(self):
        group = socket.inet_aton(self._multicast_addr)
        mreq = struct.pack('4sL', group, socket.INADDR_ANY)

        self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,
                                   socket.IPPROTO_UDP)
        self._sock.setblocking(0)
        self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        # Multicast and WiFi are not friends, so set this up for a specific query-response broadcast too.
        self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

        # Tell the OS about the multicast group membership.
        self._sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP, 1)
        self._sock.setsockopt(
            socket.IPPROTO_IP, socket.IP_MULTICAST_TTL,
            struct.pack('b',
                        edconfig.get_instance().get_discovery_ttl()))
        self._sock.bind(('', self._multicast_port))
        self._sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP,
                              mreq)

        self._lock.acquire()
        self._initialized = True
        self._conditional.notify()
        self._lock.release()

        while self.is_running():
            try:
                rr, _, _ = select.select([self._sock], [], [], 0.5)
            except:
                self._lock.acquire()
                self._running = False
                self._lock.release()

                rr = None

            if rr:
                data, _ = self._sock.recvfrom(1024)

                if data:
                    try:
                        message = EDDiscoveryMessageFactory.get_message(
                            json.loads(data))

                        if (message.get_type() !=
                                DISCOVERY_SERVICE_TYPE.ANNOUNCE
                                or message.get_name() != "edproxy"):
                            #                             self.log.debug("Received: [%s]", message)
                            self._event_queue.post(message)
                            self._event_queue.flush()
                    except:
                        pass
                else:
                    self._lock.acquire()
                    self._running = False
                    self._lock.release()

        try:
            self._sock.shutdown(socket.SHUT_RDWR)
            self._sock.close()
        except:
            pass

        self._lock.acquire()
        self._running = False
        self._initialized = False
        self._lock.release()