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/30 22:15:17 UTC

[1/2] incubator-spot git commit: Fixed try catch module to handle errors at Edge file creation

Repository: incubator-spot
Updated Branches:
  refs/heads/master 8381546e1 -> 00f195679


Fixed try catch module to handle errors at Edge file creation


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

Branch: refs/heads/master
Commit: 00f1956796e776b8f46c5688f320acfe1ac6d5f5
Parents: f9729c2
Author: LedaLima <le...@apache.org>
Authored: Mon Jan 23 15:41:20 2017 -0600
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.zpn.intel.com>
Committed: Mon Jan 30 16:14:22 2017 -0600

----------------------------------------------------------------------
 spot-oa/oa/dns/dns_oa.py | 51 +++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/00f19567/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 59f4c2c..5cb93a5 100644
--- a/spot-oa/oa/dns/dns_oa.py
+++ b/spot-oa/oa/dns/dns_oa.py
@@ -277,28 +277,30 @@ class OA(object):
             dns_qry = ("SELECT frame_time,frame_len,ip_dst,ip_src,dns_qry_name,dns_qry_class,dns_qry_type,dns_qry_rcode,dns_a FROM {0}.{1} WHERE y={2} AND m={3} AND d={4} AND dns_qry_name LIKE '%{5}%' AND h={6} LIMIT {7};").format(self._db,self._table_name,year,month,day,dns_qry_name,hh,limit)
             
             # execute query
-            self._engine.query(dns_qry,edge_tmp)
- 
-            # add IANA to results.
-            if dns_iana:
-                update_rows = []
-                self._logger.info("Adding IANA translation to details results")
-                with open(edge_tmp) as dns_details_csv:
-                    rows = csv.reader(dns_details_csv, delimiter=',', quotechar='|')
-                    try:
-                        next(rows)
-                        update_rows = [[conn[0]] + [conn[1]] + [conn[2]] + [conn[3]] + [conn[4]] + [dns_iana.get_name(conn[5],"dns_qry_class")] + [dns_iana.get_name(conn[6],"dns_qry_type")] + [dns_iana.get_name(conn[7],"dns_qry_rcode")] + [conn[8]] for conn in rows]
-                        update_rows = filter(None, update_rows)
-                        header = [ "frame_time", "frame_len", "ip_dst","ip_src","dns_qry_name","dns_qry_class_name","dns_qry_type_name","dns_qry_rcode_name","dns_a" ]
-                        update_rows.insert(0,header)
-                    except IndexError:
-                        pass
-
+	    try:
+                self._engine.query(dns_qry,edge_tmp)
+            except:
+		self._logger.error("ERROR. Edge file couldn't be created for {0}, skipping this step".format(dns_qry_name))
             else:
-                self._logger.info("WARNING: NO IANA configured.")
-
-            try:
-                # create edge file.
+            # add IANA to results.
+                if dns_iana:
+                    update_rows = []
+                    self._logger.info("Adding IANA translation to details results")
+                    with open(edge_tmp) as dns_details_csv:
+                        rows = csv.reader(dns_details_csv, delimiter=',', quotechar='|')
+                        try:
+                            next(rows)
+                            update_rows = [[conn[0]] + [conn[1]] + [conn[2]] + [conn[3]] + [conn[4]] + [dns_iana.get_name(conn[5],"dns_qry_class")] + [dns_iana.get_name(conn[6],"dns_qry_type")] + [dns_iana.get_name(conn[7],"dns_qry_rcode")] + [conn[8]] for conn in rows]
+                            update_rows = filter(None, update_rows)
+                            header = [ "frame_time", "frame_len", "ip_dst","ip_src","dns_qry_name","dns_qry_class_name","dns_qry_type_name","dns_qry_rcode_name","dns_a" ]
+                            update_rows.insert(0,header)
+                        except IndexError:
+                            pass
+
+                else:
+                    self._logger.info("WARNING: NO IANA configured.")
+
+                    # create edge file.
                 self._logger.info("Creating edge file:{0}".format(edge_file))
                 with open(edge_file,'wb') as dns_details_edge:
                     writer = csv.writer(dns_details_edge, quoting=csv.QUOTE_ALL)
@@ -308,10 +310,7 @@ class OA(object):
                         shutil.copy(edge_tmp,edge_file)           
                 
                 os.remove(edge_tmp)
-            except OSError as e:
-                self._logger.info("Error while trying to read/write file: {0}".format(str(e))                
-                pass
-           
+
 
     def _get_dns_dendrogram(self):
         limit = self._details_limit
@@ -392,4 +391,4 @@ class OA(object):
             os.rename(ingest_summary_tmp,ingest_summary_file)
         else:
             self._logger.info("No data found for the ingest summary")
-        
\ No newline at end of file
+        


[2/2] incubator-spot git commit: Added try catch module to handle errors at Edge file creation

Posted by ev...@apache.org.
Added try catch module to handle errors at Edge file creation


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

Branch: refs/heads/master
Commit: f9729c21884a8fb49a3e3c8756a3363af7f84570
Parents: 8381546
Author: LedaLima <ga...@intel.com>
Authored: Mon Jan 23 11:29:57 2017 -0600
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.zpn.intel.com>
Committed: Mon Jan 30 16:14:22 2017 -0600

----------------------------------------------------------------------
 spot-oa/oa/dns/dns_oa.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/f9729c21/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 abb8cac..59f4c2c 100644
--- a/spot-oa/oa/dns/dns_oa.py
+++ b/spot-oa/oa/dns/dns_oa.py
@@ -297,18 +297,19 @@ class OA(object):
             else:
                 self._logger.info("WARNING: NO IANA configured.")
 
-            # create edge file.
-            self._logger.info("Creating edge file:{0}".format(edge_file))
-            with open(edge_file,'wb') as dns_details_edge:
-                writer = csv.writer(dns_details_edge, quoting=csv.QUOTE_ALL)
-                if update_rows:
-                    writer.writerows(update_rows)
-                else:            
-                    shutil.copy(edge_tmp,edge_file)           
-            
             try:
+                # create edge file.
+                self._logger.info("Creating edge file:{0}".format(edge_file))
+                with open(edge_file,'wb') as dns_details_edge:
+                    writer = csv.writer(dns_details_edge, quoting=csv.QUOTE_ALL)
+                    if update_rows:
+                        writer.writerows(update_rows)
+                    else:            
+                        shutil.copy(edge_tmp,edge_file)           
+                
                 os.remove(edge_tmp)
-            except OSError:
+            except OSError as e:
+                self._logger.info("Error while trying to read/write file: {0}".format(str(e))                
                 pass