From 14062a549c6a90ac79aad7a44d11855005f137e7 Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Mon, 8 Aug 2016 11:37:18 +0200 Subject: [PATCH] Fixed bug in credential (not sending correctly to ModuleStat) + Fixed date bug in ModuleStats --- bin/Credential.py | 13 +++++++++++-- bin/ModuleStats.py | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/Credential.py b/bin/Credential.py index cfbec7c7..d8bb8a84 100755 --- a/bin/Credential.py +++ b/bin/Credential.py @@ -57,11 +57,19 @@ if __name__ == "__main__": publisher.warning(to_print) #Send to duplicate p.populate_set_out(filepath, 'Duplicate') - #send to Browse_warning_paste + #Send to BrowseWarningPaste p.populate_set_out('credential;{}'.format(filepath), 'BrowseWarningPaste') #Put in form, count occurences, then send to moduleStats creds_sites = {} + site_occurence = re.findall(regex_site_for_stats, content) + for site in site_occurence: + site_domain = site[1:-1] + if site_domain in creds_sites.keys(): + creds_sites[site_domain] += 1 + else: + creds_sites[site_domain] = 1 + for url in sites: faup.decode(url) domain = faup.get()['domain'] @@ -71,7 +79,8 @@ if __name__ == "__main__": creds_sites[domain] = 1 for site, num in creds_sites.iteritems(): # Send for each different site to moduleStats - p.populate_set_out('credential;{};{};{}'.format(num, site, paste.p_date), 'ModuleStats') + print 'credential;{};{};{}'.format(num, site, paste.p_date) + p.populate_set_out('credential;{};{};{}'.format(num, site, paste.p_date), 'ModuleStats') if sites_set: print("=======> Probably on : {}".format(', '.join(sites_set))) diff --git a/bin/ModuleStats.py b/bin/ModuleStats.py index 36812dcd..32c631ed 100755 --- a/bin/ModuleStats.py +++ b/bin/ModuleStats.py @@ -31,6 +31,7 @@ def compute_most_posted(server, message): module, num, keyword, paste_date = message.split(';') redis_progression_name_set = 'top_'+ module +'_set' + # Add/Update in Redis prev_score = server.hget(paste_date, module+'-'+keyword) if prev_score is not None: @@ -39,7 +40,7 @@ def compute_most_posted(server, message): ok = server.hset(paste_date, module+'-'+keyword, int(num)) # Compute Most Posted - date = get_date_range(0) + date = get_date_range(0)[0] # check if this keyword is eligible for progression keyword_total_sum = 0 @@ -59,6 +60,8 @@ def compute_most_posted(server, message): keyw_value = server.hget(paste_date, module+'-'+keyw) if keyw_value is not None: member_set.append((keyw, int(keyw_value))) + else: #No data for this set for today + member_set.append((keyw, int(0))) member_set.sort(key=lambda tup: tup[1]) if len(member_set) > 0: if member_set[0][1] < keyword_total_sum: