예제 #1
0
def loadLocalConfig(
	onlyTemplates=False, master_config_file=None, node_config_file=None, rg_config_file=None, 
	systemTemplateDir = None, overrideTemplateDir = None):
	"""
	Load the local system configuration. Can load templates only, if needed.
	"""
	if master_config_file is None:
		master_config_file = vsapi.masterConfigFile
	if node_config_file is None:
		node_config_file = vsapi.nodeConfigFile
	if rg_config_file is None:
		rg_config_file = vsapi.rgConfigFile
	if systemTemplateDir is None:
		systemTemplateDir = vsapi.systemTemplateDir
	if overrideTemplateDir is None:
		overrideTemplateDir = vsapi.overrideTemplateDir
	sysConfig = {
		'templates' : { 'gpu' : {} , 'display' : {}, 'keyboard' : {}, 'mouse' : {}  }, 
		'nodes' : {},
		'resource_groups' : {}
	}

	# Load all templates...
	# NOTE: We load the templates from the global directory first.
	# Then load them from the local directory. This way, we ensure
	# that the local templates override the global ones.

	# Load GPU templates
	fileList = glob('%s/gpus/*.xml'%(systemTemplateDir))
	fileList += glob('%s/gpus/*.xml'%(overrideTemplateDir))
	for fname in fileList:
		try:
			dom = minidom.parse(fname)
		except xml.parsers.expat.ExpatError, e:
			raise vsapi.VizError(vsapi.VizError.BAD_CONFIGURATION, "Failed to parse XML file '%s'. Reason: %s"%(fname, str(e)))

		newObj = vsapi.deserializeVizResource(dom.documentElement, [vsapi.GPU])	
		sysConfig['templates']['gpu'][newObj.getType()] = newObj
예제 #2
0
# 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#
# test_ser.py
#
# Serialization/deserialization tests.

import vsapi
from xml.dom import minidom

gpu = vsapi.GPU(0)
gpu.setScanout(0, "DFP", "dummy", "1600x1200_60")
ser = gpu.serializeToXML()
print "Serializing GPU"
print ser

dom = minidom.parseString(ser)
deser = vsapi.deserializeVizResource(dom.documentElement)

print "Deserializing that and serializing again gives the GPU"
print deser.serializeToXML()
예제 #3
0
		except xml.parsers.expat.ExpatError, e:
			raise vsapi.VizError(vsapi.VizError.BAD_CONFIGURATION, "Failed to parse XML file '%s'. Reason: %s"%(fname, str(e)))

		newObj = vsapi.deserializeVizResource(dom.documentElement, [vsapi.GPU])	
		sysConfig['templates']['gpu'][newObj.getType()] = newObj

	# DisplayDevice templates
	fileList = glob('%s/displays/*.xml'%(systemTemplateDir))
	fileList += glob('%s/displays/*.xml'%(overrideTemplateDir))
	for fname in fileList:
		try:
			dom = minidom.parse(fname)
		except xml.parsers.expat.ExpatError, e:
			raise vsapi.VizError(vsapi.VizError.BAD_CONFIGURATION, "Failed to parse XML file '%s'. Reason: %s"%(fname, str(e)))

		newObj = vsapi.deserializeVizResource(dom.documentElement, [vsapi.DisplayDevice])	
		sysConfig['templates']['display'][newObj.getType()] = newObj

	# Keyboard templates
	fileList = glob('%s/keyboard/*.xml'%(systemTemplateDir))
	fileList += glob('%s/keyboard/*.xml'%(overrideTemplateDir))
	for fname in fileList:
		try:
			dom = minidom.parse(fname)
		except xml.parsers.expat.ExpatError, e:
			raise vsapi.VizError(vsapi.VizError.BAD_CONFIGURATION, "Failed to parse XML file '%s'. Reason: %s"%(fname, str(e)))
		newObj = vsapi.deserializeVizResource(dom.documentElement, [vsapi.Keyboard])
		sysConfig['templates']['keyboard'][newObj.getType()] = newObj

	# Mice templates
	fileList = glob('%s/mouse/*.xml'%(systemTemplateDir))
예제 #4
0
파일: test_ser.py 프로젝트: jappa/VizStack
# 
# 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#
# test_ser.py
#
# Serialization/deserialization tests.

import vsapi
from xml.dom import minidom

gpu = vsapi.GPU(0)
gpu.setScanout(0, "DFP", "dummy","1600x1200_60")
ser = gpu.serializeToXML()
print "Serializing GPU"
print ser

dom = minidom.parseString(ser)
deser = vsapi.deserializeVizResource(dom.documentElement)

print "Deserializing that and serializing again gives the GPU"
print deser.serializeToXML()