mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-30 01:37:17 +00:00
Added comments, cleanup and added credentials search progress in Flask
This commit is contained in:
parent
cbb2909156
commit
fa52292029
1 changed files with 10 additions and 10 deletions
|
@ -71,6 +71,7 @@ def Term_getValueOverRange(word, startDate, num_day, per_paste=""):
|
||||||
passed_days += 1
|
passed_days += 1
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
#Mix suplied username, if extensive is set, slice username(s) with different windows
|
||||||
def mixUserName(supplied, extensive=False):
|
def mixUserName(supplied, extensive=False):
|
||||||
#e.g.: John Smith
|
#e.g.: John Smith
|
||||||
terms = supplied.split()[:2]
|
terms = supplied.split()[:2]
|
||||||
|
@ -107,6 +108,7 @@ def mixUserName(supplied, extensive=False):
|
||||||
if not extensive:
|
if not extensive:
|
||||||
return usernames
|
return usernames
|
||||||
|
|
||||||
|
#Slice the supplied username(s)
|
||||||
mixedSupplied = supplied.replace(' ','')
|
mixedSupplied = supplied.replace(' ','')
|
||||||
minWindow = 3 if len(mixedSupplied)/2 < 4 else len(mixedSupplied)/2
|
minWindow = 3 if len(mixedSupplied)/2 < 4 else len(mixedSupplied)/2
|
||||||
for winSize in range(3,len(mixedSupplied)):
|
for winSize in range(3,len(mixedSupplied)):
|
||||||
|
@ -334,7 +336,6 @@ def terms_plot_tool():
|
||||||
|
|
||||||
@terms.route("/terms_plot_tool_data/")
|
@terms.route("/terms_plot_tool_data/")
|
||||||
def terms_plot_tool_data():
|
def terms_plot_tool_data():
|
||||||
|
|
||||||
oneDay = 60*60*24
|
oneDay = 60*60*24
|
||||||
range_start = datetime.datetime.utcfromtimestamp(int(float(request.args.get('range_start')))) if request.args.get('range_start') is not None else 0;
|
range_start = datetime.datetime.utcfromtimestamp(int(float(request.args.get('range_start')))) if request.args.get('range_start') is not None else 0;
|
||||||
range_start = range_start.replace(hour=0, minute=0, second=0, microsecond=0)
|
range_start = range_start.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
|
@ -350,7 +351,6 @@ def terms_plot_tool_data():
|
||||||
else:
|
else:
|
||||||
per_paste = ""
|
per_paste = ""
|
||||||
|
|
||||||
|
|
||||||
if term is None:
|
if term is None:
|
||||||
return "None"
|
return "None"
|
||||||
|
|
||||||
|
@ -366,7 +366,6 @@ def terms_plot_tool_data():
|
||||||
|
|
||||||
@terms.route("/terms_plot_top/")
|
@terms.route("/terms_plot_top/")
|
||||||
def terms_plot_top():
|
def terms_plot_top():
|
||||||
|
|
||||||
per_paste = request.args.get('per_paste')
|
per_paste = request.args.get('per_paste')
|
||||||
per_paste = per_paste if per_paste is not None else 1
|
per_paste = per_paste if per_paste is not None else 1
|
||||||
return render_template("terms_plot_top.html", per_paste=per_paste)
|
return render_template("terms_plot_top.html", per_paste=per_paste)
|
||||||
|
@ -379,7 +378,6 @@ def terms_plot_top_data():
|
||||||
today = today.replace(hour=0, minute=0, second=0, microsecond=0)
|
today = today.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
today_timestamp = calendar.timegm(today.timetuple())
|
today_timestamp = calendar.timegm(today.timetuple())
|
||||||
|
|
||||||
|
|
||||||
per_paste = request.args.get('per_paste')
|
per_paste = request.args.get('per_paste')
|
||||||
if per_paste == "1" or per_paste is None:
|
if per_paste == "1" or per_paste is None:
|
||||||
per_paste = "per_paste_"
|
per_paste = "per_paste_"
|
||||||
|
@ -469,8 +467,16 @@ def cred_management_action():
|
||||||
uniq_num_set.add(num)
|
uniq_num_set.add(num)
|
||||||
#Extensive /!\
|
#Extensive /!\
|
||||||
if extensive:
|
if extensive:
|
||||||
|
iter_num = 0
|
||||||
|
tot_iter = len(AllUsernameInRedis)*len(possibilities)
|
||||||
for tempUsername in AllUsernameInRedis:
|
for tempUsername in AllUsernameInRedis:
|
||||||
for poss in possibilities:
|
for poss in possibilities:
|
||||||
|
#FIXME print progress
|
||||||
|
if(iter_num % int(tot_iter/20) == 0):
|
||||||
|
#print("searching: {}% done".format(int(iter_num/tot_iter*100)), sep=' ', end='\r', flush=True)
|
||||||
|
print("searching: {}% done".format(float(iter_num)/float(tot_iter)*100))
|
||||||
|
iter_num += 1
|
||||||
|
|
||||||
if poss in tempUsername:
|
if poss in tempUsername:
|
||||||
num = r_serv_cred.hget(REDIS_KEY_ALL_CRED_SET, tempUsername)
|
num = r_serv_cred.hget(REDIS_KEY_ALL_CRED_SET, tempUsername)
|
||||||
if num is not None:
|
if num is not None:
|
||||||
|
@ -488,14 +494,8 @@ def cred_management_action():
|
||||||
supp_mixed = supplied.replace(' ','')
|
supp_mixed = supplied.replace(' ','')
|
||||||
supp_splitted.append(supp_mixed)
|
supp_splitted.append(supp_mixed)
|
||||||
for indiv_supplied in supp_splitted:
|
for indiv_supplied in supp_splitted:
|
||||||
#levenDist = float(Levenshtein.distance(indiv_supplied, username))
|
|
||||||
#levenRatio = levenDist / float(len(indiv_supplied)) if levenRatio > levenDist / float(len(indiv_supplied)) else levenRatio
|
|
||||||
#levenRatio = levenRatio if levenRatio < 1.0 else 1.0
|
|
||||||
levenRatio = float(Levenshtein.ratio(indiv_supplied, username))
|
levenRatio = float(Levenshtein.ratio(indiv_supplied, username))
|
||||||
levenRatioStr = "{:.1%}".format(levenRatio)
|
levenRatioStr = "{:.1%}".format(levenRatio)
|
||||||
#levenRatioStr = "{:.1%}".format(1.0 - levenRatio)
|
|
||||||
#if levenRatio >= 1.0:
|
|
||||||
# continue
|
|
||||||
|
|
||||||
data['usr'].append(username)
|
data['usr'].append(username)
|
||||||
allPathNum = list(r_serv_cred.smembers(REDIS_KEY_MAP_CRED_TO_PATH+'_'+Unum))
|
allPathNum = list(r_serv_cred.smembers(REDIS_KEY_MAP_CRED_TO_PATH+'_'+Unum))
|
||||||
|
|
Loading…
Reference in a new issue