예제 #1
0
	def coreTemplatesOutlinerUi_Templates_Outliner_treeView_OnSelectionChanged( self, selectedItems, deselectedItems ):
		'''
		This Method Sets Is Triggered When coreTemplatesOutlinerUi_Templates_Outliner_treeView Selection Has Changed.
		
		@param selectedItems: Selected Items. ( QItemSelection )
		@param deselectedItems: Deselected Items. ( QItemSelection )
		'''

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

		if template :
			LOGGER.debug( "> Parsing '{0}' Template For '{1}' Section.".format( template._datas.name, self._templateRemoteConnectionSection ) )

			if os.path.exists( template._datas.path ) :
				templateParser = Parser( template._datas.path )
				templateParser.read() and templateParser.parse( rawSections = ( self._templateScriptSection ) )

				if self._templateRemoteConnectionSection in templateParser.sections :
					LOGGER.debug( "> {0}' Section Found.".format( self._templateRemoteConnectionSection ) )
					self.ui.Remote_Connection_groupBox.show()
					connectionType = foundations.parser.getAttributeCompound( "ConnectionType", templateParser.getValue( "ConnectionType", self._templateRemoteConnectionSection ) )
					if connectionType.value == "Socket" :
						LOGGER.debug( "> Remote Connection Type : 'Socket'." )
						self.ui.Software_Port_spinBox.setValue( int( foundations.parser.getAttributeCompound( "DefaultPort", templateParser.getValue( "DefaultPort", self._templateRemoteConnectionSection ) ).value ) )
						self.ui.Address_lineEdit.setText( QString( foundations.parser.getAttributeCompound( "DefaultAddress", templateParser.getValue( "DefaultAddress", self._templateRemoteConnectionSection ) ).value ) )
						self.ui.Remote_Connection_Options_frame.show()
					elif connectionType.value == "Win32" :
						LOGGER.debug( "> Remote Connection : 'Win32'." )
						self.ui.Remote_Connection_Options_frame.hide()
				else :
					self.ui.Remote_Connection_groupBox.hide()
		else :
			self.ui.Remote_Connection_groupBox.hide()
예제 #2
0
	def coreTemplatesOutlinerUi_Templates_Outliner_treeView_OnSelectionChanged( self, selectedItems, deselectedItems ):
		'''
		This Method Sets Is Triggered When coreTemplatesOutlinerUi_Templates_Outliner_treeView Selection Has Changed.
		
		@param selectedItems: Selected Items. ( QItemSelection )
		@param deselectedItems: Deselected Items. ( QItemSelection )
		'''

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

		if template :
			LOGGER.debug( "> Parsing '{0}' Template For '{1}' and '{2}'Section.".format( template._datas.name, self._templateCommonAttributesSection, self._templateAdditionalAttributesSection ) )

			if os.path.exists( template._datas.path ) :
				templateParser = Parser( template._datas.path )
				templateParser.read() and templateParser.parse( rawSections = ( self._templateScriptSection ) )

				self.setOptionsToolBox( templateParser.sections[self._templateCommonAttributesSection], self.ui.Common_Attributes_tableWidget )
				self.setOptionsToolBox( templateParser.sections[self._templateAdditionalAttributesSection], self.ui.Additional_Attributes_tableWidget )
예제 #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 )
예제 #4
0
	def getLoaderScript( self, template, iblSet, overrideKeys ):
		'''
		This Method Build A Loader Script.
		
		@param template: Template Path. ( String )
		@param iblSet: iblSet Path. ( String )
		@param overrideKeys: Override Keys. ( Dictionary )
		@return: Loader Script. ( List )
		'''

		LOGGER.debug( "> Parsing Template File : '{0}'.".format( template ) )
		templateParser = Parser( template )
		templateParser.read() and templateParser.parse( rawSections = ( self._templateScriptSection ) )
		templateSections = dict.copy( templateParser.sections )

		for attribute, value in dict.copy( templateSections[self._templateIblAttributesSection] ).items():
			templateSections[self._templateIblAttributesSection][foundations.parser.removeNamespace( attribute, rootOnly = True )] = value
			del templateSections[self._templateIblAttributesSection][attribute]

		LOGGER.debug( "> Binding Templates File Attributes." )
		bindedAttributes = dict( [( attribute, foundations.parser.getAttributeCompound( attribute, value ) ) for section in templateSections.keys() if section not in ( self._templateScriptSection ) for attribute, value in templateSections[section].items() ] )

		LOGGER.debug( "> Parsing Ibl Set File : '{0}'.".format( iblSet ) )
		iblSetParser = Parser( iblSet )
		iblSetParser.read() and iblSetParser.parse()
		iblSetSections = dict.copy( iblSetParser.sections )

		LOGGER.debug( "> Flattening Ibl Set File Attributes." )
		flattenedIblAttributes = dict( [( attribute, foundations.parser.getAttributeCompound( attribute, value ) ) for section in iblSetSections.keys() for attribute, value in iblSetSections[section].items() ] )

		for attribute in flattenedIblAttributes :
			if attribute in bindedAttributes.keys() :
				bindedAttributes[attribute].value = flattenedIblAttributes[attribute].value

		if "Lights|DynamicLights" in bindedAttributes.keys() :
			LOGGER.debug( "> Building '{0}' Custom Attribute.".format( "Lights|DynamicLights" ) )
			dynamicLights = []
			for section in iblSetSections :
				if re.search( "Light[0-9]*", section ) :
					dynamicLights.append( section )
					dynamicLights.append( iblSetParser.getValue( "LIGHTname", section ) )
					lightColorTokens = iblSetParser.getValue( "LIGHTcolor", section ).split( "," )
					for color in lightColorTokens:
						dynamicLights.append( color )
					dynamicLights.append( iblSetParser.getValue( "LIGHTmulti", section ) )
					dynamicLights.append( iblSetParser.getValue( "LIGHTu", section ) )
					dynamicLights.append( iblSetParser.getValue( "LIGHTv", section ) )

			LOGGER.debug( "> Adding '{0}' Custom Attribute With Value : '{1}'.".format( "Lights|DynamicLights", ", ".join( dynamicLights ) ) )
			bindedAttributes["Lights|DynamicLights"].value = self._defaultStringSeparator.join( dynamicLights )

		LOGGER.debug( "> Updating Attributes With Override Keys." )
		for attribute in overrideKeys :
			if attribute in bindedAttributes.keys() :
				bindedAttributes[attribute].value = overrideKeys[attribute] and overrideKeys[attribute].value or None

		LOGGER.debug( "> Updating Loader Script Content." )
		loaderScript = templateParser.sections[self._templateScriptSection][foundations.parser.setNamespace( "Script", templateParser.rawSectionContentIdentifier )]

		bindedLoaderScript = []
		for line in loaderScript :
			bindingParameters = re.findall( "{0}".format( self._bindingIdentifierPattern ), line )
			if bindingParameters:
				for parameter in bindingParameters :
					for attribute in bindedAttributes.values() :
						if parameter == attribute.link :
							LOGGER.debug( "> Updating Loader Script Parameter '{0}' With Value : '{1}'.".format( parameter, attribute.value ) )
							line = line.replace( parameter, attribute.value and attribute.value or "-1" )
			bindedLoaderScript.append( line )

		return bindedLoaderScript
예제 #5
0
파일: manager.py 프로젝트: dschaga/sIBL_GUI
    def getProfile(self, file):
        """
		This Method Gets Provided Component Profile.

		@param file: File Path. ( String )
		@return: Profile. ( Profile )
		"""

        LOGGER.debug("> Building '{0}' Profile.".format(file))

        parser = Parser(file)
        parser.read() and parser.parse()

        if parser.sections:
            profile = Profile()
            profile.path = os.path.dirname(file)
            profile.name = parser.attributeExists("Name", "Component") and parser.getValue("Name", "Component") or None
            if not profile.name:
                raise foundations.exceptions.FileStructureError(
                    "'{0}' No '{1}' Attribute Found, File Structure Seems Invalid !".format(file, "Name")
                )
            profile.path = os.path.dirname(file)
            profile.module = (
                parser.attributeExists("Module", "Component") and parser.getValue("Module", "Component") or None
            )
            if not profile.module:
                raise foundations.exceptions.FileStructureError(
                    "'{0}' No '{1}' Attribute Found, File Structure Seems Invalid !".format(file, "Module")
                )
            profile.object_ = (
                parser.attributeExists("Object", "Component") and parser.getValue("Object", "Component") or None
            )
            if not profile.object_:
                raise foundations.exceptions.FileStructureError(
                    "'{0}' No '{1}' Attribute Found, File Structure Seems Invalid !".format(file, "Object")
                )
            profile.rank = parser.attributeExists("Rank", "Component") and parser.getValue("Rank", "Component") or None
            if not profile.rank:
                raise foundations.exceptions.FileStructureError(
                    "'{0}' No '{1}' Attribute Found, File Structure Seems Invalid !".format(file, "Rank")
                )
            profile.version = (
                parser.attributeExists("Version", "Component") and parser.getValue("Version", "Component") or None
            )
            if not profile.version:
                raise foundations.exceptions.FileStructureError(
                    "'{0}' No '{1}' Attribute Found, File Structure Seems Invalid !".format(file, "Version")
                )
            profile.author = (
                parser.attributeExists("Author", "Informations") and parser.getValue("Author", "Informations") or None
            )
            profile.email = (
                parser.attributeExists("Email", "Informations") and parser.getValue("Email", "Informations") or None
            )
            profile.url = (
                parser.attributeExists("Url", "Informations") and parser.getValue("Url", "Informations") or None
            )
            profile.description = (
                parser.attributeExists("Description", "Informations")
                and parser.getValue("Description", "Informations")
                or None
            )

            return profile
        else:
            raise foundations.exceptions.FileStructureError(
                "'{0}' No Sections Found, File Structure Seems Invalid !".format(file)
            )