def installPlugin(self, _pluginName, _isQuiet=False): isInstalled = False pluginModule = __import__("MyPlugins." + _pluginName, globals(), locals(), ["pluginName", "pluginFiles", "pluginDirectory", "installThisPlugin", "setupDirectory", "pluginVersion"], 0) if pluginModule.installThisPlugin is None: if pluginModule.pluginDirectory == "": try: fu.makeDirs(pluginModule.setupDirectory) except: pass for pluginFile in pluginModule.pluginFiles: fu.copyOrChange(fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName, pluginFile), fu.joinPath(pluginModule.setupDirectory, pluginFile), "file", "only", True) MyConfigure.reConfigureFile(fu.joinPath(pluginModule.setupDirectory, pluginFile)) isInstalled = True else: oldFilePath = fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName, pluginModule.pluginDirectory) newFilePath = fu.copyOrChange(oldFilePath, fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory), "directory", "only", True) if newFilePath != oldFilePath: isInstalled = True else: isInstalled = pluginModule.installThisPlugin() if isInstalled: Settings.setUniversalSetting(str(pluginModule.pluginName), str(pluginModule.pluginVersion)) if _isQuiet is False: Dialogs.show(translate("MyPlugins", "Plug-in Installation Is Complete"), str(translate("MyPlugins", "\"%s\" is installed on your system.")) % ( pluginModule.pluginName)) elif isInstalled == "AlreadyInstalled": if _isQuiet is False: Dialogs.show(translate("MyPlugins", "Plug-in Already Installed"), str(translate("MyPlugins", "\"%s\" already installed on your system.")) % ( pluginModule.pluginName)) else: if _isQuiet is False: Dialogs.showError(translate("MyPlugins", "Plug-in Installation Failed"), str(translate("MyPlugins", "\"%s\" failed to install on your system.")) % ( pluginModule.pluginName))
def writeContents(self): self.changedValueNumber = 0 uni.startThreadAction() import Amarok allItemNumber = len(self.values) Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True) for rowNo in range(self.rowCount()): isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: try: if self.isRowHidden(rowNo) is False: baseNameOfDirectory = str(self.values[rowNo]["baseNameOfDirectory"]) baseName = str(self.values[rowNo]["baseName"]) if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory): baseNameOfDirectory = str(self.item(rowNo, 0).text()) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "baseName", baseName, False): baseName = str(self.item(rowNo, 1).text()) self.changedValueNumber += 1 newFilePath = fu.getRealPath( fu.joinPath(str(self.leDestinationDirPath.text()), baseNameOfDirectory, baseName)) if fu.isFile(self.values[rowNo]["path"]) and fu.isReadableFileOrDir( self.values[rowNo]["path"], False, True): if fu.isWritableFileOrDir(newFilePath, False, True): newFilePathCopied = fu.copyOrChange(self.values[rowNo]["path"], newFilePath) if self.values[rowNo]["path"] != newFilePathCopied: newFilePath = newFilePathCopied try: tagger = Taggers.getTagger() tagger.loadFileForWrite(newFilePath) if self.isChangeableItem(rowNo, "artist"): value = str(self.item(rowNo, 2).text()) tagger.setArtist(value) Records.add(str(translate("MusicTable", "Artist")), str(self.values[rowNo]["artist"]), value) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "title"): value = str(self.item(rowNo, 3).text()) tagger.setTitle(value) Records.add(str(translate("MusicTable", "Title")), str(self.values[rowNo]["title"]), value) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "album"): value = str(self.item(rowNo, 4).text()) tagger.setAlbum(value) Records.add(str(translate("MusicTable", "Album")), str(self.values[rowNo]["album"]), value) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "albumArtist"): value = str(self.item(rowNo, 5).text()) tagger.setAlbumArtist(value) Records.add(str(translate("MusicTable", "Album Artist")), str(self.values[rowNo]["albumArtist"]), value) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "trackNum"): value = str(self.item(rowNo, 6).text()) tagger.setTrackNum(value) Records.add(str(translate("MusicTable", "Track No")), str(self.values[rowNo]["trackNum"]), value) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "year"): value = str(self.item(rowNo, 7).text()) tagger.setDate(value) Records.add(str(translate("MusicTable", "Year")), str(self.values[rowNo]["year"]), value) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "genre"): value = str(self.item(rowNo, 8).text()) tagger.setGenre(value) Records.add(str(translate("MusicTable", "Genre")), str(self.values[rowNo]["genre"]), value) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "firstComment"): value = str(self.item(rowNo, 9).text()) tagger.setFirstComment(value) Records.add(str(translate("MusicTable", "Comment")), str( self.values[rowNo]["firstComment"]), value) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "firstLyrics"): value = str(self.item(rowNo, 10).text()) tagger.setFirstLyrics(value) Records.add(str(translate("MusicTable", "Lyrics")), str(self.values[rowNo]["firstLyrics"]), value) self.changedValueNumber += 1 tagger.update() except: Dialogs.showError(translate("MusicTable", "Tags Cannot Changed"), str(translate("MusicTable", "\"%s\" : cannot be changed tags.") ) % Organizer.getLink(newFilePath)) except: ReportBug.ReportBug() else: allItemNumber = rowNo + 1 Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), rowNo + 1, allItemNumber, True) if isContinueThreadAction is False: break uni.finishThreadAction() return True
def installPlugin(self, _pluginName, _isQuiet=False): isInstalled = False pluginModule = __import__( "MyPlugins." + _pluginName, globals(), locals(), [ "pluginName", "pluginFiles", "pluginDirectory", "installThisPlugin", "setupDirectory", "pluginVersion" ], 0) if pluginModule.installThisPlugin is None: if pluginModule.pluginDirectory == "": try: fu.makeDirs(pluginModule.setupDirectory) except: pass for pluginFile in pluginModule.pluginFiles: fu.copyOrChange( fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName, pluginFile), fu.joinPath(pluginModule.setupDirectory, pluginFile), "file", "only", True) MyConfigure.reConfigureFile( fu.joinPath(pluginModule.setupDirectory, pluginFile)) isInstalled = True else: oldFilePath = fu.joinPath(fu.HamsiManagerDirectory, "MyPlugins", _pluginName, pluginModule.pluginDirectory) newFilePath = fu.copyOrChange( oldFilePath, fu.joinPath(pluginModule.setupDirectory, pluginModule.pluginDirectory), "directory", "only", True) if newFilePath != oldFilePath: isInstalled = True else: isInstalled = pluginModule.installThisPlugin() if isInstalled: Settings.setUniversalSetting(str(pluginModule.pluginName), str(pluginModule.pluginVersion)) if _isQuiet is False: Dialogs.show( translate("MyPlugins", "Plug-in Installation Is Complete"), str( translate("MyPlugins", "\"%s\" is installed on your system.")) % (pluginModule.pluginName)) elif isInstalled == "AlreadyInstalled": if _isQuiet is False: Dialogs.show( translate("MyPlugins", "Plug-in Already Installed"), str( translate("MyPlugins", "\"%s\" already installed on your system.")) % (pluginModule.pluginName)) else: if _isQuiet is False: Dialogs.showError( translate("MyPlugins", "Plug-in Installation Failed"), str( translate("MyPlugins", "\"%s\" failed to install on your system.")) % (pluginModule.pluginName))
def writeContents(self): self.changedValueNumber = 0 uni.startThreadAction() import Amarok allItemNumber = len(self.values) Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True) for rowNo in range(self.rowCount()): isContinueThreadAction = uni.isContinueThreadAction() if isContinueThreadAction: try: if self.isRowHidden(rowNo) is False: baseNameOfDirectory = str( self.values[rowNo]["baseNameOfDirectory"]) baseName = str(self.values[rowNo]["baseName"]) if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory): baseNameOfDirectory = str( self.item(rowNo, 0).text()) self.changedValueNumber += 1 if self.isChangeableItem(rowNo, "baseName", baseName, False): baseName = str(self.item(rowNo, 1).text()) self.changedValueNumber += 1 newFilePath = fu.getRealPath( fu.joinPath(str(self.leDestinationDirPath.text()), baseNameOfDirectory, baseName)) if fu.isFile(self.values[rowNo] ["path"]) and fu.isReadableFileOrDir( self.values[rowNo]["path"], False, True): if fu.isWritableFileOrDir(newFilePath, False, True): newFilePathCopied = fu.copyOrChange( self.values[rowNo]["path"], newFilePath) if self.values[rowNo][ "path"] != newFilePathCopied: newFilePath = newFilePathCopied try: tagger = Taggers.getTagger() tagger.loadFileForWrite(newFilePath) if self.isChangeableItem( rowNo, "artist"): value = str( self.item(rowNo, 2).text()) tagger.setArtist(value) Records.add( str( translate( "MusicTable", "Artist")), str(self.values[rowNo] ["artist"]), value) self.changedValueNumber += 1 if self.isChangeableItem( rowNo, "title"): value = str( self.item(rowNo, 3).text()) tagger.setTitle(value) Records.add( str( translate( "MusicTable", "Title")), str(self.values[rowNo] ["title"]), value) self.changedValueNumber += 1 if self.isChangeableItem( rowNo, "album"): value = str( self.item(rowNo, 4).text()) tagger.setAlbum(value) Records.add( str( translate( "MusicTable", "Album")), str(self.values[rowNo] ["album"]), value) self.changedValueNumber += 1 if self.isChangeableItem( rowNo, "albumArtist"): value = str( self.item(rowNo, 5).text()) tagger.setAlbumArtist(value) Records.add( str( translate( "MusicTable", "Album Artist")), str(self.values[rowNo] ["albumArtist"]), value) self.changedValueNumber += 1 if self.isChangeableItem( rowNo, "trackNum"): value = str( self.item(rowNo, 6).text()) tagger.setTrackNum(value) Records.add( str( translate( "MusicTable", "Track No")), str(self.values[rowNo] ["trackNum"]), value) self.changedValueNumber += 1 if self.isChangeableItem( rowNo, "year"): value = str( self.item(rowNo, 7).text()) tagger.setDate(value) Records.add( str( translate( "MusicTable", "Year")), str(self.values[rowNo] ["year"]), value) self.changedValueNumber += 1 if self.isChangeableItem( rowNo, "genre"): value = str( self.item(rowNo, 8).text()) tagger.setGenre(value) Records.add( str( translate( "MusicTable", "Genre")), str(self.values[rowNo] ["genre"]), value) self.changedValueNumber += 1 if self.isChangeableItem( rowNo, "firstComment"): value = str( self.item(rowNo, 9).text()) tagger.setFirstComment(value) Records.add( str( translate( "MusicTable", "Comment")), str(self.values[rowNo] ["firstComment"]), value) self.changedValueNumber += 1 if self.isChangeableItem( rowNo, "firstLyrics"): value = str( self.item(rowNo, 10).text()) tagger.setFirstLyrics(value) Records.add( str( translate( "MusicTable", "Lyrics")), str(self.values[rowNo] ["firstLyrics"]), value) self.changedValueNumber += 1 tagger.update() except: Dialogs.showError( translate("MusicTable", "Tags Cannot Changed"), str( translate( "MusicTable", "\"%s\" : cannot be changed tags." )) % Organizer.getLink(newFilePath)) except: ReportBug.ReportBug() else: allItemNumber = rowNo + 1 Dialogs.showState( translate("FileUtils/Musics", "Writing Music Tags"), rowNo + 1, allItemNumber, True) if isContinueThreadAction is False: break uni.finishThreadAction() return True