Example #1
0
def get_app():
    """load API modules and return the WSGI application"""
    global get_app, _app, login_manager
    _app = Flask(__name__)
    _app.config.from_object(DefaultConfig())
    _app.secret_key = 'WTF is this!!'  # Should have this to work

    login_manager = LoginManager()
    login_manager.init_app(_app)

    import_all_modules(__file__, __name__)
    get_app = lambda: _app
    return _app
Example #2
0
def get_app():
    """load API modules and return the WSGI application"""
    global get_app, _app, login_manager
    _app = Flask(__name__)
    _app.config.from_object(DefaultConfig())
    _app.secret_key = 'WTF is this!!'       # Should have this to work

    login_manager = LoginManager()
    login_manager.init_app(_app)

    import_all_modules(__file__, __name__)
    get_app = lambda: _app
    return _app
Example #3
0
            try:
                log_info("Searching '{1}' with searcher: '{0}' ...".
                         format(self.name, ctx.query))
                res = func(ctx)
                for r in res['results']:
                    r.searcher = self.name
                return res
            except KeyboardInterrupt:
                raise
            except Exception as e:
                log_exc("Error in searcher '{0}' with query '{1}': {2}".
                        format(self.name, ctx.query, str(e)))

        self.searcher_list.append(self)
        self.cb = wrapper
        return wrapper

    def run(self, ctx):
        """ run this searcher against the context given"""
        res = self.cb(ctx)
        if res and res['results']:
            log_info("Got the following results from {0}:\n".format(self.name) +
                    "\n".join([str(r) for r in res['results']]))
        return res

    @staticmethod
    def get_searcher_list():
        return sorted(register_searcher.searcher_list, key=lambda x: x.priority, reverse=True)

import_all_modules(__file__, __name__)
Example #4
0
                    ctx.existing = doc[0]
                    ukdbconn.update_meta(doc[0]['_id'],
                                         fetcher_inst.get_meta())
                    return True
        meta = fetcher_inst.get_meta()
        if len(meta):
            log_info("Fetcher {} Update Metadata: {}".format(
                fetcher_inst.name, str(meta.keys())))
        ctx.update_meta_dict(meta)
        return True

    def download(self, sr, progress_updater=None):
        """ return binary data or None"""
        fetcher_inst = self.fetcher_cls(sr)

        succ = fetcher_inst.download(progress_updater)
        if not succ:
            return None

        ft = check_buf_pdf(fetcher_inst.get_data())
        if ft == True:
            data = fetcher_inst.get_data()
            return data
        else:
            log_err("Wrong Format: {0}".format(ft))
            return None


if __name__ != '__main__':
    import_all_modules(__file__, __name__)