欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

aptoncd.py

Progra,, das sehr viele Medien formate spielt und sehr bekannt ist.
PY
第 1 页 / 共 2 页
字号:
#!/usr/bin/env python# -*- coding: utf-8 -*-import CreateAptOncdimport ProgressWindowimport configimport gettextimport gtkimport gtk.gladeimport localefrom messageBox import MessageBoximport osimport pygtkimport restoreimport timeimport utilsimport HalManagerimport RepDownloadimport webbrowserimport sysfrom mediaInfo import mediaInfofrom optparse import OptionParserimport msg(RESTORE, RESTORE_ISO,CREATE,HIDE_MAIN,CREATE_LIST, DOWNLOAD, NONE) = range(7)# ---- Config file ----config.init(config.CONFIG_FILE)# ---- i18n ----locale.setlocale(locale.LC_ALL, '')gettext.bindtextdomain(config.I18N_APP, config.I18N_DIR)gettext.textdomain(config.I18N_APP)_ = gettext.gettextgtk.glade.bindtextdomain(config.I18N_APP, config.I18N_DIR)gtk.glade.textdomain(config.I18N_APP)gettext.install(config.I18N_APP, config.I18N_DIR, unicode=1)class AboutDialog:	def __init__(self, gladeFileName):		self.formName = "frmAbout"		self.gladeFile = gtk.glade.XML(gladeFileName, self.formName)			def run(self):		"""This function will show the aboutDialog"""				#Get the actual dialog widget		frmAbout = self.gladeFile.get_widget(self.formName)		frmAbout.set_position(gtk.WIN_POS_CENTER)		frmAbout.set_modal(True)		#run the dialog and store the response				result = frmAbout.run()				#we are done with the dialog, destory it		frmAbout.destroy()				#return the result		return 	resultclass RestoreISO:    def __init__(self,gladeFileName, frmWindow = None):        self.gladeFileName = gladeFileName        self.frmMainWindow = frmWindow        self.cursorManager = utils.cursorManager()            def run(self):        if os.getuid() != 0:            os.execl("/usr/bin/gksu", "gksu", "--desktop",                         "/usr/share/applications/aptoncd.desktop",                         "--", "aptoncd", "--restore-iso")            sys.exit()            return        result, filename = utils.openSelectDialog (msg.MESSAGE_0029,msg.MESSAGE_0030,"*.iso")#        print 'Result is:', result, filename        if result == gtk.RESPONSE_OK:            isofile = filename[0]                        if os.path.isfile(isofile):                fromPath = "/tmp/aptoncd-mnt-image/"                utils.mkdir(fromPath,True)                                command = "gksu --desktop /usr/share/applications/aptoncd.desktop 'mount -o loop %s %s'" % (isofile.replace(' ','\ '), fromPath.replace(' ','\ '))                ret = os.system(command)                time.sleep(0.1)                cdinfo = mediaInfo(os.path.join(fromPath,'aptoncd.info'))                result, msgError = cdinfo.infoFromFile()                if result:                    isValid,strMsg = cdinfo.compare_version()                    if isValid:                        s = restore.restoreAptOnCd(self.gladeFileName,fromPath)                        s.run()                    else:                        MessageBox().ShowError(strMsg,self.frmMainWindow)                else:                    MessageBox().ShowError(msgError,self.frmMainWindow)                                    command = "gksu --desktop /usr/share/applications/aptoncd.desktop 'umount %s'" % fromPath.replace(' ','\ ')                ret = os.system(command)                utils.removePath(fromPath)                        else:                MessageBox().ShowError(msg.MESSAGE_0031,self.frmMainWindow)        else:            sys.exit()class RestoreCD:    def __init__(self, gladeFileName, frmwindow = None):        self.gladeFileName = gladeFileName        self.frmMainWindow = frmwindow        self.cursorManager = utils.cursorManager()            def run(self):        if os.getuid() != 0:            os.execl("/usr/bin/gksu", "gksu", "--desktop",                         "/usr/share/applications/aptoncd.desktop",                         "--", "aptoncd", "--restore")            return        self.cursorManager.setBusy(self.frmMainWindow,True)        utils.updateUI()        CancelMount = False        deviceEjected = False        hal = HalManager.HalManager()                mountedName = hal.get_first_mounted_name()                if mountedName == "" and hal.get_property(mountedName,HalManager.LABEL) != "APTonCD":            f = os.popen("eject")            mountedName =""            deviceEjected = True            while mountedName == "" :                if not MessageBox().ShowQuestionOkCancel(msg.MESSAGE_0025, self.frmMainWindow):                    CancelMount = True                    break                while hal.get_first_mounted_name() == "":                        time.sleep(0.1)                mountedName = hal.get_first_mounted_name()                                if mountedName !="":                    cdName = hal.get_property(mountedName,HalManager.LABEL)                    if cdName !="APTonCD":                        MessageBox().ShowError(msg.MESSAGE_0026,self.frmMainWindow)                        mountedName =""                                elif mountedName != "" and hal.get_property(mountedName,HalManager.LABEL) != "APTonCD":            f = os.popen("eject")            mountedName =""            deviceEjected = True            while mountedName == "":                if not MessageBox().ShowQuestionOkCancel(msg.MESSAGE_0027, self.frmMainWindow):                    CancelMount = True                    break                while hal.get_first_mounted_name() == "":                        time.sleep(0.1)                mountedName = hal.get_first_mounted_name()                if mountedName !="":                    cdName = hal.get_property(mountedName,HalManager.LABEL)                    if cdName !="APTonCD":                        MessageBox().ShowError(msg.MESSAGE_0028,self.frmMainWindow)                        mountedName =""                    if not CancelMount:                self.cursorManager.setBusy(self.frmMainWindow,False)                mPoint = hal.get_first_mounted_point()                cdinfo = mediaInfo(os.path.join(mPoint,'aptoncd.info'))                result, msgError = cdinfo.infoFromFile()                if result:                    isValid,strMsg = cdinfo.compare_version()                    if isValid:                        s = restore.restoreAptOnCd(self.gladeFileName,mPoint)                        s.run()                    else:                        MessageBox().ShowError(strMsg,self.frmMainWindow)                else:                    MessageBox().ShowError(msgError,self.frmMainWindow)        else:            if deviceEjected:                f = os.popen("eject -t &")        self.cursorManager.setBusy(self.frmMainWindow,False)                       return     resultclass ConfigurationDialog:    def __init__(self, gladeFileName):        self.formName = "frmConfiguration"        self.gladeFile = gtk.glade.XML(gladeFileName, self.formName)            def run(self):        """This function will show the Configuration Dialog"""                #Get the actual dialog widget        frmConfiguration = self.gladeFile.get_widget(self.formName)        frmConfiguration.set_position(gtk.WIN_POS_CENTER)        frmConfiguration.set_modal(True)                #run the dialog and store the response                result = frmConfiguration.run()                #we are done with the dialog, destory it        frmConfiguration.destroy()                return     resultclass DownloadDialog:    def __init__(self, gladeFileName):        self.formName = "frmDownload"        self.gladeFile = gtk.glade.XML(gladeFileName, self.formName)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -