def refreshAlexa(self): alexaActor = self.getActorHandle('analytics/alexadns') info = alexaActor.request('get_list', {}) if info.isSuccess: i = 0 newAlexa = {} for domain in info.data['domains']: i += 1 newAlexa[domain] = i self.alexa = newAlexa try: tld.update_tld_names() except: pass self.delay(60 * 60 * 24, self.refreshAlexa)
def refreshDomains(self): response = urllib2.urlopen( urllib2.Request(self.domain, headers={'User-Agent': 'LimaCharlie'})).read() z = ZipFile(StringIO(response)) content = z.read(z.namelist()[0]) newMap = {} newList = [] for d in content.split('\n'): if '' == d: continue n, dns = d.split(',') if int(n) > self.keepN: continue newMap[dns] = int(n) newList.append(dns) self.topMap = newMap self.topList = newList self.log("updated Alexa top list with %d domains." % len(self.topList)) try: tld.update_tld_names() except: pass self.delay(60 * 60 * 24, self.refreshDomains)
import re import uuid import flask import sqlalchemy import tld from .. import config, model, notify, util from . import util as web_util from .blueprint import web_api from profanity import profanity import wordfilter tld.update_tld_names() USERNAME_REGEX = re.compile(r'^[a-zA-Z0-9][a-zA-Z0-9_\-]*$') USERNAME_LENGTH = 40 def is_valid_username(username): return len(username) <= USERNAME_LENGTH and \ username and \ not profanity.contains_profanity(username) and \ not wordfilter.blacklisted(username) and \ USERNAME_REGEX.match(username) def make_user_record(row, *, logged_in, total_users=None): """Given a database result row, create the JSON user object."""