コード例 #1
0
ファイル: plugin.py プロジェクト: trtko1964/archivczsk
def sessionStart(reason, session):
    GlobalSession.setSession(session)
    # saving active downloads to session
    if not hasattr(session, 'archivCZSKdownloads'):
        session.archivCZSKdownloads = []
    if DownloadManager.getInstance() is None:
        DownloadManager(session.archivCZSKdownloads)
コード例 #2
0
ファイル: download.py プロジェクト: 1801/archivczsk
    def overrideDownloadCB(download):
        session = GlobalSession.getSession()
        dManager = DownloadManager.getInstance()
        dInstance = None
        for d in dManager.download_lst:
            if download.local == d.local:
                dInstance = d
                break

        def renameCB(callback=None):
            if callback and len(callback) > 0:
                dpath = os.path.join(download.destDir, callback)
                if download.filename == callback:
                    session.open(
                        MessageBox,
                        _("You've to change download filename. Try again.."),
                        type=MessageBox.TYPE_WARNING)
                elif os.path.isfile(dpath):
                    message = "%s: %s %s\n%s" % (
                        _("The file"), callback, _("already exists"),
                        _("Try to use another name..."))
                    session.open(MessageBox,
                                 message,
                                 type=MessageBox.TYPE_WARNING)
                else:
                    download.filename = callback
                    download.local = dpath
                    dManager.addDownload(download)

        def askOverrideCB(callback=None):
            if callback:
                if callback[1] == "override":
                    try:
                        if dInstance:
                            dManager.removeDownload(dInstance)
                        else:
                            os.remove(download.local)
                        dManager.addDownload(download)
                    except OSError as e:
                        print e
                elif callback[1] == "rename":
                    session.openWithCallback(renameCB,
                                             VirtualKeyBoard,
                                             _("Rename filename"),
                                             text=download.filename)

        if download is not None:
            if dInstance and dInstance.running:
                message = _("Download is already running")
                session.open(MessageBox, message, type=MessageBox.TYPE_INFO)
            else:
                dfname = download.filename
                message = "%s: %s %s" % (_("The file"), dfname,
                                         _("already exist"))
                choices = [(_("Override existing file"), "override"),
                           (_("Rename file"), "rename")]
                session.openWithCallback(askOverrideCB, ChoiceBox, message,
                                         choices)
コード例 #3
0
ファイル: download.py プロジェクト: easyspider/archivczsk
 def finishDownloadCB(download):
     session = GlobalSession.getSession()
     def updateDownloadList(callback=None):
         if DownloadListScreen.instance is not None:
             DownloadListScreen.instance.refreshList()
     if download.downloaded:
         session.openWithCallback(updateDownloadList, MessageBox, _("ArchivyCZSK - Download:") + ' ' + \
                                   download.name.encode('utf-8', 'ignore') + ' ' + _("successfully finished."), \
                                   type=MessageBox.TYPE_INFO, timeout=0)
     else:
         session.openWithCallback(updateDownloadList, MessageBox, _("ArchivyCZSK - Download:") + ' ' + \
                                   download.name.encode('utf-8', 'ignore') + ' ' + _("finished with errors."), \
                                   type=MessageBox.TYPE_ERROR, timeout=0)
コード例 #4
0
 def finishDownloadCB(download):
     session = GlobalSession.getSession()
     def updateDownloadList(callback=None):
         if ArchivCZSKDownloadListScreen.instance is not None:
             ArchivCZSKDownloadListScreen.instance.refreshList()
     if download.downloaded:
         session.openWithCallback(updateDownloadList, MessageBox, _("ArchivyCZSK - Download:") + ' ' + \
                                   download.name.encode('utf-8', 'ignore') + ' ' + _("successfully finished."), \
                                   type=MessageBox.TYPE_INFO, timeout=0)
     else:
         session.openWithCallback(updateDownloadList, MessageBox, _("ArchivyCZSK - Download:") + ' ' + \
                                   download.name.encode('utf-8', 'ignore') + ' ' + _("finished with errors."), \
                                   type=MessageBox.TYPE_ERROR, timeout=0)
コード例 #5
0
ファイル: download.py プロジェクト: easyspider/archivczsk
    def overrideDownloadCB(download):
        session = GlobalSession.getSession()
        dManager = DownloadManager.getInstance()
        dInstance = None
        for d in dManager.download_lst:
            if download.local == d.local:
                dInstance = d
                break

        def renameCB(callback=None):
            if callback and len(callback) > 0:
                dpath = os.path.join(download.destDir, callback)
                if download.filename == callback:
                    session.open(MessageBox, _("You've to change download filename. Try again.."), type=MessageBox.TYPE_WARNING)
                elif os.path.isfile(dpath):
                    message = "%s: %s %s\n%s" % (_("The file"), callback, _("already exists"), _("Try to use another name..."))
                    session.open(MessageBox, message, type=MessageBox.TYPE_WARNING)
                else:
                    download.filename = callback
                    download.local = dpath
                    dManager.addDownload(download)

        def askOverrideCB(callback=None):
            if callback:
                if callback[1] == "override":
                    try:
                        if dInstance:
                            dManager.removeDownload(dInstance)
                        else:
                            os.remove(download.local)
                        dManager.addDownload(download)
                    except OSError as e:
                        print e
                elif callback[1] == "rename":
                    session.openWithCallback(renameCB, VirtualKeyBoard, _("Rename filename"), text=download.filename)

        if download is not None:
            if dInstance and dInstance.running:
                message = _("Download is already running")
                session.open(MessageBox, message, type=MessageBox.TYPE_INFO)
            else:
                dfname = download.filename
                message = "%s: %s %s" % (_("The file") , dfname, _("already exist"))
                choices = [(_("Override existing file"),"override"),
                                     (_("Rename file"), "rename")]
                session.openWithCallback(askOverrideCB, ChoiceBox, message, choices)
コード例 #6
0
ファイル: download.py プロジェクト: easyspider/archivczsk
 def startDownloadCB(download):
     session = GlobalSession.getSession()
     session.open(MessageBox, _("ArchivCZSK - Download:") + ' ' + \
                  download.name.encode('utf-8', 'ignore') + ' ' + _("started."), \
                  type=MessageBox.TYPE_INFO, timeout=5)
コード例 #7
0
 def startDownloadCB(download):
     session = GlobalSession.getSession()
     session.open(MessageBox, _("ArchivCZSK - Download:") + ' ' + \
                  download.name.encode('utf-8', 'ignore') + ' ' + _("started."), \
                  type=MessageBox.TYPE_INFO, timeout=5)