Example #1
0
	def __init__(self, parent=None):
		QDialog.__init__(self, parent)
		self.achoParent = parent
		self.ui = Ui_OpenA()
		self.ui.setupUi(self)
		self.setModal(True)
		#self.ui.tab1.setLayout(self.ui.verticalLayout)
		#self.ui.tab2.setLayout(self.ui.gridLayout)
		#self.ui.sliceBox.setLayout(self.ui.gl1)
		#self.ui.endpointBox.setLayout(self.ui.hl2)
		self.ui.tabWidget.setTabEnabled(0, True)
		self.ui.tabWidget.setTabEnabled(1, False)
		self.slicePath = str(self.ui.slicePathWidget.text())
		self.endpoint = ''
		self.connect(self.ui.slicePathWidget, SIGNAL('textChanged(str)'), self.sliceChanged)
		self.connect(self.ui.button, SIGNAL('clicked()'), self.slotSelect)
		self.connect(self.ui.buttonBox1, SIGNAL('accepted()'), self.slotAccepted1)
		self.connect(self.ui.buttonBox1, SIGNAL('rejected()'), self.slotRejected)
		self.ui.buttonBox1.setFocus()
Example #2
0
	def __init__(self, parent=None):
		QDialog.__init__(self, parent)
		self.achoParent = parent
		self.ui = Ui_OpenA()
		self.ui.setupUi(self)
		self.setModal(True)
		#self.ui.tab1.setLayout(self.ui.verticalLayout)
		#self.ui.tab2.setLayout(self.ui.gridLayout)
		#self.ui.sliceBox.setLayout(self.ui.gl1)
		#self.ui.endpointBox.setLayout(self.ui.hl2)
		self.ui.tabWidget.setTabEnabled(0, True)
		self.ui.tabWidget.setTabEnabled(1, False)
		self.slicePath = str(self.ui.slicePathWidget.text())
		self.endpoint = ''
		self.connect(self.ui.slicePathWidget, SIGNAL('textChanged(QString)'), self.sliceChanged)
		self.connect(self.ui.button, SIGNAL('clicked()'), self.slotSelect)
		self.connect(self.ui.buttonBox1, SIGNAL('accepted()'), self.slotAccepted1)
		self.connect(self.ui.buttonBox1, SIGNAL('rejected()'), self.slotRejected)
		self.ui.buttonBox1.setFocus()
Example #3
0
class OpenConnection(QDialog):
	done = Signal()
	def __init__(self, parent=None):
		QDialog.__init__(self, parent)
		self.achoParent = parent
		self.ui = Ui_OpenA()
		self.ui.setupUi(self)
		self.setModal(True)
		#self.ui.tab1.setLayout(self.ui.verticalLayout)
		#self.ui.tab2.setLayout(self.ui.gridLayout)
		#self.ui.sliceBox.setLayout(self.ui.gl1)
		#self.ui.endpointBox.setLayout(self.ui.hl2)
		self.ui.tabWidget.setTabEnabled(0, True)
		self.ui.tabWidget.setTabEnabled(1, False)
		self.slicePath = str(self.ui.slicePathWidget.text())
		self.endpoint = ''
		self.connect(self.ui.slicePathWidget, SIGNAL('textChanged(str)'), self.sliceChanged)
		self.connect(self.ui.button, SIGNAL('clicked()'), self.slotSelect)
		self.connect(self.ui.buttonBox1, SIGNAL('accepted()'), self.slotAccepted1)
		self.connect(self.ui.buttonBox1, SIGNAL('rejected()'), self.slotRejected)
		self.ui.buttonBox1.setFocus()
	def loadConfig(self, config, root):
		# Automatically set slice path
		self.slicePath = ROBOCOMP + "/" + config[0]
		self.ui.slicePathWidget.setText(self.slicePath)
		# Automatically set slice options
		pathsplit = self.slicePath.rsplit('/', 1)
		if len(pathsplit)>1:
			self.ui.sliceOpts.append(self.slicePath.rsplit('/', 1)[0]+'/')
		# Automatically set endpoint name
		self.ui.endpointName.setText(config[1])
		# Automatically set host name
		self.ui.hostName.setText(config[2])
		# Automatically set endpoint protocol
		if config[3].split()[0] == 'tcp':
			self.ui.endpointProtocol.setCurrentIndex(0)
		elif config[3].split()[0] == 'udp':
			self.ui.endpointProtocol.setCurrentIndex(1)
		elif config[3].split()[0] == 'ws':
			self.ui.endpointProtocol.setCurrentIndex(2)
		else:
			print('Wrong protocol:', config[3].split()[0])
			sys.exit()
		# Automatically set endpoint port number
		self.ui.endpointPort.setValue(int(config[4]))
		# Automatically set code
		codePath = root
		if len(codePath)>0:
			codePath += "/"
		codePath += config[5]
		try:
			print ('Opening code file <'+codePath+'>')
			f = open(codePath, 'r')
		except:
			print ('Cannot open code file <'+codePath+'>')
			sys.exit(1)
		self.slotAccepted1()
		self.ui.textEdit.setText('')
		#print ('<CODE')
		for line in f.readlines():
			self.ui.textEdit.append(line.rstrip())
			#print (line)
		#print ('CODE>')
		self.slotAccepted2()
	def sliceChanged(self, qstr):
		if self.ui.endpointName.text().size() == 0:
			filename = qstr.split('/')[-1]
			ifname = filename.split('.ice')[0].toLower()
			self.ui.endpointName.setText(ifname)
	def resizeEvent(self, ev):
		newSize = ev.size()
		newSize.setWidth(newSize.width() - 10)
		newSize.setHeight(newSize.height() - 10)
		self.ui.tabWidget.resize(newSize)
		self.ui.tabWidget.move(5, 5)
	def slotSelect(self):
		self.slicePath = str(QFileDialog.getOpenFileName(self, 'Select an slice file (*.ice)', '.', '*.ice' ))
		self.ui.slicePathWidget.setText(self.slicePath)
		pathsplit = self.slicePath.rsplit('/', 1)
		if len(pathsplit)>1:
			self.ui.sliceOpts.append(+'/')
	def slotAccepted1(self):
		self.endpoint = str(self.ui.endpointName.text() + ': ')
		self.endpoint = self.endpoint + str(self.ui.endpointProtocol.currentText() + ' -p ' + self.ui.endpointPort.text())
		if len(str(self.ui.hostName.text())) != 0:
			self.endpoint = self.endpoint + str(' -h ' + self.ui.hostName.text() + ' ')
		#print (self.endpoint)
		sliceOpts = ''
		for directory in str(self.ui.sliceOpts.toPlainText()).split('\n'):
			if len(directory)>0:
				sliceOpts = sliceOpts + ' -I' + directory + ' '
		sliceOpts = sliceOpts + ' -I. '
		sliceOpts = sliceOpts + ' -I' + ROBOCOMP + '/interfaces '
		sliceOpts = sliceOpts + ' --all'
		print ('Slice options:', sliceOpts)
		self.sr = SliceReader(self.slicePath, sliceOpts)

		self.importedSymbols = ''
		proxyName = ''
		for key in self.sr.RoboComps.keys():
			for element in dir(self.sr.RoboComps[key]):
				if element[:3] != '_t_' and element[:2] != '__':
					self.importedSymbols += element+'\n'
				if element[-3:] == 'Prx' and element[:3] == '_t_':
					proxyName = element[3:]
			self.ui.symbolsText.insertPlainText(self.importedSymbols)
			self.importedMethods = ''
			if proxyName != '':
				proxyClassName = 'self.sr.RoboComps[\''+key+'\'].' + proxyName
				proxyUncasted = eval(proxyClassName)
				for element in dir(proxyUncasted):
					if element[:4] != 'ice_' and element[:2] != '__':
						self.importedMethods += element+'\n'
				self.ui.methodsText.insertPlainText(self.importedMethods)

		self.ui.tabWidget.setTabEnabled(0, False)
		self.ui.tabWidget.setTabEnabled(1, True)
		self.connect(self.ui.buttonBox2, SIGNAL('accepted()'), self.slotAccepted2)
		self.connect(self.ui.buttonBox2, SIGNAL('rejected()'), self.slotRejected)
		self.ui.tabWidget.setCurrentIndex(1)
		self.achoParent.ui.menuTemplates.setEnabled(True)
		self.ui.buttonBox2.setFocus()
	def slotAccepted2(self):
		self.achoParent.ui.menuTemplates.setEnabled(False)
		src = str(self.ui.textEdit.toPlainText())
		self.module = importCode(src, 'modulillo')
		self.hide()
		self.done.emit()
	def slotRejected(self):
		self.hide()
Example #4
0
class OpenConnection(QDialog):
	def __init__(self, parent=None):
		QDialog.__init__(self, parent)
		self.achoParent = parent
		self.ui = Ui_OpenA()
		self.ui.setupUi(self)
		self.setModal(True)
		#self.ui.tab1.setLayout(self.ui.verticalLayout)
		#self.ui.tab2.setLayout(self.ui.gridLayout)
		#self.ui.sliceBox.setLayout(self.ui.gl1)
		#self.ui.endpointBox.setLayout(self.ui.hl2)
		self.ui.tabWidget.setTabEnabled(0, True)
		self.ui.tabWidget.setTabEnabled(1, False)
		self.slicePath = str(self.ui.slicePathWidget.text())
		self.endpoint = ''
		self.connect(self.ui.slicePathWidget, SIGNAL('textChanged(QString)'), self.sliceChanged)
		self.connect(self.ui.button, SIGNAL('clicked()'), self.slotSelect)
		self.connect(self.ui.buttonBox1, SIGNAL('accepted()'), self.slotAccepted1)
		self.connect(self.ui.buttonBox1, SIGNAL('rejected()'), self.slotRejected)
		self.ui.buttonBox1.setFocus()
	def loadConfig(self, config, root):
		# Automatically set slice path
		self.slicePath = ROBOCOMP + "/" + config[0]
		self.ui.slicePathWidget.setText(self.slicePath)
		# Automatically set slice options
		pathsplit = self.slicePath.rsplit('/', 1)
		if len(pathsplit)>1:
			self.ui.sliceOpts.append(self.slicePath.rsplit('/', 1)[0]+'/')
		# Automatically set endpoint name
		self.ui.endpointName.setText(config[1])
		# Automatically set host name
		self.ui.hostName.setText(config[2])
		# Automatically set endpoint protocol
		if (config[3].split()[0] == 'tcp'):
			self.ui.endpointProtocol.setCurrentIndex(0)
		elif (config[3].split()[0] == 'udp'):
			self.ui.endpointProtocol.setCurrentIndex(1)
		else:
			print 'Wrong protocol:',config[3].split()[0]
			sys.exit()
		# Automatically set endpoint port number
		self.ui.endpointPort.setValue(int(config[4]))
		# Automatically set code
		codePath = root
		if len(codePath)>0:
			codePath += "/"
		codePath += config[5]
		try:
			print 'Opening code file <'+codePath+'>'
			f = open(codePath, 'r')
		except:
			print 'Cannot open code file <'+codePath+'>'
			sys.exit(1)
		self.slotAccepted1()
		self.ui.textEdit.setText('')
		#print '<CODE'
		for line in f.readlines():
			self.ui.textEdit.append(line.rstrip())
			#print line,
		#print 'CODE>'
		self.slotAccepted2()
	def sliceChanged(self, qstr):
		if self.ui.endpointName.text().size() == 0:
			filename = qstr.split('/')[-1]
			ifname = filename.split('.ice')[0].toLower()
			self.ui.endpointName.setText(ifname)
	def resizeEvent(self, ev):
		newSize = ev.size()
		newSize.setWidth(newSize.width() - 10)
		newSize.setHeight(newSize.height() - 10)
		self.ui.tabWidget.resize(newSize)
		self.ui.tabWidget.move(5, 5)
	def slotSelect(self):
		self.slicePath = str(QFileDialog.getOpenFileName(self, 'Select an slice file (*.ice)', '.', '*.ice' ))
		self.ui.slicePathWidget.setText(self.slicePath)
		pathsplit = self.slicePath.rsplit('/', 1)
		if len(pathsplit)>1:
			self.ui.sliceOpts.append(+'/')
	def slotAccepted1(self):
		self.endpoint = str(self.ui.endpointName.text() + ': ')
		self.endpoint = self.endpoint + str(self.ui.endpointProtocol.currentText() + ' -p ' + self.ui.endpointPort.text())
		if len(str(self.ui.hostName.text())) != 0:
			self.endpoint = self.endpoint + str(' -h ' + self.ui.hostName.text() + ' ')
		#print self.endpoint
		sliceOpts = ''
		for directory in str(self.ui.sliceOpts.toPlainText()).split('\n'):
			if len(directory)>0:
				sliceOpts = sliceOpts + ' -I' + directory + ' '
		sliceOpts = sliceOpts + ' -I. '
		sliceOpts = sliceOpts + ' -I' + ROBOCOMP + '/interfaces '
		sliceOpts = sliceOpts + ' --all'
		print 'Slice options:', sliceOpts
		self.sr = SliceReader(self.slicePath, sliceOpts)

		self.importedSymbols = ''
		proxyName = ''
		for key in self.sr.RoboComps.keys():
			for element in dir(self.sr.RoboComps[key]):
				if element[:3] != '_t_' and element[:2] != '__':
					self.importedSymbols += element+'\n'
				if element[-3:] == 'Prx' and element[:3] == '_t_':
					proxyName = element[3:]
			self.ui.symbolsText.insertPlainText(self.importedSymbols)
			self.importedMethods = ''
			if proxyName != '':
				proxyClassName = 'self.sr.RoboComps[\''+key+'\'].' + proxyName
				proxyUncasted = eval(proxyClassName)
				for element in dir(proxyUncasted):
					if element[:4] != 'ice_' and element[:2] != '__':
						self.importedMethods += element+'\n'
				self.ui.methodsText.insertPlainText(self.importedMethods)

		self.ui.tabWidget.setTabEnabled(0, False)
		self.ui.tabWidget.setTabEnabled(1, True)
		self.connect(self.ui.buttonBox2, SIGNAL('accepted()'), self.slotAccepted2)
		self.connect(self.ui.buttonBox2, SIGNAL('rejected()'), self.slotRejected)
		self.ui.tabWidget.setCurrentIndex(1)
		self.achoParent.ui.menuTemplates.setEnabled(True)
		self.ui.buttonBox2.setFocus()
	def slotAccepted2(self):
		self.achoParent.ui.menuTemplates.setEnabled(False)
		src = str(self.ui.textEdit.toPlainText())
		self.module = importCode(src, 'modulillo')
		self.hide()
		self.emit(SIGNAL("done()"))
	def slotRejected(self):
		self.hide()