You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spot.apache.org by ev...@apache.org on 2017/01/25 18:36:51 UTC

[39/49] incubator-spot git commit: Reverted changes to split into two different PRs

Reverted changes to split into two different PRs


Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/a958cb4e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/a958cb4e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/a958cb4e

Branch: refs/heads/master
Commit: a958cb4e5f8b2c3976bb7a32731bcfb969927028
Parents: c9e27ba
Author: LedaLima <ga...@intel.com>
Authored: Fri Jan 20 14:28:18 2017 -0600
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.ra.intel.com>
Committed: Fri Jan 20 17:01:02 2017 -0800

----------------------------------------------------------------------
 spot-oa/oa/dns/dns_oa.py | 22 ++++------------------
 spot-oa/oa/utils.py      |  5 ++---
 2 files changed, 6 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/a958cb4e/spot-oa/oa/dns/dns_oa.py
----------------------------------------------------------------------
diff --git a/spot-oa/oa/dns/dns_oa.py b/spot-oa/oa/dns/dns_oa.py
index ffcc839..abb8cac 100644
--- a/spot-oa/oa/dns/dns_oa.py
+++ b/spot-oa/oa/dns/dns_oa.py
@@ -143,31 +143,17 @@ class OA(object):
         dns_scores_csv = "{0}/dns_scores.csv".format(self._data_path)
         dns_scores_final =  self._move_time_stamp(self._dns_scores)
         dns_scores_final.insert(0,self._dns_scores_headers)
-        Util.create_csv_file(dns_scores_csv,dns_scores_final,',',0)   
+        Util.create_csv_file(dns_scores_csv,dns_scores_final)   
 
         # create bk file
         dns_scores_bu_csv = "{0}/dns_scores_bu.csv".format(self._data_path)
-        Util.create_csv_file(dns_scores_bu_csv,dns_scores_final,',',0)     
+        Util.create_csv_file(dns_scores_bu_csv,dns_scores_final)     
 
 
     def _add_tld_column(self):
-        qry_name_col = self._conf['dns_results_fields']['dns_qry_name']
-        self._dns_scores = [conn + [ self._get_valid_tld(str(conn[qry_name_col])) ] for conn in self._dns_scores ]
-         
+        qry_name_col = self._conf['dns_results_fields']['dns_qry_name'] 
+        self._dns_scores = [conn + [ get_tld("http://" + str(conn[qry_name_col]), fail_silently=True) if "http://" not in str(conn[qry_name_col]) else get_tld(str(conn[qry_name_col]), fail_silently=True)] for conn in self._dns_scores ] 
   
-    def _get_valid_tld(self, qry_name):
-        tld = ""
-        try:
-            if "http://" not in qry_name: 
-                tld = get_tld("http://" + qry_name)
-            else:
-                tld = get_tld(qry_name)
-        except ValueError:
-            self._logger.error("Unable to get top level domain from query: {0}".format(qry_name))
-            tld = "UNKNOWN"
-        return tld
-    
-
     def _add_reputation(self):
 
         # read configuration.

http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/a958cb4e/spot-oa/oa/utils.py
----------------------------------------------------------------------
diff --git a/spot-oa/oa/utils.py b/spot-oa/oa/utils.py
index 52b251a..d08b26e 100644
--- a/spot-oa/oa/utils.py
+++ b/spot-oa/oa/utils.py
@@ -98,10 +98,9 @@ class Util(object):
 	
 	
 	@classmethod
-	def create_csv_file(cls,full_path_file,content,delimiter=',',set_quoting=3):  
-		#set_quoting: 0 - MINIMAL, 1 - ALL, 3 - NONE
+	def create_csv_file(cls,full_path_file,content,delimiter=','):   
 		with open(full_path_file, 'w+') as u_file:
-			writer = csv.writer(u_file, quoting=set_quoting, quotechar='"', delimiter=delimiter)
+			writer = csv.writer(u_file, quoting=csv.QUOTE_NONE, delimiter=delimiter)
 			writer.writerows(content)