imgseek-commits Mailing List for imgSeek - Intelligent image database
Status: Beta
Brought to you by:
niederberger
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(79) |
Nov
|
Dec
|
---|
From: <nie...@us...> - 2003-10-12 21:03:53
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/net In directory sc8-pr-cvs1:/tmp/cvs-serv28417/isnLib/net Modified Files: peerManager.py Log Message: Index: peerManager.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/peerManager.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- peerManager.py 12 Oct 2003 20:31:22 -0000 1.8 +++ peerManager.py 12 Oct 2003 21:03:47 -0000 1.9 @@ -79,8 +79,15 @@ work = [[x,ires] for x in self.peers] for w in work: - w[0].root.callRemote("querySig",data,w[1]).addCallbacks(self.sigResult) + w[0].root.callRemote("querySig",data,w[1]).addCallbacks(self.queryResult) - def sigResult(self,res): - print 'res:',res + def queryResult(self,res): + self.env.cb.searchResult(res) + def queryRandom(self,res): + assert (res < 60), "Try requesting less random images. The current max is 60" + + work = [[x,res] for x in self.peers] + + for w in work: + w[0].root.callRemote("queryRandom",w[1]).addCallbacks(self.queryResult) |
From: <nie...@us...> - 2003-10-12 21:03:53
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib In directory sc8-pr-cvs1:/tmp/cvs-serv28417/isnLib Modified Files: imgSeekNetApp.py Log Message: Index: imgSeekNetApp.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/imgSeekNetApp.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- imgSeekNetApp.py 12 Oct 2003 01:36:04 -0000 1.12 +++ imgSeekNetApp.py 12 Oct 2003 21:03:47 -0000 1.13 @@ -54,6 +54,7 @@ #sys.path.append('/home/rnc/prj/imgseek-net/isnLib/net') if '-s' not in sys.argv: # start GUI before server + logging.info("Starting GUI client...") import gettext gettext.install("imgSeekNet") ### Locale testing |
From: <nie...@us...> - 2003-10-12 21:03:53
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/gui In directory sc8-pr-cvs1:/tmp/cvs-serv28417/isnLib/gui Modified Files: searchToolbar.py Log Message: Index: searchToolbar.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/searchToolbar.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- searchToolbar.py 9 Oct 2003 01:46:48 -0000 1.3 +++ searchToolbar.py 12 Oct 2003 21:03:47 -0000 1.4 @@ -2,6 +2,7 @@ from wxPython.wx import * from isnLib.coreEnv import isnDataDir +import isnLib.coreEnv # begin wxGlade: dependencies # end wxGlade @@ -22,6 +23,11 @@ self.__do_layout() # end wxGlade + self.env = isnLib.coreEnv.env + + ### Events + EVT_TOOL (self, TB_random, self.onRandomQuery) + def __set_properties(self): # begin wxGlade: searchToolbar.__set_properties self.Realize() @@ -32,6 +38,9 @@ pass # end wxGlade + def onRandomQuery(self,evt): + self.env.peerMgr.queryRandom(10) + # end of class searchToolbar |
From: <nie...@us...> - 2003-10-12 20:31:28
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/net In directory sc8-pr-cvs1:/tmp/cvs-serv21412/isnLib/net Modified Files: imgClient.py peerManager.py Log Message: Index: imgClient.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/imgClient.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- imgClient.py 12 Oct 2003 00:04:38 -0000 1.8 +++ imgClient.py 12 Oct 2003 20:31:22 -0000 1.9 @@ -72,7 +72,7 @@ def debug(self,msg): logging.debug("Server@[%s:%d] %s" % (self.addr,self.port,repr(msg))) - def gotStatus(self,stat,ss): + def gotStatus(self,stat): self.debug("got from remote: "+str(stat)) self.lastStatusTime = time() self.status = stat Index: peerManager.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/peerManager.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- peerManager.py 12 Oct 2003 19:31:57 -0000 1.7 +++ peerManager.py 12 Oct 2003 20:31:22 -0000 1.8 @@ -21,6 +21,7 @@ ***************************************************************************""" import logging +from time import time try: from twisted.internet import reactor @@ -31,8 +32,8 @@ class netOpts: def __init__(self): - self.refresh_status_interval = 5 # interval - self.save_peer_cache_interval = 10 + self.refresh_status_interval = 20 # interval + self.save_peer_cache_interval = 10 * 60 self.status_timeout = 10 * 60 class peerManager: @@ -43,22 +44,24 @@ self.env.loadSettings('net',netOpts) assert(self.env.opts.net.refresh_status_interval) - reactor.callLater(self.env.opts.net.refresh_status_interval, self.refresh) + reactor.callLater(self.env.opts.net.refresh_status_interval, self.refreshPeers) logging.debug("serverManager init") - def refresh(self): + def refreshPeers(self): logging.debug("Refreshing peers (%d)"%len(self.peers)) for peer in self.peers: if time() - peer.lastStatusTime > self.env.opts.net.status_timeout: pass #TODO: remove peer and shut it down peer.root.callRemote("getStatus").addCallbacks(peer.gotStatus,peer.errStatus) - reactor.callLater(self.env.opts.net.refresh_status_interval, self.refresh) + reactor.callLater(self.env.opts.net.refresh_status_interval, self.refreshPeers) + self.env.cb.peerChange(self.peers) # update UI def addPeer(self,addr): peer = imgClient(addr[0],addr[1]) self.peers.append(peer) - + self.env.cb.peerChange(self.peers) # update UI + def querySig(self,data,res): """later, this should propagate search queries for all peers, and then determine which are best matches among all returned results. |
From: <nie...@us...> - 2003-10-12 20:31:28
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/gui In directory sc8-pr-cvs1:/tmp/cvs-serv21412/isnLib/gui Modified Files: MainFrame.py Log Message: Index: MainFrame.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/MainFrame.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- MainFrame.py 12 Oct 2003 19:31:57 -0000 1.10 +++ MainFrame.py 12 Oct 2003 20:31:22 -0000 1.11 @@ -68,8 +68,6 @@ self.peersListCtrl.InsertColumn(0, "Address") self.peersListCtrl.InsertColumn(1, "Port") - self.peerMap = {} - ### Events EVT_BUTTON (self, self.addPeerBtn.GetId(), self.onAddPeer) #EVT_LIST_ITEM_SELECTED(self, self.thumbList.GetId(), self.onThumbSelected) @@ -79,8 +77,7 @@ isnLib.coreEnv.env.gui = self self.env = isnLib.coreEnv.env - self.env.cb.newPeer = self.cbNewPeer - self.env.cb.delPeer = self.cbDelPeer + self.env.cb.peerChange = self.cbPeerChange self.env.cb.downloadFinished = self.cbDownloadFinished self.env.cb.searchResult = self.cbSearchResult @@ -180,20 +177,22 @@ # end wxGlade def onAddPeer(self,evt): - print self.env.peerMgr + addr = self.addressEdit.GetValue() + try: + port = int(self.portEdit.GetValue()) + except ValueError: + #TODO3: show error message + return + + #TODO: validate addr and port + self.env.peerMgr.addPeer([addr,port]) - def cbDelPeer(self,obj): - pass - - def cbNewPeer(self,obj): - if obj in self.peerMap: - self.peersListCtrl.SetStringItem(self.peerMap[obj],1,obj.port) - else: - self.peerMap[obj] = self.peersListCtrl.InsertStringItem(-1,obj.addr) - assert(self.peerMap[obj] != -1) - self.peersListCtrl.SetStringItem(self.peerMap[obj],1,obj.port) -## a= self.peersListCtrl.InsertStringItem(-1,"f") -## self.peersListCtrl.SetStringItem(a,1,'g') + def cbPeerChange(self,peers): + self.peersListCtrl.DeleteAllItems() + for peer in peers: + cnt = self.peersListCtrl.GetItemCount() + self.peersListCtrl.InsertStringItem(cnt,str(peer.addr)) + self.peersListCtrl.SetStringItem(cnt,1,str(peer.port)) def cbDownloadFinished(self,dn): print dn |
From: <nie...@us...> - 2003-10-12 20:31:28
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib In directory sc8-pr-cvs1:/tmp/cvs-serv21412/isnLib Modified Files: coreEnv.py Log Message: Index: coreEnv.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/coreEnv.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- coreEnv.py 12 Oct 2003 17:13:34 -0000 1.16 +++ coreEnv.py 12 Oct 2003 20:31:22 -0000 1.17 @@ -79,13 +79,16 @@ ### Init callbacks self.cb = Dummy() - cbList = ['newPeer','delPeer','searchResult','downloadFinished'] + cbList = ['peerChange','searchResult','downloadFinished'] for cb in cbList: - setattr(self.cb,cb,None) + setattr(self.cb,cb,self.dummy) def loadSettings(self,sector, default): from Settings import loadSettings setattr(self.opts, sector, loadSettings(sector+'.cfg',default)) + + def dummy(self,*args): + pass if __name__ == "__main__": pass |
From: <nie...@us...> - 2003-10-12 19:32:02
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/net In directory sc8-pr-cvs1:/tmp/cvs-serv6528/isnLib/net Modified Files: peerManager.py Log Message: Index: peerManager.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/peerManager.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- peerManager.py 12 Oct 2003 18:04:30 -0000 1.6 +++ peerManager.py 12 Oct 2003 19:31:57 -0000 1.7 @@ -59,4 +59,25 @@ peer = imgClient(addr[0],addr[1]) self.peers.append(peer) - + def querySig(self,data,res): + """later, this should propagate search queries for all peers, and then + determine which are best matches among all returned results. + """ + work = [] # list of pairs [imgCLient-object, num_res] + # if user requested less results than the current number of peers, + # just ask the best result from each peer, asking then n peers + if res < len(self.peers): + for peer in self.peers: + work.append([peer,1]) + res -= 1 + if res == 0: break + else: # share the required number of requests evenly across peers + ires = int( res / len(self.peers) ) + work = [[x,ires] for x in self.peers] + + for w in work: + w[0].root.callRemote("querySig",data,w[1]).addCallbacks(self.sigResult) + + def sigResult(self,res): + print 'res:',res + |
From: <nie...@us...> - 2003-10-12 19:32:02
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/gui In directory sc8-pr-cvs1:/tmp/cvs-serv6528/isnLib/gui Modified Files: MainFrame.py Log Message: Index: MainFrame.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/MainFrame.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- MainFrame.py 12 Oct 2003 17:13:34 -0000 1.9 +++ MainFrame.py 12 Oct 2003 19:31:57 -0000 1.10 @@ -82,7 +82,7 @@ self.env.cb.newPeer = self.cbNewPeer self.env.cb.delPeer = self.cbDelPeer self.env.cb.downloadFinished = self.cbDownloadFinished - self.env.cb.searchResult = self.cbSearchResult + self.env.cb.searchResult = self.cbSearchResult logging.debug("GUI started") @@ -180,8 +180,11 @@ # end wxGlade def onAddPeer(self,evt): + print self.env.peerMgr + + def cbDelPeer(self,obj): pass - + def cbNewPeer(self,obj): if obj in self.peerMap: self.peersListCtrl.SetStringItem(self.peerMap[obj],1,obj.port) @@ -197,6 +200,7 @@ def cbSearchResult(self,dn): print dn + # end of class MainFrame |
From: <nie...@us...> - 2003-10-12 18:04:34
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/net In directory sc8-pr-cvs1:/tmp/cvs-serv21977/isnLib/net Modified Files: peerManager.py Log Message: small updates Index: peerManager.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/peerManager.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- peerManager.py 12 Oct 2003 00:04:38 -0000 1.5 +++ peerManager.py 12 Oct 2003 18:04:30 -0000 1.6 @@ -51,7 +51,7 @@ for peer in self.peers: if time() - peer.lastStatusTime > self.env.opts.net.status_timeout: pass #TODO: remove peer and shut it down - server.root.callRemote("getStatus").addCallbacks(server.gotStatus,server.errStatus) + peer.root.callRemote("getStatus").addCallbacks(peer.gotStatus,peer.errStatus) reactor.callLater(self.env.opts.net.refresh_status_interval, self.refresh) |
From: <nie...@us...> - 2003-10-12 17:13:40
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib In directory sc8-pr-cvs1:/tmp/cvs-serv13119/isnLib Modified Files: coreEnv.py Log Message: small updates Index: coreEnv.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/coreEnv.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- coreEnv.py 12 Oct 2003 03:32:12 -0000 1.15 +++ coreEnv.py 12 Oct 2003 17:13:34 -0000 1.16 @@ -73,10 +73,15 @@ class Dummy: pass self.opts = Dummy() - + self.loadSettings('core', Opts) - #import re - #self.auth_ip_re = re.compile(self.opts.core.auth_ip) + + ### Init callbacks + self.cb = Dummy() + + cbList = ['newPeer','delPeer','searchResult','downloadFinished'] + for cb in cbList: + setattr(self.cb,cb,None) def loadSettings(self,sector, default): from Settings import loadSettings |
From: <nie...@us...> - 2003-10-12 17:13:40
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/gui In directory sc8-pr-cvs1:/tmp/cvs-serv13119/isnLib/gui Modified Files: MainFrame.py Log Message: small updates Index: MainFrame.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/MainFrame.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- MainFrame.py 12 Oct 2003 03:32:12 -0000 1.8 +++ MainFrame.py 12 Oct 2003 17:13:34 -0000 1.9 @@ -68,11 +68,6 @@ self.peersListCtrl.InsertColumn(0, "Address") self.peersListCtrl.InsertColumn(1, "Port") - a= self.peersListCtrl.InsertStringItem(-1,"f") - print a - self.peersListCtrl.SetStringItem(a,1,'g') - - self.peerMap = {} ### Events @@ -82,6 +77,13 @@ ### Callbacks isnLib.coreEnv.env.gui = self + self.env = isnLib.coreEnv.env + + self.env.cb.newPeer = self.cbNewPeer + self.env.cb.delPeer = self.cbDelPeer + self.env.cb.downloadFinished = self.cbDownloadFinished + self.env.cb.searchResult = self.cbSearchResult + logging.debug("GUI started") def __set_properties(self): @@ -187,8 +189,14 @@ self.peerMap[obj] = self.peersListCtrl.InsertStringItem(-1,obj.addr) assert(self.peerMap[obj] != -1) self.peersListCtrl.SetStringItem(self.peerMap[obj],1,obj.port) +## a= self.peersListCtrl.InsertStringItem(-1,"f") +## self.peersListCtrl.SetStringItem(a,1,'g') - + def cbDownloadFinished(self,dn): + print dn + + def cbSearchResult(self,dn): + print dn # end of class MainFrame |
From: <nie...@us...> - 2003-10-12 17:13:40
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/img In directory sc8-pr-cvs1:/tmp/cvs-serv13119/isnLib/img Modified Files: ImgDB.py Log Message: small updates Index: ImgDB.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/img/ImgDB.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- ImgDB.py 11 Oct 2003 20:31:08 -0000 1.20 +++ ImgDB.py 12 Oct 2003 17:13:34 -0000 1.21 @@ -47,7 +47,8 @@ self.env.sim_imgdb = imgdb self.env.sim_imgdb.initDbase() except ImportError: - logging.exception("Unable to import c++ image processing module") + #logging.exception("Unable to import c++ image processing module") + print "Unable to import c++ image processing module, make sure imgSeekNet was compiled and installed properly." self.env.sim_imgdb = None # TODO3: env.sim_imgdb should be checked before being invoked later raise ImportError |
From: <nie...@us...> - 2003-10-12 03:32:19
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib In directory sc8-pr-cvs1:/tmp/cvs-serv25006/isnLib Modified Files: coreEnv.py Log Message: Index: coreEnv.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/coreEnv.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- coreEnv.py 12 Oct 2003 01:36:04 -0000 1.14 +++ coreEnv.py 12 Oct 2003 03:32:12 -0000 1.15 @@ -68,6 +68,7 @@ logging.info("Initializing core environment ...") self.imgdb = None + self.gui = None class Dummy: pass |
From: <nie...@us...> - 2003-10-12 03:32:19
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/gui In directory sc8-pr-cvs1:/tmp/cvs-serv25006/isnLib/gui Modified Files: MainFrame.py Log Message: Index: MainFrame.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/MainFrame.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- MainFrame.py 12 Oct 2003 01:55:38 -0000 1.7 +++ MainFrame.py 12 Oct 2003 03:32:12 -0000 1.8 @@ -64,14 +64,24 @@ self.__do_layout() # end wxGlade + ### Extra UI setup + self.peersListCtrl.InsertColumn(0, "Address") + self.peersListCtrl.InsertColumn(1, "Port") + + a= self.peersListCtrl.InsertStringItem(-1,"f") + print a + self.peersListCtrl.SetStringItem(a,1,'g') + + + self.peerMap = {} + ### Events EVT_BUTTON (self, self.addPeerBtn.GetId(), self.onAddPeer) #EVT_LIST_ITEM_SELECTED(self, self.thumbList.GetId(), self.onThumbSelected) #EVT_LIST_ITEM_RIGHT_CLICK(self, self.thumbList.GetId(), self.onThumbActivated) ### Callbacks - self.env = isnLib.coreEnv.env - #self.env. + isnLib.coreEnv.env.gui = self logging.debug("GUI started") def __set_properties(self): @@ -169,6 +179,16 @@ def onAddPeer(self,evt): pass + + def cbNewPeer(self,obj): + if obj in self.peerMap: + self.peersListCtrl.SetStringItem(self.peerMap[obj],1,obj.port) + else: + self.peerMap[obj] = self.peersListCtrl.InsertStringItem(-1,obj.addr) + assert(self.peerMap[obj] != -1) + self.peersListCtrl.SetStringItem(self.peerMap[obj],1,obj.port) + + # end of class MainFrame |
From: <nie...@us...> - 2003-10-12 01:55:43
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/gui In directory sc8-pr-cvs1:/tmp/cvs-serv14131/isnLib/gui Modified Files: MainFrame.py isn.wxg Log Message: Index: MainFrame.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/MainFrame.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- MainFrame.py 12 Oct 2003 01:36:04 -0000 1.6 +++ MainFrame.py 12 Oct 2003 01:55:38 -0000 1.7 @@ -50,15 +50,15 @@ self.dirTree = wxGenericDirCtrl(self.localPane, -1) self.recursiveCheck = wxCheckBox(self.localPane, -1, _("Recursively")) self.addDirBtn = wxBitmapButton(self.localPane, -1, wxBitmap(isnDataDir + "wizard.png", wxBITMAP_TYPE_ANY)) - self.label_3 = wxStaticText(self.localPane, -1, _("imgSeekNet started.")) + self.statusLabel = wxStaticText(self.localPane, -1, _("imgSeekNet started.")) self.mNetworkToolbar = networkToolbar(self.networkPane, -1) - self.list_ctrl_1 = wxListCtrl(self.networkPane, -1, style=wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER) + self.peersListCtrl = wxListCtrl(self.networkPane, -1, style=wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER) self.label_1 = wxStaticText(self.networkPane, -1, _("Address")) - self.text_ctrl_1 = wxTextCtrl(self.networkPane, -1, "") + self.addressEdit = wxTextCtrl(self.networkPane, -1, "") self.label_2 = wxStaticText(self.networkPane, -1, _("Port")) - self.text_ctrl_2 = wxTextCtrl(self.networkPane, -1, "") + self.portEdit = wxTextCtrl(self.networkPane, -1, "") self.addPeerBtn = wxBitmapButton(self.networkPane, -1, wxBitmap(isnDataDir + "connect.png", wxBITMAP_TYPE_ANY)) - self.list_box_1 = wxListBox(self.networkPane, -1, choices=[_("choice 1")]) + self.statusBox = wxListBox(self.networkPane, -1, choices=[_("choice 1")]) self.__set_properties() self.__do_layout() @@ -70,7 +70,8 @@ #EVT_LIST_ITEM_RIGHT_CLICK(self, self.thumbList.GetId(), self.onThumbActivated) ### Callbacks - a = isnLib.coreEnv.env + self.env = isnLib.coreEnv.env + #self.env. logging.debug("GUI started") def __set_properties(self): @@ -91,7 +92,7 @@ self.addDirBtn.SetSize(self.addDirBtn.GetBestSize()) self.addPeerBtn.SetToolTipString(_("Add this peer manually")) self.addPeerBtn.SetSize(self.addPeerBtn.GetBestSize()) - self.list_box_1.SetSelection(0) + self.statusBox.SetSelection(0) # end wxGlade def __do_layout(self): @@ -128,7 +129,7 @@ sizer_4.Add(self.addDirBtn, 0, wxALL|wxEXPAND|wxALIGN_BOTTOM|wxALIGN_CENTER_HORIZONTAL, 0) sizer_3.Add(sizer_4, 1, wxALL|wxALIGN_RIGHT, 5) sizer_2.Add(sizer_3, 1, 0, 0) - sizer_7.Add(self.label_3, 0, wxEXPAND, 0) + sizer_7.Add(self.statusLabel, 0, wxEXPAND, 0) sizer_2.Add(sizer_7, 1, wxEXPAND, 0) self.localPane.SetAutoLayout(1) self.localPane.SetSizer(sizer_2) @@ -138,18 +139,18 @@ sizer_2.AddGrowableRow(1) sizer_2.AddGrowableCol(0) grid_sizer_3.Add(self.mNetworkToolbar, 1, wxALL|wxEXPAND, 0) - grid_sizer_4.Add(self.list_ctrl_1, 1, wxEXPAND, 0) + grid_sizer_4.Add(self.peersListCtrl, 1, wxEXPAND, 0) sizer_9.Add(self.label_1, 0, wxALL, 5) - sizer_9.Add(self.text_ctrl_1, 0, 0, 0) + sizer_9.Add(self.addressEdit, 0, 0, 0) sizer_9.Add(self.label_2, 0, wxALL, 5) - sizer_9.Add(self.text_ctrl_2, 0, 0, 0) + sizer_9.Add(self.portEdit, 0, 0, 0) sizer_9.Add(self.addPeerBtn, 0, wxLEFT|wxEXPAND, 5) grid_sizer_4.Add(sizer_9, 1, wxALL|wxEXPAND, 5) grid_sizer_4.AddGrowableRow(0) grid_sizer_4.AddGrowableCol(0) sizer_8.Add(grid_sizer_4, 1, wxEXPAND, 0) grid_sizer_3.Add(sizer_8, 1, wxEXPAND, 0) - Status.Add(self.list_box_1, 0, wxEXPAND, 0) + Status.Add(self.statusBox, 0, wxEXPAND, 0) grid_sizer_3.Add(Status, 1, wxEXPAND, 0) self.networkPane.SetAutoLayout(1) self.networkPane.SetSizer(grid_sizer_3) Index: isn.wxg =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/isn.wxg,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- isn.wxg 12 Oct 2003 00:04:38 -0000 1.3 +++ isn.wxg 12 Oct 2003 01:55:38 -0000 1.4 @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!-- generated by wxGlade 0.3 on Sat Oct 11 21:11:28 2003 --> +<!-- generated by wxGlade 0.3 on Sat Oct 11 23:03:57 2003 --> <application path="/home/rnc/prj/imgseek-net/isnLib/gui" name="imgSeekNet" class="imgSeekNetApp" option="1" language="python" top_window="mMainFrame" encoding="ISO-8859-1" use_gettext="1" overwrite="0"> <object class="MainFrame" name="mMainFrame" base="EditFrame"> @@ -213,7 +213,7 @@ <flag>wxEXPAND</flag> <border>0</border> <option>0</option> - <object class="wxStaticText" name="label_3" base="EditStaticText"> + <object class="wxStaticText" name="statusLabel" base="EditStaticText"> <attribute>1</attribute> <label>imgSeekNet started.</label> </object> @@ -264,7 +264,7 @@ <flag>wxEXPAND</flag> <border>0</border> <option>1</option> - <object class="wxListCtrl" name="list_ctrl_1" base="EditListCtrl"> + <object class="wxListCtrl" name="peersListCtrl" base="EditListCtrl"> <style>wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER</style> </object> </object> @@ -287,7 +287,7 @@ <object class="sizeritem"> <border>0</border> <option>0</option> - <object class="wxTextCtrl" name="text_ctrl_1" base="EditTextCtrl"> + <object class="wxTextCtrl" name="addressEdit" base="EditTextCtrl"> </object> </object> <object class="sizeritem"> @@ -302,7 +302,7 @@ <object class="sizeritem"> <border>0</border> <option>0</option> - <object class="wxTextCtrl" name="text_ctrl_2" base="EditTextCtrl"> + <object class="wxTextCtrl" name="portEdit" base="EditTextCtrl"> </object> </object> <object class="sizeritem"> @@ -331,7 +331,7 @@ <flag>wxEXPAND</flag> <border>0</border> <option>0</option> - <object class="wxListBox" name="list_box_1" base="EditListBox"> + <object class="wxListBox" name="statusBox" base="EditListBox"> <selection>0</selection> <choices> <choice>choice 1</choice> |
From: <nie...@us...> - 2003-10-12 01:36:10
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib In directory sc8-pr-cvs1:/tmp/cvs-serv12003/isnLib Modified Files: Settings.py coreEnv.py imgSeekNetApp.py Log Message: Index: Settings.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/Settings.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Settings.py 12 Oct 2003 00:04:38 -0000 1.6 +++ Settings.py 12 Oct 2003 01:36:04 -0000 1.7 @@ -59,13 +59,21 @@ else: try: f = open(ffname,"rb") - obj = pickle.load(f) + """ + vals = pickle.load(f) f.close() + if type(vals) != type({}): + logging.error("On %s, content should be a pickled dictionary. Returning default values." % fname) + return klass() + obj = klass() + for val in vals: + setattr(obj,val,vals[val]) + """ + obj = pickle.load(f) return obj except: logging.exception("Loading filename:"+ffname) return klass() # error ocurred, so just return a default object of the passed class - #TODO2: iterate klass members and detect which members are missing from the de-pickled file logging.info(fname + " settings loaded.") def saveSettings(env, fname): Index: coreEnv.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/coreEnv.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- coreEnv.py 11 Oct 2003 22:07:46 -0000 1.13 +++ coreEnv.py 12 Oct 2003 01:36:04 -0000 1.14 @@ -82,9 +82,4 @@ setattr(self.opts, sector, loadSettings(sector+'.cfg',default)) if __name__ == "__main__": - import os - - coreEnv.env = loadEnv('test.cfg', coreEnv) - print coreEnv.env.imgAutoOpen - coreEnv.env.imgAutoOpen = "changed" - saveEnv(coreEnv.env,'test.cfg') + pass Index: imgSeekNetApp.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/imgSeekNetApp.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- imgSeekNetApp.py 11 Oct 2003 23:03:34 -0000 1.11 +++ imgSeekNetApp.py 12 Oct 2003 01:36:04 -0000 1.12 @@ -32,7 +32,8 @@ ###### Load Core settings from isnLib.coreEnv import coreEnv env = coreEnv() - + isnLib.coreEnv.env = env + ###### Image Database # load the proper database module backend dinamically from the core config option try: |
From: <nie...@us...> - 2003-10-12 01:36:10
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/gui In directory sc8-pr-cvs1:/tmp/cvs-serv12003/isnLib/gui Modified Files: MainFrame.py Log Message: Index: MainFrame.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/MainFrame.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- MainFrame.py 12 Oct 2003 00:04:38 -0000 1.5 +++ MainFrame.py 12 Oct 2003 01:36:04 -0000 1.6 @@ -4,6 +4,7 @@ from searchToolbar import searchToolbar from networkToolbar import networkToolbar from isnLib.coreEnv import isnDataDir +import isnLib.coreEnv import logging # begin wxGlade: dependencies @@ -65,8 +66,11 @@ ### Events EVT_BUTTON (self, self.addPeerBtn.GetId(), self.onAddPeer) -# EVT_LIST_ITEM_SELECTED(self, self.thumbList.GetId(), self.onThumbSelected) -# EVT_LIST_ITEM_RIGHT_CLICK(self, self.thumbList.GetId(), self.onThumbActivated) + #EVT_LIST_ITEM_SELECTED(self, self.thumbList.GetId(), self.onThumbSelected) + #EVT_LIST_ITEM_RIGHT_CLICK(self, self.thumbList.GetId(), self.onThumbActivated) + + ### Callbacks + a = isnLib.coreEnv.env logging.debug("GUI started") def __set_properties(self): @@ -163,7 +167,7 @@ # end wxGlade def onAddPeer(self,evt): - print "adp" + pass # end of class MainFrame |
From: <nie...@us...> - 2003-10-12 00:04:42
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/net In directory sc8-pr-cvs1:/tmp/cvs-serv1681/isnLib/net Modified Files: imgClient.py imgServer.py peerManager.py Log Message: Index: imgClient.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/imgClient.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- imgClient.py 11 Oct 2003 18:09:10 -0000 1.7 +++ imgClient.py 12 Oct 2003 00:04:38 -0000 1.8 @@ -21,6 +21,7 @@ ***************************************************************************""" import logging +from time import time #TODO3: this twisted import code is reused on imgServer. perhaps refactor it ? try: from twisted.spread import pb @@ -34,7 +35,8 @@ self.addr = addr self.port = port self.isConnected = 0 - logging.debug("imgClient initialized") + logging.debug("imgClient initialized") + self.lastStatusTime = time() self.connect() def success(message): @@ -54,10 +56,9 @@ except: logging.exception("Error while connecting: [address %s] [port %d]" % (self.addr,self.port)) self.isConnected = 0 - return - + return factory.getRootObject().addCallbacks(self.gotRoot, self.errRoot) - reactor.run() + #reactor.run() def errRoot(self,reason): self.debug("error getting root object:" + repr(reason)) @@ -73,6 +74,7 @@ def gotStatus(self,stat,ss): self.debug("got from remote: "+str(stat)) + self.lastStatusTime = time() self.status = stat def errStatus(self,reason): Index: imgServer.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/imgServer.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- imgServer.py 11 Oct 2003 22:33:01 -0000 1.19 +++ imgServer.py 12 Oct 2003 00:04:38 -0000 1.20 @@ -64,3 +64,13 @@ stat = {'uptime': time() - self.startTime} return stat + def remote_getPeers(self,max = 10): + plist = [] + nPrs = len(self.env.peerMgr.peers) + while max: + if nPrs > max: + peer = self.env.peerMgr.peers[max] + plist.append([peer.addr,peer.port]) + max -= 1 + return plist + Index: peerManager.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/peerManager.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- peerManager.py 11 Oct 2003 23:03:34 -0000 1.4 +++ peerManager.py 12 Oct 2003 00:04:38 -0000 1.5 @@ -23,14 +23,17 @@ import logging try: - from twisted.internet import reactor + from twisted.internet import reactor except: logging.exception("Please install Twisted (http://www.twistedmatrix.com/products/download)") +from imgClient import imgClient + class netOpts: def __init__(self): self.refresh_status_interval = 5 # interval self.save_peer_cache_interval = 10 + self.status_timeout = 10 * 60 class peerManager: def __init__(self,env): @@ -46,10 +49,14 @@ def refresh(self): logging.debug("Refreshing peers (%d)"%len(self.peers)) for peer in self.peers: + if time() - peer.lastStatusTime > self.env.opts.net.status_timeout: + pass #TODO: remove peer and shut it down server.root.callRemote("getStatus").addCallbacks(server.gotStatus,server.errStatus) reactor.callLater(self.env.opts.net.refresh_status_interval, self.refresh) - def addPeer(self,peer): + def addPeer(self,addr): + peer = imgClient(addr[0],addr[1]) self.peers.append(peer) + |
From: <nie...@us...> - 2003-10-12 00:04:42
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib In directory sc8-pr-cvs1:/tmp/cvs-serv1681/isnLib Modified Files: Settings.py core.py Log Message: Index: Settings.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/Settings.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Settings.py 11 Oct 2003 22:07:46 -0000 1.5 +++ Settings.py 12 Oct 2003 00:04:38 -0000 1.6 @@ -59,7 +59,7 @@ else: try: f = open(ffname,"rb") - obj = cPickle.load(f) + obj = pickle.load(f) f.close() return obj except: @@ -74,7 +74,7 @@ ffname = settDir + fname try: f = open(ffname,"wb") - cPickle.dump(env, f,1) + pickle.dump(env, f,1) f.close() logging.info(fname + " settings saved.") except: Index: core.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/core.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- core.py 11 Oct 2003 23:03:34 -0000 1.2 +++ core.py 12 Oct 2003 00:04:38 -0000 1.3 @@ -33,6 +33,7 @@ self.env = env self.startServer() + self.startPeerManager() logging.debug("core init. Now running Twisted event engine...") self.env.app.run(save=0) |
From: <nie...@us...> - 2003-10-12 00:04:42
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/gui In directory sc8-pr-cvs1:/tmp/cvs-serv1681/isnLib/gui Modified Files: MainFrame.py isn.wxg Log Message: Index: MainFrame.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/MainFrame.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- MainFrame.py 11 Oct 2003 18:09:10 -0000 1.4 +++ MainFrame.py 12 Oct 2003 00:04:38 -0000 1.5 @@ -56,7 +56,7 @@ self.text_ctrl_1 = wxTextCtrl(self.networkPane, -1, "") self.label_2 = wxStaticText(self.networkPane, -1, _("Port")) self.text_ctrl_2 = wxTextCtrl(self.networkPane, -1, "") - self.bitmap_button_1 = wxBitmapButton(self.networkPane, -1, wxBitmap(isnDataDir + "connect.png", wxBITMAP_TYPE_ANY)) + self.addPeerBtn = wxBitmapButton(self.networkPane, -1, wxBitmap(isnDataDir + "connect.png", wxBITMAP_TYPE_ANY)) self.list_box_1 = wxListBox(self.networkPane, -1, choices=[_("choice 1")]) self.__set_properties() @@ -64,7 +64,7 @@ # end wxGlade ### Events -# EVT_BUTTON (self, self.addDirBtn.GetId(), self.onAddDir) + EVT_BUTTON (self, self.addPeerBtn.GetId(), self.onAddPeer) # EVT_LIST_ITEM_SELECTED(self, self.thumbList.GetId(), self.onThumbSelected) # EVT_LIST_ITEM_RIGHT_CLICK(self, self.thumbList.GetId(), self.onThumbActivated) logging.debug("GUI started") @@ -72,10 +72,7 @@ def __set_properties(self): # begin wxGlade: MainFrame.__set_properties self.SetTitle(_("imgSeekNet")) - _icon = wxEmptyIcon() - _icon.CopyFromBitmap(wxBitmap(_(isnDataDir + "imgSeekLite.ico"), wxBITMAP_TYPE_ANY)) - self.SetIcon(_icon) - self.SetSize((866, 744)) + self.SetSize((824, 419)) self.mStatusBar.SetStatusWidths([-1, -1]) # statusbar fields mStatusBar_fields = [_("Empty collection"), _("Ready.")] @@ -88,7 +85,8 @@ self.dirTree.SetToolTipString(_("Select a directory and choose an action")) self.recursiveCheck.SetValue(1) self.addDirBtn.SetSize(self.addDirBtn.GetBestSize()) - self.bitmap_button_1.SetSize(self.bitmap_button_1.GetBestSize()) + self.addPeerBtn.SetToolTipString(_("Add this peer manually")) + self.addPeerBtn.SetSize(self.addPeerBtn.GetBestSize()) self.list_box_1.SetSelection(0) # end wxGlade @@ -135,13 +133,13 @@ sizer_2.AddGrowableRow(0) sizer_2.AddGrowableRow(1) sizer_2.AddGrowableCol(0) - grid_sizer_3.Add(self.mNetworkToolbar, 1, wxEXPAND, 0) + grid_sizer_3.Add(self.mNetworkToolbar, 1, wxALL|wxEXPAND, 0) grid_sizer_4.Add(self.list_ctrl_1, 1, wxEXPAND, 0) sizer_9.Add(self.label_1, 0, wxALL, 5) sizer_9.Add(self.text_ctrl_1, 0, 0, 0) sizer_9.Add(self.label_2, 0, wxALL, 5) sizer_9.Add(self.text_ctrl_2, 0, 0, 0) - sizer_9.Add(self.bitmap_button_1, 0, wxLEFT|wxEXPAND, 5) + sizer_9.Add(self.addPeerBtn, 0, wxLEFT|wxEXPAND, 5) grid_sizer_4.Add(sizer_9, 1, wxALL|wxEXPAND, 5) grid_sizer_4.AddGrowableRow(0) grid_sizer_4.AddGrowableCol(0) @@ -163,6 +161,9 @@ self.SetSizer(sizer_1) self.Layout() # end wxGlade + + def onAddPeer(self,evt): + print "adp" # end of class MainFrame Index: isn.wxg =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/gui/isn.wxg,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- isn.wxg 20 Sep 2003 19:51:23 -0000 1.2 +++ isn.wxg 12 Oct 2003 00:04:38 -0000 1.3 @@ -1,14 +1,13 @@ <?xml version="1.0"?> -<!-- generated by wxGlade 0.3 on Sat Sep 20 16:44:24 2003 --> +<!-- generated by wxGlade 0.3 on Sat Oct 11 21:11:28 2003 --> <application path="/home/rnc/prj/imgseek-net/isnLib/gui" name="imgSeekNet" class="imgSeekNetApp" option="1" language="python" top_window="mMainFrame" encoding="ISO-8859-1" use_gettext="1" overwrite="0"> <object class="MainFrame" name="mMainFrame" base="EditFrame"> <style>wxDEFAULT_FRAME_STYLE</style> - <icon>/home/rnc/prj/imgseek-net/isnData/imgSeekLite.ico</icon> <title>imgSeekNet</title> <menubar>1</menubar> <statusbar>1</statusbar> - <size>866, 744</size> + <size>824, 419</size> <object class="wxMenuBar" name="mMenuBar" base="EditMenuBar"> <menus> <menu name="" label="&Local"> @@ -233,7 +232,7 @@ <cols>1</cols> <vgap>0</vgap> <object class="sizeritem"> - <flag>wxEXPAND</flag> + <flag>wxALL|wxEXPAND</flag> <border>0</border> <option>1</option> <object class="networkToolbar" name="mNetworkToolbar" base="CustomWidget"> @@ -310,7 +309,8 @@ <flag>wxLEFT|wxEXPAND</flag> <border>5</border> <option>0</option> - <object class="wxBitmapButton" name="bitmap_button_1" base="EditBitmapButton"> + <object class="wxBitmapButton" name="addPeerBtn" base="EditBitmapButton"> + <tooltip>Add this peer manually</tooltip> <bitmap>/home/rnc/prj/imgseek-net/isnData/connect.png</bitmap> </object> </object> |
From: <nie...@us...> - 2003-10-11 23:03:38
|
Update of /cvsroot/imgseek/imgseek-net2 In directory sc8-pr-cvs1:/tmp/cvs-serv25917 Modified Files: imgSeekNet Log Message: architecture change. peerManager and imgServer are now called and tracked by core.py module Index: imgSeekNet =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/imgSeekNet,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- imgSeekNet 5 Oct 2003 01:36:01 -0000 1.9 +++ imgSeekNet 11 Oct 2003 23:03:34 -0000 1.10 @@ -20,6 +20,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************""" + if __name__ == "__main__": from isnLib import imgSeekNetApp imgSeekNetApp.run() + |
From: <nie...@us...> - 2003-10-11 23:03:38
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib In directory sc8-pr-cvs1:/tmp/cvs-serv25917/isnLib Modified Files: __init__.py core.py imgSeekNetApp.py Log Message: architecture change. peerManager and imgServer are now called and tracked by core.py module Index: __init__.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/__init__.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- __init__.py 11 Oct 2003 18:09:10 -0000 1.5 +++ __init__.py 11 Oct 2003 23:03:34 -0000 1.6 @@ -11,6 +11,7 @@ __all__ = ["gui", "net", "img", + "core", "coreEnv", "Settings", "imgSeekNetApp", @@ -27,7 +28,8 @@ hdlr = logging.FileHandler("imgSeekNet.log") hdlr.setFormatter(fmt) logging.getLogger("").addHandler(hdlr) - + + #TODO0: override logging.exception to show "Please submit bugreports to foo...@as..." #TODO3: setup file logging as a default option. Right now it's disabled #setFileLog() Index: core.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/core.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- core.py 11 Oct 2003 22:33:38 -0000 1.1 +++ core.py 11 Oct 2003 23:03:34 -0000 1.2 @@ -42,21 +42,25 @@ from net.peerManager import peerManager self.env.peerMgr = peerManager(self.env) - reactor.callLater(self.env.opts.net.refresh_status_delay, self.refresh) + # peerManager.__init__ should load all net-related settings + assert(self.env.opts.net.save_peer_cache_interval) + reactor.callLater(self.env.opts.net.save_peer_cache_interval, self.savePeerCache) def startServer(self): from net.imgServer import imgServer logging.info("Starting server ...") sport = self.env.opts.core.server_port + assert(sport) self.env.app = app.Application("imgSeekNetServer") + assert(self.env.app) self.env.imgServer = imgServer(self.env) self.env.app.listenTCP(sport, pb.PBServerFactory(self.env.imgServer)) def savePeerCache(self): logging.debug("savePeerCache") - reactor.callLater(self.env.opts.net.refresh_status_delay, self.refresh) + reactor.callLater(self.env.opts.net.save_peer_cache_interval, self.savePeerCache) Index: imgSeekNetApp.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/imgSeekNetApp.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- imgSeekNetApp.py 11 Oct 2003 20:31:08 -0000 1.10 +++ imgSeekNetApp.py 11 Oct 2003 23:03:34 -0000 1.11 @@ -1,6 +1,5 @@ -#! /usr/bin/env python """ imgSeekNet - Main App. Load ImgDB module dinamically, load preferences, - setup logging, apply internationalization + setup logging, apply internationalization, start core. *************************************************************************** begin : Sat Oct 4, 2003 3:52 PM copyright : (C) 2003 by Ricardo Niederberger Cabral @@ -23,7 +22,6 @@ ***************************************************************************""" import logging -#TODO0: override logging.exception to show "Please submit bugreports to foo...@as..." def run(): startGUI = 1 @@ -39,7 +37,7 @@ # load the proper database module backend dinamically from the core config option try: ImgDB = __import__('isnLib.img.'+ env.opts.core.db_module, globals(), locals(), [env.opts.core.db_module]) - logging.info("Imported "+ImgDB.__name__) + logging.info("Imported '%s'"% ImgDB.__name__) except ImportError: logging.exception("Fatal error while importing:" + env.opts.core.db_module) return None @@ -54,8 +52,6 @@ #TODO0: REMOVE ME BEFORE RELEASE ARRGHHH #sys.path.append('/home/rnc/prj/imgseek-net/isnLib/net') - from isnLib.net.imgServer import startServer - if '-s' not in sys.argv: # start GUI before server import gettext gettext.install("imgSeekNet") @@ -64,11 +60,11 @@ #lang2.install() from isnLib.gui.imgSeekNet import imgSeekNetApp - from twisted.internet import wxsupport #,reactor - #imgSeekNetApp(0).MainLoop() + from twisted.internet import wxsupport wxsupport.install(imgSeekNetApp(0)) - #reactor.run() - - startServer(env) - logging.info("[--- imgSeekNet finished ---]") + + from isnLib.core import core + mainCore = core(env) + + logging.info("[--- imgSeekNet shutdown ---]") logging.shutdown() |
From: <nie...@us...> - 2003-10-11 23:03:38
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/net In directory sc8-pr-cvs1:/tmp/cvs-serv25917/isnLib/net Modified Files: __init__.py peerManager.py Log Message: architecture change. peerManager and imgServer are now called and tracked by core.py module Index: __init__.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- __init__.py 11 Oct 2003 20:08:18 -0000 1.4 +++ __init__.py 11 Oct 2003 23:03:34 -0000 1.5 @@ -22,5 +22,5 @@ __all__ = ["serverManager", "imgClient", - "imgServer", + "imgServer", ] Index: peerManager.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/peerManager.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- peerManager.py 11 Oct 2003 22:33:01 -0000 1.3 +++ peerManager.py 11 Oct 2003 23:03:34 -0000 1.4 @@ -29,8 +29,9 @@ class netOpts: def __init__(self): - self.refresh_status_delay = 5 # delay - + self.refresh_status_interval = 5 # interval + self.save_peer_cache_interval = 10 + class peerManager: def __init__(self,env): self.env = env @@ -38,7 +39,8 @@ self.env.loadSettings('net',netOpts) - reactor.callLater(self.env.opts.net.refresh_status_delay, self.refresh) + assert(self.env.opts.net.refresh_status_interval) + reactor.callLater(self.env.opts.net.refresh_status_interval, self.refresh) logging.debug("serverManager init") def refresh(self): @@ -46,7 +48,7 @@ for peer in self.peers: server.root.callRemote("getStatus").addCallbacks(server.gotStatus,server.errStatus) - reactor.callLater(self.env.opts.net.refresh_status_delay, self.refresh) + reactor.callLater(self.env.opts.net.refresh_status_interval, self.refresh) def addPeer(self,peer): self.peers.append(peer) |
From: <nie...@us...> - 2003-10-11 22:33:42
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib In directory sc8-pr-cvs1:/tmp/cvs-serv22129/isnLib Added Files: core.py Log Message: architecture change. peerManager and imgServer are now called and tracked by core.py module --- NEW FILE: core.py --- """ imgSeekNet - core *************************************************************************** begin : Sat Oct 11, 2003 7:32 PM copyright : (C) 2003 by Ricardo Niederberger Cabral email : nieder at mail dot ru $Id: core.py,v 1.1 2003/10/11 22:33:38 niederberger Exp $ *************************************************************************** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************""" import logging try: from twisted.spread import pb from twisted.internet import app, reactor except ImportError: logging.error("Please install Twisted (http://www.twistedmatrix.com/products/download)") class core: def __init__(self,env): self.env = env self.startServer() logging.debug("core init. Now running Twisted event engine...") self.env.app.run(save=0) logging.debug("core exit.") def startPeerManager(self): from net.peerManager import peerManager self.env.peerMgr = peerManager(self.env) reactor.callLater(self.env.opts.net.refresh_status_delay, self.refresh) def startServer(self): from net.imgServer import imgServer logging.info("Starting server ...") sport = self.env.opts.core.server_port self.env.app = app.Application("imgSeekNetServer") self.env.imgServer = imgServer(self.env) self.env.app.listenTCP(sport, pb.PBServerFactory(self.env.imgServer)) def savePeerCache(self): logging.debug("savePeerCache") reactor.callLater(self.env.opts.net.refresh_status_delay, self.refresh) ## def authorizer(self, peer): ## """returns True if this peer ip address should be granted access to private imgdb methods ## """ ## return self.auth_ip_re.match(peer, 0) |
From: <nie...@us...> - 2003-10-11 22:33:04
|
Update of /cvsroot/imgseek/imgseek-net2/isnLib/net In directory sc8-pr-cvs1:/tmp/cvs-serv21993/isnLib/net Modified Files: imgServer.py peerManager.py Log Message: architecture change. peerManager and imgServer are now called and tracked by core.py module Index: imgServer.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/imgServer.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- imgServer.py 11 Oct 2003 22:07:46 -0000 1.18 +++ imgServer.py 11 Oct 2003 22:33:01 -0000 1.19 @@ -39,7 +39,7 @@ failsafe = [os.path.expanduser(x) for x in failsafe] map(sys.path.append, failsafe) try: - from twisted.spread import pb + from twisted.spread import pb except ImportError: logging.error("Please install Twisted (http://www.twistedmatrix.com/products/download)") @@ -64,24 +64,3 @@ stat = {'uptime': time() - self.startTime} return stat -def startServer(env): - logging.info("Starting server ...") - sport = env.opts.core.server_port - - from twisted.internet import app - - env.app = app.Application("imgSeekNetServer") - env.imgServer = imgServer(env) - env.app.listenTCP(sport, pb.PBServerFactory(env.imgServer)) - env.app.run(save=0) - - #logging.info("Server Status:"+ str(root.rimgdb.getStatus())) - #logging.info("Server listening on port %d ..." % sport) - - logging.info("... server stopped.") - - -## def authorizer(self, peer): -## """returns True if this peer ip address should be granted access to private imgdb methods -## """ -## return self.auth_ip_re.match(peer, 0) Index: peerManager.py =================================================================== RCS file: /cvsroot/imgseek/imgseek-net2/isnLib/net/peerManager.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- peerManager.py 11 Oct 2003 22:10:41 -0000 1.2 +++ peerManager.py 11 Oct 2003 22:33:01 -0000 1.3 @@ -47,3 +47,7 @@ server.root.callRemote("getStatus").addCallbacks(server.gotStatus,server.errStatus) reactor.callLater(self.env.opts.net.refresh_status_delay, self.refresh) + + def addPeer(self,peer): + self.peers.append(peer) + |