Beispiel #1
0
def fetch_asyncio(user_id, feed_id):
    "Crawl the feeds with asyncio."
    import asyncio

    with application.app_context():
        from flask.ext.login import current_user
        from crawler import classic_crawler
        ucontr = UserController()
        users = []
        try:
            users = [ucontr.get(user_id)]
        except:
            users = ucontr.read()
        finally:
            if users == []:
                users = ucontr.read()

        try:
            feed_id = int(feed_id)
        except:
            feed_id = None

        loop = asyncio.get_event_loop()
        for user in users:
            if user.is_active:
                logger.warn("Fetching articles for " + user.login)
                classic_crawler.retrieve_feed(loop, current_user, feed_id)
        loop.close()
Beispiel #2
0
def fetch_asyncio(user_id, feed_id):
    "Crawl the feeds with asyncio."
    import asyncio

    with application.app_context():
        from flask.ext.login import current_user
        from crawler import classic_crawler
        ucontr = UserController()
        users = []
        try:
            users = [ucontr.get(user_id)]
        except:
            users = ucontr.read()
        finally:
            if users == []:
                users = ucontr.read()

        try:
            feed_id = int(feed_id)
        except:
            feed_id = None

        loop = asyncio.get_event_loop()
        for user in users:
            if user.is_active:
                logger.warn("Fetching articles for " + user.login)
                classic_crawler.retrieve_feed(loop, current_user, feed_id)
        loop.close()
Beispiel #3
0
 def validate(self):
     ucontr = UserController()
     validated = super().validate()
     if ucontr.read(nickname=self.nickname.data).count():
         self.nickname.errors.append('Nickname already taken')
         validated = False
     if ucontr.read(email=self.email.data).count():
         self.email.errors.append('Email already taken')
         validated = False
     return validated
Beispiel #4
0
 def validate(self):
     ucontr = UserController()
     validated = super().validate()
     if ucontr.read(nickname=self.nickname.data).count():
         self.nickname.errors.append('Nickname already taken')
         validated = False
     if ucontr.read(email=self.email.data).count():
         self.email.errors.append('Email already taken')
         validated = False
     return validated
Beispiel #5
0
 def validate(self):
     ucontr = UserController()
     validated = super().validate()
     if not ucontr.read(email=self.email.data).count():
         self.email.errors.append('No user with that email')
         validated = False
     return validated
Beispiel #6
0
 def validate(self):
     ucontr = UserController()
     validated = super().validate()
     if not ucontr.read(email=self.email.data).count():
         self.email.errors.append('No user with that email')
         validated = False
     return validated
Beispiel #7
0
 def validate(self):
     ucontr = UserController()
     validated = super().validate()
     if ucontr.read(login=self.login.data).count():
         self.login.errors.append('Login already taken')
         validated = False
     if self.password.data != self.password_conf.data:
         self.password_conf.errors.append("Passwords don't match")
         validated = False
     return validated
Beispiel #8
0
 def validate(self):
     ucontr = UserController()
     validated = super().validate()
     if ucontr.read(login=self.login.data).count():
         self.login.errors.append('Login already taken')
         validated = False
     if self.password.data != self.password_conf.data:
         self.password_conf.errors.append("Passwords don't match")
         validated = False
     return validated
Beispiel #9
0
 def validate(self):
     ucontr = UserController()
     validated = super().validate()
     if ucontr.read(nickname=self.nickname.data).count():
         self.nickname.errors.append('Nickname already taken')
         validated = False
     if self.nickname.data != User.make_valid_nickname(self.nickname.data):
         self.nickname.errors.append(lazy_gettext(
                 'This nickname has invalid characters. '
                 'Please use letters, numbers, dots and underscores only.'))
         validated = False
     return validated
Beispiel #10
0
 def validate(self):
     ucontr = UserController()
     validated = super().validate()
     if ucontr.read(nickname=self.nickname.data).count():
         self.nickname.errors.append("Nickname already taken")
         validated = False
     if self.nickname.data != User.make_valid_nickname(self.nickname.data):
         self.nickname.errors.append(
             lazy_gettext(
                 "This nickname has invalid characters. "
                 "Please use letters, numbers, dots and underscores only."))
         validated = False
     return validated
Beispiel #11
0
 def config(self):
     print("graph_title JARR - Articles adding rate")
     print("graph_vlabel Articles per sec")
     print("articles.label Overall rate")
     print("articles.type DERIVE")
     print("articles.min 0")
     ucontr = UserController(ignore_context=True)
     for id_ in sorted(user.id for user in ucontr.read()):
         print("articles_user_%s.label Rate for user %s" % (id_, id_))
         print("articles_user_%s.type DERIVE" % id_)
         print("articles_user_%s.min 0" % id_)
     print("graph_category web")
     print("graph_scale yes")
Beispiel #12
0
def confirm_account(activation_key=None):
    """
    Confirm the account of a user.
    """
    user_contr = UserController()
    if activation_key != "":
        user = user_contr.read(activation_key=activation_key).first()
        if user is not None:
            user_contr.update({'id': user.id}, {'activation_key': ''})
            flash(gettext('Your account has been confirmed.'), 'success')
        else:
            flash(gettext('Impossible to confirm this account.'), 'danger')
    return redirect(url_for('login'))
Beispiel #13
0
def confirm_account(activation_key=None):
    """
    Confirm the account of a user.
    """
    user_contr = UserController()
    if activation_key != "":
        user = user_contr.read(activation_key=activation_key).first()
        if user is not None:
            user_contr.update({"id": user.id}, {"activation_key": ""})
            flash(gettext("Your account has been confirmed."), "success")
        else:
            flash(gettext("Impossible to confirm this account."), "danger")
    return redirect(url_for("login"))
Beispiel #14
0
def confirm_account(token=None):
    """
    Confirm the account of a user.
    """
    user_contr = UserController()
    user, nickname = None, None
    if token != "":
        nickname = confirm_token(token)
    if nickname:
        user = user_contr.read(nickname=nickname).first()
    if user is not None:
        user_contr.update({'id': user.id}, {'is_active': True})
        flash(gettext('Your account has been confirmed.'), 'success')
    else:
        flash(gettext('Impossible to confirm this account.'), 'danger')
    return redirect(url_for('login'))
Beispiel #15
0
def confirm_account(token=None):
    """
    Confirm the account of a user.
    """
    user_contr = UserController()
    user, email = None, None
    if token != "":
        email = confirm_token(token)
    if email:
        user = user_contr.read(email=email).first()
    if user is not None:
        user_contr.update({'id': user.id}, {'is_active': True})
        flash(gettext('Your account has been confirmed.'), 'success')
    else:
        flash(gettext('Impossible to confirm this account.'), 'danger')
    return redirect(url_for('login'))
Beispiel #16
0
def confirm_account(token=None):
    """
    Confirm the account of a user.
    """
    user_contr = UserController()
    user, nickname = None, None
    if token != "":
        nickname = confirm_token(token)
    if nickname:
        user = user_contr.read(nickname=nickname).first()
    if user is not None:
        user_contr.update({"id": user.id}, {"is_active": True})
        flash(gettext("Your account has been confirmed."), "success")
    else:
        flash(gettext("Impossible to confirm this account."), "danger")
    return redirect(url_for("login"))