本文整理汇总了Python中Core.Universals类的典型用法代码示例。如果您正苦于以下问题:Python Universals类的具体用法?Python Universals怎么用?Python Universals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Universals类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
def execute(_command=[], _executableName=None):
if _executableName in ["HamsiManager", "HamsiManagerInstaller"]:
pathOfExecutable = findExecutablePath(_executableName)
if pathOfExecutable.find(".py") > -1 or pathOfExecutable.find(".py3") > -1 or pathOfExecutable.find(".pyw") > -1:
pathOfExecutable = [getPythonPath(), pathOfExecutable]
else:
pathOfExecutable = [pathOfExecutable]
_command = pathOfExecutable + _command
if len(_command) > 1 and _command[1][0] is not "-" and _command[0].find("kdesu") > -1:
tCommand = _command[0]
del _command[0]
for c in _command:
if c.find(" ") > -1 or c.find("'") > -1:
c = "'" + c + "'"
tCommand += " \"" + (" ".join(_command)) + "\""
_command = tCommand
Records.add("Execute >>> " + str(_command))
Records.saveAllRecords()
return subprocess.Popen(args=uni.trEncode(_command, fu.fileSystemEncoding), stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1, shell=True)
else:
Records.add("Execute >>> " + str(_command))
Records.saveAllRecords()
try: correctedCommand = uni.trEncodeList(_command, fu.fileSystemEncoding)
except: correctedCommand = _command
return subprocess.Popen(args=correctedCommand, stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1)
示例2: deleteAlbum
def deleteAlbum(_albumId):
db = Amarok.checkAndGetDB()
queryUpdate = "DELETE FROM albums WHERE id=%s" % (_albumId)
uni.printForDevelopers("Query - deleteAlbum : " + queryUpdate)
db.query(queryUpdate)
db.commit()
return True
示例3: getAllMusicFilePathsByAlbumArtistId
def getAllMusicFilePathsByAlbumArtistId(_artistId):
db = Amarok.checkAndGetDB()
query = """
SELECT
REPLACE(
CONCAT(
CASE WHEN devices.lastmountpoint IS NOT NULL THEN devices.lastmountpoint ELSE '' END,
SUBSTRING( urls.rpath , 2 )),
CONCAT('/',
CONCAT( CASE WHEN devices.lastmountpoint IS NOT NULL THEN devices.lastmountpoint ELSE '' END,
SUBSTRING( urls.rpath , 2 )))
, '') AS 'filePath'
FROM tracks
INNER JOIN urls ON urls.id = tracks.url
LEFT JOIN devices ON devices.id = urls.deviceid
LEFT JOIN albums ON albums.id = tracks.album
LEFT JOIN artists albumartists ON albumartists.id = albums.artist
WHERE albums.artist=""" + str(_artistId) + " ORDER BY filePath "
uni.printForDevelopers("Query - getAllMusicFilePathsByArtistId : " + query)
db.query(query)
r = db.store_result()
musicFileValues = []
rows = r.fetch_row(0)
for row in rows:
musicFileValues.append(row[0])
return musicFileValues
示例4: destinationClicked
def destinationClicked(self):
imagePath = Dialogs.getSaveFileName(translate("ImageDetails", "Save As"),
self.lePathOfDestination.text(), str(
translate("ImageDetails", "Images (*.%s)") % uni.getStringFromList(uni.getListValue("imageExtensions"),
" *.")), 0)
if imagePath is not None:
self.lePathOfDestination.setText(imagePath)
示例5: installKDE4Languages
def installKDE4Languages():
if uni.isAvailableKDE4():
for langCode in uni.getInstalledLanguagesCodes():
installKDE4Language(langCode)
uni.setMySetting("isInstalledKDE4Language", True)
return True
return False
示例6: getAllArtistsValues
def getAllArtistsValues(_filter=""):
db = Amarok.checkAndGetDB()
_filter = str(_filter).strip()
query = """
SELECT DISTINCT
artists.id,
artists.name
FROM tracks
INNER JOIN urls ON urls.id = tracks.url
LEFT JOIN devices ON devices.id = urls.deviceid
LEFT JOIN artists ON artists.id = tracks.artist
LEFT JOIN albums ON albums.id = tracks.album
LEFT JOIN artists albumartists ON albumartists.id = albums.artist
LEFT JOIN years ON years.id = tracks.year
LEFT JOIN genres ON genres.id = tracks.genre
LEFT JOIN images ON images.id = albums.image
LEFT JOIN statistics ON statistics.url = tracks.url
LEFT JOIN lyrics ON lyrics.url = urls.id
"""
query += getSQLConditionByFilter(_filter, True) + " ORDER BY artists.name "
uni.printForDevelopers("Query - getAllArtistsValues : " + query)
db.query(query)
r = db.store_result()
musicFileValues = []
rows = r.fetch_row(0)
for row in rows:
musicFileValues.append({})
musicFileValues[-1]["id"] = row[0]
musicFileValues[-1]["name"] = row[1]
return musicFileValues
示例7: getDevices
def getDevices():
db = Amarok.checkAndGetDB()
query = "SELECT id,lastmountpoint FROM devices"
uni.printForDevelopers("Query - getDevices : " + query)
db.query(query)
r = db.store_result()
return r.fetch_row(0)
示例8: closeEvent
def closeEvent(self, _event):
try:
self.player.stop()
uni.setMySetting("isPlayNow", self.isPlayNow.isChecked())
except:
pass
self.closeCurrenctImageDialogs()
示例9: getTagger
def getTagger(_isAlertIfNotExist=False, _isReloadAgain=False):
global loaddedTagger
try:
if not _isReloadAgain and loaddedTagger is not None:
return loaddedTagger
preferedTaggerModule = uni.MySettings["preferedTaggerModule"]
taggerModule = __import__("Taggers." + preferedTaggerModule, globals(), locals(), ["isAvailable", "Tagger", preferedTaggerModule], 0)
if taggerModule.isAvailable:
loaddedTagger = taggerModule.Tagger()
return loaddedTagger
taggersNames = uni.getTaggersMachineNames()
for tagger in taggersNames:
taggerModule = __import__("Taggers." + tagger, globals(), locals(), ["isAvailable", "Tagger", tagger], 0)
if taggerModule.isAvailable:
uni.setMySetting("preferedTaggerModule", tagger)
loaddedTagger = taggerModule.Tagger()
return loaddedTagger
if _isAlertIfNotExist:
Dialogs.show(translate("Taggers", "You Have Not Any Tagger"),
translate("Taggers", "Not found any tagger in your system. "
"Please install a tagger module. "
"Now supporting only eyeD3 module (python-eyed3)."))
return None
except:
ReportBug.ReportBug()
示例10: emendDirectoryWithContents
def emendDirectoryWithContents(self):
try:
_path = self.checkSource(str(QuickMakeParameters[1]), "directory")
if _path is not None:
if uni.getBoolValue("isShowQuickMakeWindow"):
newEmendedName = str(self.leNewValue.text())
else:
newEmendedName = Organizer.emend(_path, fu.getObjectType(_path))
fu.activateSmartCheckIcon()
oldFileName = _path
newDirName = fu.moveOrChange(oldFileName, newEmendedName, "directory")
if newDirName != oldFileName:
fileAndDirectoryNames = fu.readDirectory(newDirName, "fileAndDirectory")
for fileAndDirs in fileAndDirectoryNames:
objectType = fu.getObjectType(fu.joinPath(newDirName, fileAndDirs))
fu.moveOrChange(fu.joinPath(newDirName, fileAndDirs),
fu.joinPath(newDirName, Organizer.emend(fileAndDirs, objectType)), objectType)
if uni.isActiveDirectoryCover and uni.getBoolValue(
"isActiveAutoMakeIconToDirectory") and uni.getBoolValue(
"isAutoMakeIconToDirectoryWhenFileMove"):
fu.checkIcon(newDirName)
if fu.isDir(newDirName):
fu.completeSmartCheckIcon()
Dialogs.show(translate("QuickMake", "Directory And Contents Emended"),
str(translate("QuickMake",
"\"%s\" is emended based on the criteria you set.This directory is \"%s\" now.")) %
(Organizer.getLink(_path), Organizer.getLink(newDirName)))
self.close()
except:
ReportBug.ReportBug()
示例11: checkEmbeddedDB
def checkEmbeddedDB():
global isAskEmbeddedDBConfiguration
if uni.getBoolValue("isReadOnlyAmarokDB"):
if (fu.isDir(fu.pathOfSettingsDirectory + "/Amarok/mysqle/amarok") and
fu.isDir(fu.pathOfSettingsDirectory + "/Amarok/mysqle/mysql") and
fu.isFile(fu.pathOfSettingsDirectory + "/Amarok/my.cnf")):
return startReadOnlyEmbeddedDB()
else:
if isAskEmbeddedDBConfiguration:
isAskEmbeddedDBConfiguration = False
answer = Dialogs.ask(translate("Amarok", "Amarok Database Must Be Configure"),
translate("Amarok",
"Amarok database must be configure for Hamsi Manager. Are you want to configure Amarok database?"))
if answer == Dialogs.Yes:
ReadOnlyEmbeddedDBConfigurator()
else:
return False
else:
if (fu.isFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysql/db.frm") and
fu.isFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/my.cnf")):
return startEmbeddedDB()
else:
if isAskEmbeddedDBConfiguration:
isAskEmbeddedDBConfiguration = False
answer = Dialogs.ask(translate("Amarok", "Amarok Database Must Be Configure"),
translate("Amarok",
"Amarok database must be configure for Hamsi Manager. Are you want to configure Amarok database?"))
if answer == Dialogs.Yes:
EmbeddedDBConfigurator()
else:
return False
return checkEmbeddedDB()
示例12: getPID
def getPID():
global isStarted
if fu.isFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysqld.pid"):
isStarted = True
return fu.readFromFile(uni.getKDE4HomePath() + "/share/apps/amarok/mysqle/mysqld.pid").split("\n")[0]
isStarted = False
return None
示例13: changeArtistWithAnother
def changeArtistWithAnother(_currentArtistId, _artistWillBeSelectedId):
db = Amarok.checkAndGetDB()
queryUpdate1 = "UPDATE tracks SET artist=%s WHERE artist=%s" % (_artistWillBeSelectedId, _currentArtistId)
uni.printForDevelopers("Query - changeArtistWithAnother - queryUpdate1 : " + queryUpdate1)
db.query(queryUpdate1)
db.commit()
try:
db = Amarok.checkAndGetDB()
queryUpdate2 = "UPDATE albums SET artist=%s WHERE artist=%s" % (_artistWillBeSelectedId, _currentArtistId)
uni.printForDevelopers("Query - changeArtistWithAnother - queryUpdate2 : " + queryUpdate2)
db.query(queryUpdate2)
db.commit()
except Amarok.getMySQLModule().IntegrityError as error:
db = Amarok.checkAndGetDB()
db.query("SELECT * FROM albums WHERE name IN (SELECT name FROM albums WHERE artist=%s) AND artist=%s" % (
_artistWillBeSelectedId, _currentArtistId))
r = db.store_result()
rows = r.fetch_row(0)
for row in rows:
currentAlbumId = row[0]
currentAlbumName = row[1]
db = Amarok.checkAndGetDB()
db.query("SELECT * FROM albums WHERE name='%s' AND artist=%s" % (currentAlbumName, _artistWillBeSelectedId))
r = db.store_result()
srows = r.fetch_row(0)
if len(srows) > 0:
albumWillBeSelectedId = srows[0][0]
changeAlbumWithAnother(currentAlbumId, albumWillBeSelectedId)
deleteAlbum(currentAlbumId)
return True
示例14: writeContents
def writeContents(self):
self.changedValueNumber = 0
changedArtistValues = []
uni.startThreadAction()
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:
if self.isChangeableItem(rowNo, "correctedArtist", str(self.values[rowNo]["currentArtist"])):
changedArtistValues.append({})
changedArtistValues[-1]["id"] = str(self.values[rowNo]["id"])
value = str(self.item(rowNo, 1).text())
changedArtistValues[-1]["name"] = value
Records.add(str(translate("AmarokArtistTable", "Artist")),
str(self.values[rowNo]["currentArtist"]), value)
self.changedValueNumber += 1
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()
Operations.changeArtistValues(changedArtistValues)
return True
示例15: getOrInsertGenre
def getOrInsertGenre(_genre):
db = Amarok.checkAndGetDB()
for sqlCommand in Databases.getAmendedSQLSelectOrInsertAndSelectQueries("genres", "id", {
"name": "'" + Databases.correctForSql(_genre) + "'"}):
uni.printForDevelopers("Query - getOrInsertGenre : " + sqlCommand)
db.query(sqlCommand)
r = db.store_result()
return str(r.fetch_row(0)[0][0])