コード例 #1
0
ファイル: views.py プロジェクト: exploratour/exploratour
    def reindex(self, **params):
        stash = {}
        if cherrypy.request.method == "POST":
            progress = pool.get_progress(reindexer_id[0])
            if progress.complete:
                reindexer_id[0] = pool.add_task(Reindexer())
                redirect(url("reindex"))

        context = dict(progress = pool.get_progress(reindexer_id[0]))
        return render("reindex.html", context)
コード例 #2
0
ファイル: views.py プロジェクト: exploratour/exploratour
    def export_backup(self, export_id=None, download=False, **params):
        # Read parameters first, to ensure they all get stashed.
        stash = {}

        # Make a new exporter, and get any parameters it needs into the stash.
        exp = Exporter.get('xml')()
        exp.read_params(stash, params)

        # Handle exports which are in progress, or have finished
        if export_id is not None:
            try:
                export_id = int(export_id)
            except ValueError:
                export_id = None
        if export_id is not None:
            try:
                running_exp = exports[export_id]
            except KeyError:
                # Invalid export id (most probably due to a server restart)
                running_exp = None
            if running_exp is not None:
                # Export in progress
                progress = pool.get_progress(export_id)
                context = dict(export_id=export_id, fmt='xml', progress=progress,
                               stash=stash)
                if not progress.complete:
                    return render('export/in_progress.html', context)
                if progress.failed:
                    return render('export/failed.html', context)
                # Export complete
                if not download:
                    # Display a "Export prepared"
                    return render('export/complete.html', context)
                return running_exp.respond()

        # Read the set of things to export.
        search, desc, topcoll = self._get_export_records(stash, None, None, None, True)

        if not getparam('export', False, stash, params):
            # Not ready to start the export yet.
            context = dict(
                           export_desc = desc,
                           stash = stash,
                          )

            exp.add_to_context(context, search, stash, params)
            return render('backup/pick.html', context)

        # Start the exporter
        task = ExportRecords(exp, search)
        export_id = pool.add_task(task)
        exports[export_id] = task

        redirect(url("records-export-inprogress", export_id=export_id, fmt='xml', **stash))
コード例 #3
0
ファイル: views.py プロジェクト: exploratour/exploratour
    def export_records(self, export_id=None, fmt='rtf', download=False,
                       **params):
        """Export a set of records.

        """
        # Read parameters first, to ensure they all get stashed.
        stash = {}
        record_id = getparam('record_id', None, stash, params)
        issearch = getparam('issearch', None, stash, params)
        coll = getparam('coll', None, stash, params)
        incsubs = getintparam('incsubs', 1, stash, params)

        # Make a new exporter, and get any parameters it needs into the stash.
        try:
            exp = Exporter.get(fmt)()
        except KeyError:
            raise cherrypy.NotFound
        exp.read_params(stash, params)

        # Handle exports which are in progress, or have finished
        if export_id is not None:
            try:
                export_id = int(export_id)
            except ValueError:
                export_id = None
        if export_id is not None:
            try:
                running_exp = exports[export_id]
            except KeyError:
                # Invalid export id (most probably due to a server restart)
                running_exp = None
            if running_exp is not None:
                # Export in progress
                progress = pool.get_progress(export_id)
                context = dict(export_id=export_id, fmt=fmt, progress=progress,
                               stash=stash)
                if not progress.complete:
                    return render('export/in_progress.html', context)
                if progress.failed:
                    return render('export/failed.html', context)
                # Export complete
                if not download:
                    # Display a "Export prepared"
                    return render('export/complete.html', context)
                return running_exp.respond()

        # Read the set of things to export.
        search, desc, topcoll = self._get_export_records(stash, record_id, issearch,
                                                coll, incsubs)

        if not getparam('export', False, stash, params):
            # Not ready to start the export yet.
            context = dict(
                           fmts = Exporter.fmts(params),
                           fmt = fmt,
                           export_desc = desc,
                           stash = stash,
                          )

            exp.add_to_context(context, search, stash, params)
            return render('export/pickfmt.html', context)

        # Start the exporter
        task = ExportRecords(exp, search)
        export_id = pool.add_task(task)
        exports[export_id] = task

        redirect(url("records-export-inprogress", export_id=export_id, fmt=fmt, **stash))
コード例 #4
0
ファイル: download.py プロジェクト: exploratour/exploratour
 def set_task(self, task):
     self._status = task.status
     self._info_getter = None
     self._task = None
     self._task_id = pool.add_task(task)
     self._task = task