Exemplo n.º 1
0
    def getOverrideKeys(self):
        """
		This Method Gets Override Keys.
		"""

        LOGGER.info("{0} | Updating Loader Script Override Keys !".format(self.__class__.__name__))

        selectedIblSet = self._coreDatabaseBrowser.getSelectedItems()
        iblSet = selectedIblSet and selectedIblSet[0] or None

        if iblSet:
            if os.path.exists(iblSet._datas.path):
                for index, comboBox in enumerate(self._reWireComboBoxesWidgets):
                    parameter = self._rewiringParameters[comboBox.currentIndex()]
                    if comboBox.currentText() == "Custom Image":
                        LOGGER.debug(
                            "> Adding '{0}' Override Key With Value : '{1}'.".format(
                                comboBox._datas, str(self._reWireLineEditWidgets[index].text())
                            )
                        )
                        self._addonsLoaderScript.overrideKeys[
                            comboBox._datas
                        ] = foundations.parser.getAttributeCompound(
                            parameter[1], strings.getNormalizedPath(str(self._reWireLineEditWidgets[index].text()))
                        )
                    else:
                        LOGGER.debug(
                            "> Adding '{0}' Override Key With Value : '{1}'.".format(
                                comboBox._datas, getattr(iblSet._datas, parameter[2])
                            )
                        )
                        self._addonsLoaderScript.overrideKeys[comboBox._datas] = getattr(
                            iblSet._datas, parameter[2]
                        ) and foundations.parser.getAttributeCompound(
                            parameter[1], strings.getNormalizedPath(getattr(iblSet._datas, parameter[2]))
                        )
Exemplo n.º 2
0
	def testGetNormalizedPath(self):
		"""
		This method tests :func:`foundations.strings.getNormalizedPath` definition.
		"""

		self.assertIsInstance(strings.getNormalizedPath("/Users/JohnDoe/Documents"), str)
		if platform.system() == "Windows" or platform.system() == "Microsoft":
			self.assertEqual(strings.getNormalizedPath("C:/Users\JohnDoe/Documents"), r"C:\\Users\\JohnDoe\\Documents")
			self.assertEqual(strings.getNormalizedPath("C://Users\/JohnDoe//Documents/"), r"C:\\Users\\JohnDoe\\Documents")
			self.assertEqual(strings.getNormalizedPath("C:\\Users\\JohnDoe\\Documents"), r"C:\\Users\\JohnDoe\\Documents")
		else:
			self.assertEqual(strings.getNormalizedPath("/Users/JohnDoe/Documents/"), "/Users/JohnDoe/Documents")
			self.assertEqual(strings.getNormalizedPath("/Users\JohnDoe/Documents"), "/Users\JohnDoe/Documents")
Exemplo n.º 3
0
	def Send_To_Software_pushButton_OnClicked( self ) :
		'''
		This Method Remotes Connect To Target Software.
		'''

		if self.outputLoaderScript() :
			selectedTemplate = self._coreTemplatesOutliner.getSelectedTemplates()[0]
			LOGGER.info( "{0} | Starting Remote Connection !".format( self.__class__.__name__ ) )
			templateParser = Parser( selectedTemplate._datas.path )
			templateParser.read() and templateParser.parse( rawSections = ( self._templateScriptSection ) )
			connectionType = foundations.parser.getAttributeCompound( "ConnectionType", templateParser.getValue( "ConnectionType", self._templateRemoteConnectionSection ) )
			loaderScriptPath = strings.getNormalizedPath( os.path.join( self._ioDirectory, selectedTemplate._datas.outputScript ) )
			if connectionType.value == "Socket" :
				try :
					connection = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
					connection.connect( ( str( self.ui.Address_lineEdit.text() ), int( self.ui.Software_Port_spinBox.value() ) ) )
					socketCommand = foundations.parser.getAttributeCompound( "ExecutionCommand", templateParser.getValue( "ExecutionCommand", self._templateRemoteConnectionSection ) ).value.replace( "$loaderScriptPath", loaderScriptPath )
					LOGGER.debug( "> Current Socket Command : '%s'.", socketCommand )
					connection.send( socketCommand )
					dataBack = connection.recv( 8192 )
					LOGGER.debug( "> Received Back From Application : '%s'", dataBack )
					connection.close()
					LOGGER.info( "{0} | Ending Remote Connection !".format( self.__class__.__name__ ) )
				except Exception as error:
					raise foundations.exceptions.SocketConnectionError, "{0} | Remote Connection Error : '{1}' !".format( self.__class__.__name__, error )
			elif connectionType.value == "Win32" :
				if platform.system() == "Windows" or platform.system() == "Microsoft":
					try :
						import win32com.client
						connection = win32com.client.Dispatch( foundations.parser.getAttributeCompound( "TargetApplication", templateParser.getValue( "TargetApplication", self._templateRemoteConnectionSection ) ).value )
						connection._FlagAsMethod( self._win32ExecutionMethod )
						connectionCommand = foundations.parser.getAttributeCompound( "ExecutionCommand", templateParser.getValue( "ExecutionCommand", self._templateRemoteConnectionSection ) ).value.replace( "$loaderScriptPath", loaderScriptPath )
						LOGGER.debug( "> Current Connection Command : '%s'.", connectionCommand )
						getattr( connection, self._win32ExecutionMethod )( connectionCommand )
					except Exception as error:
						raise foundations.exceptions.SocketConnectionError, "{0} | Remote On Win32 OLE Server Error : '{1}' !".format( self.__class__.__name__, error )
Exemplo n.º 4
0
	def getDefaultOverrideKeys( self ):
		'''
		This Method Gets Default Override Keys.
		'''

		LOGGER.debug( "> Constructing Default Override Keys." )

		overrideKeys = {}

		selectedTemplates = self._coreTemplatesOutliner.getSelectedTemplates()
		template = selectedTemplates and selectedTemplates[0] or None

		if template :
			LOGGER.debug( "> Adding '{0}' Override Key With Value : '{1}'.".format( "Template|Path", template._datas.path ) )
			overrideKeys["Template|Path"] = foundations.parser.getAttributeCompound( "Template|Path", template._datas.path )

		selectedIblSets = self._coreDatabaseBrowser.getSelectedItems()
		iblSet = selectedIblSets and selectedIblSets[0] or None

		if iblSet :
			LOGGER.debug( "> Adding '{0}' Override Key With Value : '{1}'.".format( "Background|BGfile", iblSet._datas.backgroundImage ) )
			overrideKeys["Background|BGfile"] = iblSet._datas.backgroundImage and foundations.parser.getAttributeCompound( "Background|BGfile", strings.getNormalizedPath( iblSet._datas.backgroundImage ) )

			LOGGER.debug( "> Adding '{0}' Override Key With Value : '{1}'.".format( "Enviroment|EVfile", iblSet._datas.lightingImage ) )
			overrideKeys["Enviroment|EVfile"] = iblSet._datas.lightingImage and foundations.parser.getAttributeCompound( "Enviroment|EVfile", strings.getNormalizedPath( iblSet._datas.lightingImage ) )

			LOGGER.debug( "> Adding '{0}' Override Key With Value : '{1}'.".format( "Reflection|REFfile", iblSet._datas.reflectionImage ) )
			overrideKeys["Reflection|REFfile"] = iblSet._datas.reflectionImage and foundations.parser.getAttributeCompound( "Reflection|REFfile", strings.getNormalizedPath( iblSet._datas.reflectionImage ) )

		return overrideKeys