本文整理汇总了Python中FileUtils.writeToBinaryFile方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.writeToBinaryFile方法的具体用法?Python FileUtils.writeToBinaryFile怎么用?Python FileUtils.writeToBinaryFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils.writeToBinaryFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: downloaded
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import writeToBinaryFile [as 别名]
def downloaded(self):
try:
if self.isFileExist:
self.prgbState.setVisible(False)
self.pbtnDownloadAndInstall.setEnabled(False)
self.pbtnCancel.setEnabled(False)
reply = self.sender()
request = reply.request()
v = request.attribute(MNetworkRequest.User)
fileName = trStr(v)
fu.writeToBinaryFile(fileName, reply.readAll())
self.install(fileName)
except:
ReportBug.ReportBug()
示例2: saveAsImage
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import writeToBinaryFile [as 别名]
def saveAsImage(self):
try:
if self.lstwImages.currentRow() != -1:
imagePath = Dialogs.getSaveFileName(translate("MusicDetails", "Save As"),
fu.getDirName(self.musicValues["path"]),
str(translate("MusicDetails", "Images (*.%s)")) % (str(
self.musicValues["images"][self.lstwImages.currentRow()][
2]).split("/")[1]), 0)
if imagePath is not None:
sourceFile = fu.joinPath(fu.getTempDir(), "HamsiManager-image-file." +
self.musicValues["images"][self.lstwImages.currentRow()][2].split("/")[1])
fu.writeToBinaryFile(sourceFile, self.musicValues["images"][self.lstwImages.currentRow()][3])
fu.moveOrChange(sourceFile, imagePath)
except:
ReportBug.ReportBug()
示例3: closeEvent
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import writeToBinaryFile [as 别名]
def closeEvent(self, _event):
try:
if uni.isRaisedAnError is False:
if uni.isContinueThreadAction():
uni.cancelThreadAction()
_event.ignore()
uni.isStartedCloseProcess = True
uni.printForDevelopers("Started closeEvent")
MApplication.setQuitOnLastWindowClosed(True)
try:
self.PlayerBar.MusicPlayer.stop()
except:
pass
Details.closeAllDialogs()
uni.printForDevelopers("Closed Dialogs")
if uni.isRaisedAnError is False:
if self.Table.checkUnSavedValues() is False:
uni.isStartedCloseProcess = False
uni.printForDevelopers("Close ignored")
_event.ignore()
uni.printForDevelopers("Before self.doBeforeCloseProcesses")
if self.doBeforeCloseProcesses() is False:
_event.ignore()
return None
uni.printForDevelopers("After self.doBeforeCloseProcesses")
if isActivePyKDE4:
uni.printForDevelopers("Before Save KDE Configs")
kconf = MGlobal.config()
kconfGroup = MConfigGroup(kconf, "DirectoryOperator")
self.FileManager.dirOperator.writeConfig(kconfGroup)
self.FileManager.actCollection.writeSettings(kconfGroup)
uni.printForDevelopers("After Save KDE Configs")
uni.printForDevelopers("Before Save Configs")
uni.setMySetting(self.Table.hiddenTableColumnsSettingKey,
self.Table.hiddenTableColumns)
Bars.setAllBarsStyleToMySettings()
Records.setRecordType(1)
fu.writeToBinaryFile(
fu.joinPath(fu.pathOfSettingsDirectory, "LastState"), self.saveState())
Records.restoreRecordType()
geometry = [self.geometry().x(), self.geometry().y(), self.geometry().width(),
self.geometry().height()]
uni.setMySetting("MainWindowGeometries", geometry)
uni.setMySetting("lastDirectory", self.FileManager.currentDirectory)
uni.setMySetting("isMainWindowMaximized", self.isMaximized())
uni.setMySetting("isShowAdvancedSelections", self.SpecialTools.isShowAdvancedSelections)
uni.setMySetting("tableType", uni.tableType)
uni.setMySetting("activeTabNoOfSpecialTools", self.SpecialTools.tabwTabs.currentIndex())
uni.saveSettings()
Settings.saveUniversalSettings()
if uni.isActiveAmarok and uni.getBoolValue("amarokIsUseHost") is False:
import Amarok
uni.printForDevelopers("Before Amarok.stopEmbeddedDB")
Amarok.stopEmbeddedDB()
uni.printForDevelopers("After Amarok.stopEmbeddedDB")
uni.printForDevelopers("After Save Configs")
uni.printForDevelopers("Before self.doAfterCloseProcesses")
self.doAfterCloseProcesses()
uni.printForDevelopers("After self.doAfterCloseProcesses")
except:
if ReportBug.isClose is False:
ReportBug.ReportBug()
_event.ignore()
示例4: install
# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import writeToBinaryFile [as 别名]
def install(self):
try:
MApplication.processEvents()
self.installationDirectory = str(self.leInstallationDirectory.text())
if len(self.installationDirectory) > 0:
if self.installationDirectory[-1] == fu.sep:
self.installationDirectory = self.installationDirectory[:-1]
if self.installationDirectory == fu.HamsiManagerDirectory:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path is Hamsi Manager source directory.<br>Please choose a valid installation path."))
elif fu.isFile(self.installationDirectory) is False:
isMakeInstall = True
if fu.isDir(self.installationDirectory) is False:
self.lblActions.setText(translate("Install", "Creating Installation Folder..."))
fu.makeDirs(self.installationDirectory)
elif len(fu.listDir(self.installationDirectory)) > 0:
currenctAnswer = Dialogs.askSpecial(
translate("Install", "The Installation Path You Selected Is Not Empty."),
translate("Install",
"If the path you selected is an \"Hamsi Manager\" installation path, <b>I recommend you to delete the older files.</b><br>Do you want me to clear the installation path/folder for you?<br><b>Note: </b> Your personal settings are <b>never deleted</b>."),
translate("Install", "Yes (Recommended)"),
translate("Install", "No (Overwrite)"),
translate("Install", "Cancel"))
if currenctAnswer == translate("Install", "Yes (Recommended)"):
self.lblActions.setText(translate("Install", "Clearing Installation Path..."))
try:fu.removeFileOrDir(self.installationDirectory)
except:pass
fu.makeDirs(self.installationDirectory)
isMakeInstall = True
elif currenctAnswer == translate("Install", "No (Overwrite)"):
isMakeInstall = True
else:
isMakeInstall = False
if isMakeInstall:
Settings.setUniversalSetting("pathOfInstallationDirectory", self.installationDirectory)
directoriesAndFiles = fu.readDirectoryWithSubDirectories(fu.HamsiManagerDirectory)
self.prgbState.setRange(0, len(directoriesAndFiles))
self.lblActions.setText(translate("Install", "Copying Files And Folders..."))
installFileName = Execute.findExecutableBaseName("HamsiManagerInstaller")
for fileNo, fileName in enumerate(directoriesAndFiles):
MApplication.processEvents()
newFileName = self.installationDirectory + fileName.replace(fu.HamsiManagerDirectory,"")
if fu.isDir(fileName) and fileName.find(".svn") == -1:
try: fu.makeDirs(newFileName)
except: pass
elif (fu.isFile(fileName) and fu.getBaseName(fileName) != "install.py" and
fu.getBaseName(fileName) != installFileName and fileName.find(".svn") == -1):
try:
fu.copyFileOrDir(fileName, newFileName)
except:
fileContent = fu.readFromBinaryFile(fileName)
fu.writeToBinaryFile(newFileName, fileContent)
self.prgbState.setValue(fileNo + 1)
self.pageNo += 1
MyConfigure.installKDE4Languages()
else:
self.pageNo -= 1
else:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path points to a file not a folder.<br>Please choose a valid installation path."))
else:
self.pageNo -= 1
self.lblActions.setText("")
Dialogs.showError(translate("Install", "The path you selected is not valid."),
translate("Install",
"The selected path points to a file not a folder.<br>Please choose a valid installation path."))
self.pageChanged(True)
except:
from Core import ReportBug
ReportBug.ReportBug()