[GRASS-SVN] r47417 - grass-addons/grass7/gui/wxpython/wx.wms
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 4 04:35:01 EDT 2011
Author: sudeepsingh
Date: 2011-08-04 01:35:01 -0700 (Thu, 04 Aug 2011)
New Revision: 47417
Added:
grass-addons/grass7/gui/wxpython/wx.wms/LoadConfig.py
Modified:
grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py
grass-addons/grass7/gui/wxpython/wx.wms/addserver.py
grass-addons/grass7/gui/wxpython/wx.wms/config
grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
Log:
Function to load config file moved into this file
Added: grass-addons/grass7/gui/wxpython/wx.wms/LoadConfig.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/LoadConfig.py (rev 0)
+++ grass-addons/grass7/gui/wxpython/wx.wms/LoadConfig.py 2011-08-04 08:35:01 UTC (rev 47417)
@@ -0,0 +1,11 @@
+def loadConfigFile(self):
+ try:
+ f=open('config','r')
+ lines = f.readlines()
+ f.close()
+ self.name_url_delimiter = lines[0].split()[1]
+ print "config file loaded successfully"
+ print self.name_url_delimiter
+ return True
+ except:
+ return False
Modified: grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py 2011-08-04 08:28:07 UTC (rev 47416)
+++ grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py 2011-08-04 08:35:01 UTC (rev 47417)
@@ -27,6 +27,7 @@
def addServerInfo(soup, serverinfo, snamevalue, urlvalue, unamevalue, passwordvalue):
+ snamevalue = unicode(snamevalue)
elements = soup.findAll(id = snamevalue)
if(len(elements)!=0):
return False
@@ -47,6 +48,7 @@
server.insert(3, password)
#Adding attribute to server tag
+
server['id'] = snamevalue
#Adding text values to the server info fields
@@ -57,6 +59,7 @@
return True
def removeServerInfo(soup, serverID):
+ serverID = unicode(serverID)
elements = soup.findAll(id = serverID)
if(len(elements)==0):
return False
@@ -66,6 +69,7 @@
return True
def updateServerInfo(soup, serverinfo, snamevalue, urlvalue, unamevalue, passwordvalue):
+ snamevalue = unicode(snamevalue)
if(removeServerInfo(soup, snamevalue)):
if(addServerInfo(soup, serverinfo, snamevalue, urlvalue, unamevalue, passwordvalue)):
return True
@@ -83,7 +87,7 @@
username = element.findAll('username')[0]
password = element.findAll('password')[0]
serverdata = ServerData()
- serverdata.servername = servername.contents[0].strip()
+ serverdata.servername = unicode(servername.contents[0].strip())
serverdata.url = serverurl.contents[0].strip()
serverdata.username = username.contents[0].strip()
serverdata.password = password.contents[0].strip()
Modified: grass-addons/grass7/gui/wxpython/wx.wms/addserver.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/addserver.py 2011-08-04 08:28:07 UTC (rev 47416)
+++ grass-addons/grass7/gui/wxpython/wx.wms/addserver.py 2011-08-04 08:35:01 UTC (rev 47417)
@@ -5,7 +5,9 @@
import wx
from BeautifulSoup import BeautifulSoup, Tag, NavigableString, BeautifulStoneSoup
from ServerInfoAPIs import addServerInfo, removeServerInfo, updateServerInfo, initServerInfoBase, getAllRows
+from LoadConfig import loadConfigFile
+
# begin wxGlade: extracode
# end wxGlade
@@ -49,6 +51,10 @@
#sudeep code starts
+ if( not loadConfigFile(self)):
+ print 'Config File Error, Unable to start application...'
+ self.Close()
+
self.soup = initServerInfoBase('ServersList.xml')
self.Bind(wx.EVT_CLOSE, self.OnQuit)
self.__populate_URL_List(self.ServerList)
@@ -115,7 +121,8 @@
def __populate_URL_List(self, ComboBox):
self.servers = getAllRows(self.soup)
for key, value in self.servers.items():
- ComboBox.Append(value.servername+" "+value.url)
+ ComboBox.Append(value.servername+self.name_url_delimiter+value.url)
+ #ComboBox.Append(value.servername+" "+value.url)
print self.servers
return
''''f = open('serverList.txt','r')
@@ -144,13 +151,16 @@
def __update_URL_List(self):
self.ServerList.Clear()
- for k,v in self.servers.iteritems():
- name = v.servername+" "+v.url
- self.ServerList.Append(name)
+ for key,value in self.servers.iteritems():
+ #name = v.servername+" "+v.url
+ self.ServerList.Append(value.servername+self.name_url_delimiter+value.url)
+ #self.ServerList.Append(name)
def OnSave(self, event): # wxGlade: ServerAdd.<event_handler>
#print "Event handler `OnSave' not implemented"
- newServerName = self.ServerNameText.GetValue()
+ newServerName = unicode(self.ServerNameText.GetValue())
+ print newServerName
+ print 'check12'
if(self.servers.has_key(newServerName)):
update = True
#print 'Server Name already exists'
@@ -193,11 +203,11 @@
self.__update_URL_List()
#Update_Url_List(newServerName+" "+newUrl)
else:
- print "Please Fill all the fields"
+ print "Please Fill servername and url fields"
event.Skip()
def OnRemove(self, event): # wxGlade: ServerAdd.<event_handler>
- serverName = self.ServerNameText.GetValue()
+ serverName = unicode(self.ServerNameText.GetValue())
if(len(serverName) > 0):
if(removeServerInfo(self.soup, serverName)):
print 'remove successful'
@@ -231,10 +241,10 @@
f = open('ServersList.xml','w')
f.write(xml)
f.close()
- out = open('serverList.txt','w')
+ '''out = open('serverList.txt','w')
for k,v in self.servers.iteritems():
out.write(v.servername+" "+v.url+" "+v.username+" "+v.password+"\n")
- exit()
+ exit()'''
#ServerAdd.Close()
#print "Event handler `OnQuit' not implemented"
event.Skip()
@@ -244,11 +254,11 @@
url = self.ServerList.GetValue()
print 'here'
print url
- urlarr = url.split()
+ urlarr = url.split(self.name_url_delimiter)
print urlarr
print self.servers
if(len(urlarr)==2):
- self.selectedServer = self.servers[urlarr[0]]
+ self.selectedServer = self.servers[unicode(urlarr[0])]
print self.selectedServer
self.ServerNameText.SetValue(self.selectedServer.servername)
self.URLText.SetValue(self.selectedServer.url)
Modified: grass-addons/grass7/gui/wxpython/wx.wms/config
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/config 2011-08-04 08:28:07 UTC (rev 47416)
+++ grass-addons/grass7/gui/wxpython/wx.wms/config 2011-08-04 08:35:01 UTC (rev 47417)
@@ -0,0 +1 @@
+delimeter_servername_url :
Modified: grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-04 08:28:07 UTC (rev 47416)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-04 08:35:01 UTC (rev 47417)
@@ -9,8 +9,8 @@
from WMSMapDisplay import NewImageFrame
from addserver import AddServerFrame
from ServerInfoAPIs import addServerInfo, removeServerInfo, updateServerInfo, initServerInfoBase, getAllRows
+from LoadConfig import loadConfigFile
-
# begin wxGlade: extracode
# end wxGlade
@@ -46,12 +46,18 @@
#Sudeep's Code Starts
#self.urlInput.SetValue('http://www.gisnet.lv/cgi-bin/topo')
+ self.usernameInput.Disable()
+ self.passwordInput.Disable()
+ if( not loadConfigFile(self)):
+ print 'Config File Error, Unable to start application...'
+ self.Close()
+
self.soup = initServerInfoBase('ServersList.xml')
self.__populate_Url_List(self.ServerList)
self.selectedURL="No server selected"
self.layerTreeRoot = self.LayerTree.AddRoot("Layers")
- self.usernameInput.Disable()
- self.passwordInput.Disable()
+
+
#items = ["a", "b", "c"]
#itemId = self.LayerTree.AppendItem(self.layerTreeRoot, "item")
#self.LayerTree.AppendItem(itemId, "inside")
@@ -93,10 +99,14 @@
ComboBox = self.ServerList
ComboBox.Append(name)
+
+
+
def __populate_Url_List(self, ComboBox):
self.servers = getAllRows(self.soup)
for key, value in self.servers.items():
- ComboBox.Append(value.servername+" "+value.url)
+ ComboBox.Append(value.servername+self.name_url_delimiter+value.url)
+ #ComboBox.Append(value.servername+" "+self.name_url_delimiter+" "+value.url)
print self.servers
return
@@ -114,6 +124,10 @@
f.close()'''
def OnGetCapabilities(self, event): # wxGlade: wmsFrame.<event_handler>
+ if(self.selectedURL == "No server selected"):
+ print 'no url selected\n returning...\n'
+ return
+
self.usernameInput.Enable()
self.passwordInput.Enable()
#Sudeep's Code Starts
@@ -196,6 +210,8 @@
def OnServerListEnter(self, event): # wxGlade: wmsFrame.<event_handler>
+ return
+ '''
print "Event handler `OnServerListEnter' not implemented"
#Sudeep's Code Starts
print self.ServerList.CurrentSelection
@@ -216,15 +232,25 @@
print "Format not recognized, Format: Severname URL"
#Sudeep's Code Ends
event.Skip()
-
+ '''
+ def printDict(self,dict):
+ for key in dict.keys():
+ print "the key name is" + key + "and its value is"
+
def OnServerList(self, event): # wxGlade: wmsFrame.<event_handler>
print "Event handler `OnServerList' not implemented"
#Sudeep's Code Starts
print self.ServerList.CurrentSelection
url = self.ServerList.GetValue()
- urlarr = url.split()
+ urlarr = url.split(self.name_url_delimiter)
+ print "OnServerList:printing urlarr"
+ print urlarr
+ print urlarr[0]
+ print urlarr[0].encode()
+ self.printDict(self.servers)
+ print "OnServerList: done"
if(len(urlarr)==2):
- self.selectedURL = self.servers[urlarr[0]].url
+ self.selectedURL = self.servers[urlarr[0].encode()].url
print self.selectedURL
else:
print "Wrong format of URL selected"
More information about the grass-commit
mailing list