コード例 #1
0
ファイル: locationsBrowser.py プロジェクト: dschaga/sIBL_GUI
	def exploreProvidedFolder( self, folder ) :
		'''
		This Method Provides Folder Exploring Capability.

		@param folder: Folder To Explore. ( String )
		'''

		browserCommand = None
		customFileBrowser = str( self.ui.Custom_File_Browser_Path_lineEdit.text() )

		folder = os.path.normpath( folder )
		if platform.system() == "Windows" or platform.system() == "Microsoft":
			if customFileBrowser :
				LOGGER.info( "{0} | Launching '{1}' Custom File Browser With '{2}'.".format( self.__class__.__name__, os.path.basename( customFileBrowser ), folder ) )
				browserCommand = "\"{0}\" \"{1}\"".format( customFileBrowser, folder )
			else:
				LOGGER.info( "{0} | Launching 'explorer.exe' With '{1}'.".format( self.__class__.__name__, folder ) )
				browserCommand = "explorer.exe \"{0}\"".format( folder )
		elif platform.system() == "Darwin" :
			if customFileBrowser :
				LOGGER.info( "{0} | Launching '{1}' Custom File Browser With '{2}'.".format( self.__class__.__name__, os.path.basename( customFileBrowser ), folder ) )
				browserCommand = "open -a \"{0}\" \"{1}\"".format( customFileBrowser, folder )
			else:
				LOGGER.info( "{0} | Launching 'Finder' With '{1}'.".format( self.__class__.__name__, folder ) )
				browserCommand = "open \"{0}\"".format( folder )
		elif platform.system() == "Linux":
			if customFileBrowser :
				LOGGER.info( "{0} | Launching '{1}' Custom File Browser With '{2}'.".format( self.__class__.__name__, os.path.basename( customFileBrowser ), folder ) )
				browserCommand = "\"{0}\" \"{1}\"".format( customFileBrowser, folder )
			else :
				environmentVariable = Environment( "PATH" )
				paths = environmentVariable.getPath().split( ":" )

				browserFound = False
				for browser in self._linuxBrowsers :
					if not browserFound :
						try :
							for path in paths :
								if os.path.exists( os.path.join( path, browser ) ) :
									LOGGER.info( "{0} | Launching '{1}' File Browser With '{2}'.".format( self.__class__.__name__, browser, folder ) )
									browserCommand = "\"{0}\" \"{1}\"".format( browser, folder )
									browserFound = True
									raise StopIteration
						except StopIteration:
							pass
					else :
						break

		if browserCommand :
			LOGGER.debug( "> Current Browser Command : '{0}'.".format( browserCommand ) )
			browserProcess = QProcess()
			browserProcess.startDetached( browserCommand )
		else :
			messageBox.messageBox( "Warning", "Warning", "{0} | Please Define A Browser Executable In The Preferences !".format( self.__class__.__name__ ) )
コード例 #2
0
	def editProvidedfile( self, file ):
		'''
		This Method Provides Editing Capability.

		@param file: File To Edit. ( String )
		'''

		editCommand = None
		customTextEditor = str( self.ui.Custom_Text_Editor_Path_lineEdit.text() )

		file = os.path.normpath( file )
		if platform.system() == "Windows" or platform.system() == "Microsoft":
			if customTextEditor :
				LOGGER.info( "{0} | Launching '{1}' Custom Text Editor With '{2}'.".format( self.__class__.__name__, os.path.basename( customTextEditor ), file ) )
				editCommand = "\"{0}\" \"{1}\"".format( customTextEditor, file )
			else:
				LOGGER.info( "{0} | Launching 'notepad.exe' With '{1}'.".format( self.__class__.__name__, file ) )
				editCommand = "notepad.exe \"{0}\"".format( file )
		elif platform.system() == "Darwin" :
			if customTextEditor :
				LOGGER.info( "{0} | Launching '{1}' Custom Text Editor With '{2}'.".format( self.__class__.__name__, os.path.basename( customTextEditor ), file ) )
				editCommand = "open -a \"{0}\" \"{1}\"".format( customTextEditor, file )
			else:
				LOGGER.info( "{0} | Launching Default Text Editor With '{1}'.".format( self.__class__.__name__, file ) )
				editCommand = "open -e \"{0}\"".format( file )
		elif platform.system() == "Linux":
			if customTextEditor :
				LOGGER.info( "{0} | Launching '{1}' Custom Text Editor With '{2}'.".format( self.__class__.__name__, os.path.basename( customTextEditor ), file ) )
				editCommand = "\"{0}\" \"{1}\"".format( customTextEditor, file )
			else :
				environmentVariable = Environment( "PATH" )
				paths = environmentVariable.getPath().split( ":" )

				editorFound = False
				for editor in self._linuxTextEditors :
					if not editorFound :
						try :
							for path in paths :
								if os.path.exists( os.path.join( path, editor ) ) :
									LOGGER.info( "{0} | Launching '{1}' Text Editor With '{2}'.".format( self.__class__.__name__, editor, file ) )
									editCommand = "\"{0}\" \"{1}\"".format( editor, file )
									editorFound = True
									raise StopIteration
						except StopIteration:
							pass
					else :
						break
		if editCommand :
			LOGGER.debug( "> Current Edit Command : '{0}'.".format( editCommand ) )
			editProcess = QProcess()
			editProcess.startDetached( editCommand )
		else :
			messageBox.messageBox( "Warning", "Warning", "{0} | Please Define A Text Editor Executable In The Preferences !".format( self.__class__.__name__ ) )