Commit bae6cf0f authored by nextime's avatar nextime

Move getPage in board modules to base class

parent 045c55b8
...@@ -52,7 +52,11 @@ class BaseBoard(object): ...@@ -52,7 +52,11 @@ class BaseBoard(object):
hasInputs = False hasInputs = False
hasPWMs = False hasPWMs = False
hasRelays = False hasRelays = False
pwd=False
user="system"
def requestPage(self, uri):
return wu.getPage(uri, http_user=self.user, http_password=self.pwd)
class BoardAnalog(object): class BoardAnalog(object):
""" """ """ """
......
...@@ -87,11 +87,11 @@ class DMBoard(BaseBoard): ...@@ -87,11 +87,11 @@ class DMBoard(BaseBoard):
return defer.succeed(True) return defer.succeed(True)
def _getBoardConfig(self, *a): def _getBoardConfig(self, *a):
return wu.getPage("http://"+self.host+":"+str(self.port)+"/ajax.xml", http_user="system", http_password=self.pwd) return self.requestPage("http://"+self.host+":"+str(self.port)+"/ajax.xml")
def _getIOConfig(self, *a): def _getIOConfig(self, *a):
return wu.getPage("http://"+self.host+":"+str(self.port)+"/ioconf.xml", http_user="system", http_password=self.pwd) return self.requestPage("http://"+self.host+":"+str(self.port)+"/ioconf.xml")
def getAnalogsNames(self): def getAnalogsNames(self):
if not self.analist: if not self.analist:
ret = {} ret = {}
......
...@@ -84,11 +84,12 @@ class DMBoard(BaseBoard): ...@@ -84,11 +84,12 @@ class DMBoard(BaseBoard):
self.ioXML = xml.parseXMLString(res) self.ioXML = xml.parseXMLString(res)
return defer.succeed(True) return defer.succeed(True)
def _getBoardConfig(self, *a): def _getBoardConfig(self, *a):
return wu.getPage("http://"+self.host+":"+str(self.port)+"/ajax.xml", http_user="system", http_password=self.pwd) return self.requestPage("http://"+self.host+":"+str(self.port)+"/ajax.xml")
def _getIOConfig(self, *a): def _getIOConfig(self, *a):
return wu.getPage("http://"+self.host+":"+str(self.port)+"/ioconf.xml", http_user="system", http_password=self.pwd) return self.requestPage("http://"+self.host+":"+str(self.port)+"/ioconf.xml")
def getAnalogsNames(self): def getAnalogsNames(self):
if not self.analist: if not self.analist:
......
...@@ -86,11 +86,11 @@ class DMBoard(BaseBoard): ...@@ -86,11 +86,11 @@ class DMBoard(BaseBoard):
return defer.succeed(True) return defer.succeed(True)
def _getBoardConfig(self, *a): def _getBoardConfig(self, *a):
return wu.getPage("http://"+self.host+":"+str(self.port)+"/ajax.xml", http_user="system", http_password=self.pwd) return self.requestPage("http://"+self.host+":"+str(self.port)+"/ajax.xml")
def _getIOConfig(self, *a): def _getIOConfig(self, *a):
return wu.getPage("http://"+self.host+":"+str(self.port)+"/ioconf.xml", http_user="system", http_password=self.pwd) return self.requestPage("http://"+self.host+":"+str(self.port)+"/ioconf.xml")
def getAnalogsNames(self): def getAnalogsNames(self):
return self.analist return self.analist
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment