[GRASS-SVN] r47465 - grass-addons/grass7/gui/wxpython/wx.wms
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 6 00:46:23 EDT 2011
Author: sudeepsingh
Date: 2011-08-05 21:46:23 -0700 (Fri, 05 Aug 2011)
New Revision: 47465
Modified:
grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py
grass-addons/grass7/gui/wxpython/wx.wms/ServersList.xml
grass-addons/grass7/gui/wxpython/wx.wms/TODO
grass-addons/grass7/gui/wxpython/wx.wms/addserver.py
grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
Log:
some bugs fixed, details in TODO file
Modified: grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py 2011-08-05 19:49:27 UTC (rev 47464)
+++ grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py 2011-08-06 04:46:23 UTC (rev 47465)
@@ -1,11 +1,18 @@
from BeautifulSoup import BeautifulSoup, Tag, BeautifulStoneSoup
+import os.path
class ServerData():
pass
def initServerInfoBase(fileName):
- try:
- f = open(fileName,'r')
+ if(os.path.exists(fileName)):
+ try:
+ os.system('chmod 777 '+fileName)
+ f = open(fileName,'r')
+ except:
+ print 'Unable to open File '+fileName
+ print 'exiting application...'
+ return None, False
xml = f.read()
f.close()
soup = BeautifulStoneSoup(xml)
@@ -13,17 +20,16 @@
#print 'serverinfolisthere'
#print serverinfolist
#print len(serverinfolist)
- except:
+ else:
serverinfolist = []
soup = BeautifulSoup()
xml = "null"
if(len(serverinfolist) == 0):
-
serverinfo = Tag(soup, "serverinfo")
soup.insert(0, serverinfo)
- return soup
+ return soup, True
def addServerInfo(soup, serverinfo, snamevalue, urlvalue, unamevalue, passwordvalue):
Modified: grass-addons/grass7/gui/wxpython/wx.wms/ServersList.xml
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/ServersList.xml 2011-08-05 19:49:27 UTC (rev 47464)
+++ grass-addons/grass7/gui/wxpython/wx.wms/ServersList.xml 2011-08-06 04:46:23 UTC (rev 47465)
@@ -1,18 +1,4 @@
<serverinfo>
- <server id="123">
- <servername>
- 123
- </servername>
- <serverurl>
- 123
- </serverurl>
- <username>
- 123
- </username>
- <password>
- 123
- </password>
- </server>
<server id="asd">
<servername>
asd
@@ -27,18 +13,6 @@
asd
</password>
</server>
- <server id="āšņ ēčžģ12">
- <servername>
- āšņ ēčžģ12
- </servername>
- <serverurl>
- asd12
- </serverurl>
- <username>
- </username>
- <password>
- </password>
- </server>
<server id="ڝڍڑڭڏڧڲ">
<servername>
ڝڍڑڭڏڧڲ
Modified: grass-addons/grass7/gui/wxpython/wx.wms/TODO
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/TODO 2011-08-05 19:49:27 UTC (rev 47464)
+++ grass-addons/grass7/gui/wxpython/wx.wms/TODO 2011-08-06 04:46:23 UTC (rev 47465)
@@ -12,6 +12,8 @@
5.Layers fetched are not being displayed hierarchly, bug known, to be fixed.
+6.In case, on adding or removing a server, if the write to file is unsuccessful, the application removes it from the serverlist, even though is not written in the file.
+So when the application restarts, all the changes done are lost, since data was not written to file successfuly.
More to be added...
Modified: grass-addons/grass7/gui/wxpython/wx.wms/addserver.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/addserver.py 2011-08-05 19:49:27 UTC (rev 47464)
+++ grass-addons/grass7/gui/wxpython/wx.wms/addserver.py 2011-08-06 04:46:23 UTC (rev 47465)
@@ -3,6 +3,7 @@
# generated by wxGlade 0.6.3 on Thu Jul 14 06:22:35 2011
import wx
+import os
from wx.lib.pubsub import Publisher
from BeautifulSoup import BeautifulSoup, Tag, NavigableString, BeautifulStoneSoup
from ServerInfoAPIs import addServerInfo, removeServerInfo, updateServerInfo, initServerInfoBase, getAllRows
@@ -56,9 +57,12 @@
print 'Config File Error, Unable to start application...'
self.Close()
- self.soup = initServerInfoBase('ServersList.xml')
+ self.soup, open = initServerInfoBase('ServersList.xml')
+ if(not open):
+ return
self.Bind(wx.EVT_CLOSE, self.OnQuit)
self.__populate_URL_List(self.ServerList)
+ Publisher().subscribe(self.onWMSMenuClose, ("WMS_Menu_Close"))
#sudeep code ends
def __set_properties(self):
@@ -124,7 +128,7 @@
for key, value in self.servers.items():
ComboBox.Append(value.servername+self.name_url_delimiter+value.url)
#ComboBox.Append(value.servername+" "+value.url)
- print self.servers
+ #print self.servers
return
''''f = open('serverList.txt','r')
lines = f.readlines()
@@ -211,7 +215,7 @@
'''
self.selectedURL = newUrl
print self.selectedURL
- print self.servers
+ #print self.servers
self.__update_URL_List()
#Update_Url_List(newServerName+" "+newUrl)
else:
@@ -225,14 +229,17 @@
print 'remove successful'
else:
print 'remove unsuccessful'
- print self.servers
+ return
+ #print self.servers
+
del self.servers[serverName]
self.__update_URL_List()
+
self.ServerNameText.Clear()
self.PasswordText.Clear()
self.URLText.Clear()
self.UsernameText.Clear()
- print self.servers
+ #print self.servers
self.saveXMLData()
msg = self.servers
Publisher().sendMessage(("update.serverList"), msg)
@@ -252,15 +259,33 @@
def saveXMLData(self):
xml = self.soup.prettify()
- f = open('ServersList.xml','w')
- f.write(xml)
- f.close()
+ try:
+ f = open('templist.xml','w')
+ f.write(xml)
+ f.close()
+ except:
+ print 'Unable to write in templist.xml file, Save not successful'
+ return False
+ try:
+ os.system('chmod 777 ServersList.xml')
+ os.system("cp templist.xml ServersList.xml")
+ #f = open('ServersList.xml','w')
+ except:
+ #print 'cant open file in write mode'
+ print 'cp templist.xml ServersList.xml failed'
+ print 'Save not successful'
+ return False
+ return True
+ def onWMSMenuClose(self, msg):
+ self.Destroy()
+ return
+
def OnQuit(self, event): # wxGlade: ServerAdd.<event_handler>
print 'onQuit pressed'
self.saveXMLData()
msg = self.servers
- Publisher().sendMessage(("update.serverList"), msg)
+ Publisher().sendMessage(("Add_Server_Frame_Closed"), msg)
self.Destroy()
#exit()
#self.Close()
@@ -279,7 +304,7 @@
print url
urlarr = url.split(self.name_url_delimiter)
print urlarr
- print self.servers
+ #print self.servers
if(len(urlarr)==2):
self.selectedServer = self.servers[unicode(urlarr[0])]
print self.selectedServer
Modified: grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-05 19:49:27 UTC (rev 47464)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-06 04:46:23 UTC (rev 47465)
@@ -31,7 +31,7 @@
self.passwordInput = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_TAB|wx.TE_PASSWORD)
self.GetCapabilities = wx.Button(self, -1, "GetCapabilities")
self.GetMaps = wx.Button(self, -1, "GetMaps")
- self.addServer = wx.Button(self, -1, "AddServer")
+ self.addServer = wx.Button(self, -1, "Manage Servers")
self.__set_properties()
self.__do_layout()
@@ -52,13 +52,21 @@
if( not loadConfigFile(self)):
print 'Config File Error, Unable to start application...'
self.Close()
+ return
- self.soup = initServerInfoBase('ServersList.xml')
+ self.soup, open = initServerInfoBase('ServersList.xml')
+ if(not open):
+ self.Close()
+ return
self.__populate_Url_List(self.ServerList)
self.selectedURL="No server selected"
self.layerTreeRoot = self.LayerTree.AddRoot("Layers")
- Publisher().subscribe(self.updateServerList, ("update.serverList"))
+ Publisher().subscribe(self.onAddServerFrameClose, ("Add_Server_Frame_Closed"))
+ Publisher().subscribe(self.onUpdateServerListmessage, ("update.serverList"))
+ self.Bind(wx.EVT_CLOSE, self.OnQuit)
+ self.AddServerisClosed = True
+
#items = ["a", "b", "c"]
#itemId = self.LayerTree.AppendItem(self.layerTreeRoot, "item")
#self.LayerTree.AppendItem(itemId, "inside")
@@ -101,7 +109,7 @@
for key, value in self.servers.items():
ComboBox.Append(value.servername+self.name_url_delimiter+value.url)
#ComboBox.Append(value.servername+" "+self.name_url_delimiter+" "+value.url)
- print self.servers
+ #print self.servers
return
@@ -112,7 +120,7 @@
for key, value in self.servers.items():
ComboBox.Append(value.servername+self.name_url_delimiter+value.url)
#ComboBox.Append(value.servername+" "+self.name_url_delimiter+" "+value.url)
- print self.servers
+ #print self.servers
return
@@ -151,7 +159,6 @@
#xml=f.read()
#f.close()
#self.statusbar.SetStatusText(xml)
-
reslist = parsexml(xml)
populateLayerTree(xml,self.LayerTree, self.layerTreeRoot)
#for res in reslist:
@@ -165,6 +172,11 @@
except URLError, e:
print 'We failed to reach a server.'
print 'Reason: ', e.reason
+ except ValueError, e:
+ print 'Value error'
+ print 'Reason: ', e.reason
+ except:
+ print 'urlopen exception, unable to fetch data for getcapabilities'
else:
print 'Successful'
#Sudeep's Code Ends
@@ -252,7 +264,7 @@
print urlarr
print urlarr[0]
#print urlarr[0].encode()
- self.printDict(self.servers)
+ #self.printDict(self.servers)
print "OnServerList: done"
if(len(urlarr)==2):
self.selectedURL = self.servers[urlarr[0]].url
@@ -285,25 +297,35 @@
#print "Event handler `OnLayerTreeSelChanged' not implemented"
event.Skip()
- def updateServerList(self, msg):
- """
- Shows the frame and shows the message sent in the
- text control
- """
- print 'yoyo'
+ def onAddServerFrameClose(self, msg):
+ self.AddServerisClosed = True
+ self.addServer.Enable()
self.servers = msg.data
self.__update_Url_List(self.ServerList)
- print 'yoyo'
#frame = self.GetParent()
#frame.Show()
+
+ def onUpdateServerListmessage(self, msg):
+ self.servers = msg.data
+ self.__update_Url_List(self.ServerList)
def OnAddServer(self, event): # wxGlade: wmsFrame.<event_handler>
print 'before add server call'
+ self.AddServerisClosed = False
+ self.addServer.Disable()
AddServerFrame(self)
#print 'after add server call'
#print "Event handler `OnAddServer' not implemented"
#event.Skip()
return
+
+ def OnQuit(self, event):
+ msg = ""
+ print 'in quit'
+ if(not self.AddServerisClosed):
+ Publisher().sendMessage(("WMS_Menu_Close"), msg)
+ self.Destroy()
+ return
# end of class wmsFrame
#Sudeep's Code Starts
More information about the grass-commit
mailing list