def search(queryBuilder): response = requests.get(get_es_mark_url() + "/_search?", data=json.dumps(queryBuilder.build())) marks = [] try: for mark in response.json["hits"]["hits"]: marks.append(mark["_source"]) except KeyError: conv.logger("search").exception("Elasticsearch error: " + str(response.json)) return response.json["hits"]["total"], marks
def do(self): logger = conv.logger("SendInvite") template = Template(_invite_template) body = template.substitute( username=self.user["email"].split("@")[0], base_url=conv.settings["RECALL_WEB_BASE_URL"], name=self._name(), email_key=self.user["email_key"], ) email_(self.user["private_email"], "*****@*****.**", body, "Recall Invite") logger.info("Sent invite email to " + self.user["email"])
def dequeue(): sub_queues = ["work1", "work2", "work3", "work4", "work5"] while True: try: return pickle.loads(redis_connection().blpop(sub_queues)[1]) except ConnectionError as e: logger = conv.logger("jobs") logger.warn( "Problem connecting to redis; host: {host}, port: {port}, db: {db}".format( host=conv.settings["RECALL_REDIS_HOST"], port=conv.settings["RECALL_REDIS_PORT"], db=conv.settings["RECALL_REDIS_DB"])) time.sleep(5)
def main(): try: global logger convenience.load_settings() logger = convenience.logger("worker") signal.signal(signal.SIGINT, stop) signal.signal(signal.SIGTERM, stop) logger.info("Starting") while(True): try: jobs.dequeue().do() except Exception as e: logger.exception(e) except KeyboardInterrupt: stop(None, None)
def main(): try: global logger convenience.load_settings() logger = convenience.logger("server") signal.signal(signal.SIGINT, stop) signal.signal(signal.SIGTERM, stop) logger.info("Starting") app = bottle.Bottle() app.mount("/people", people.app) app.mount("/bookmarks", bookmarks.app) app.mount("/status", status.app) http_server = make_server("", int(settings["RECALL_API_PORT"]), app) http_server.serve_forever() except KeyboardInterrupt: stop(None, None)
def __init__(self): self.logger = conv.logger("AuthenticationPlugin")
def __setstate__(self, state): self.__dict__.update(state) self.logger = conv.logger(self.__class__.__name__)
def __init__(self, localaddr, remoteaddr): self.logger = conv.logger("fake_mailserver") self.logger.info("Starting on port " + str(localaddr[1])) smtpd.SMTPServer.__init__(self, localaddr, remoteaddr)
from urllib.parse import unquote from bottle import abort, request, Bottle, response from recall import convenience as conv from recall import ( plugins, search, data, jobs, ) from bs4 import BeautifulSoup logger = conv.logger("bookmarks") app = Bottle() app.install(plugins.ppjson) app.install(plugins.auth) app.install(plugins.cors) app.install(plugins.exceptions) app.error_handler = plugins.handler_dict @app.post("/<who>/public/<when>/") def add_public(who, when, user): if "~" not in request.json or "@" not in request.json: abort(400, "You must include @ and ~ with all bookmarks") if request.json["@"] != who or who != user["email"]: abort(400, "You may only add bookmarks as yourself") if request.json["~"] != int(when):
from bottle import Bottle, request, response, abort import bcrypt from recall.data import whitelist, blacklist from recall import convenience as c from recall import plugins, jobs, messages app = Bottle() app.install(plugins.exceptions) app.install(plugins.ppjson) app.install(plugins.auth) app.install(plugins.cors) app.error_handler = plugins.handler_dict logger = c.logger("people") @app.get("/") def users(): abort(503, "Not yet implemented") @app.get("/<who>/") def user_(who): try: return whitelist(c.db().users.find_one({"email": who}), [ "email", "firstName", "pseudonym" ]) except TypeError: logger.warn("Asked about {email}, but that is not a user".format(