Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Aug 2012 21:46:22 +0000
From:      tzabal@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r240747 - in soc2012/tzabal/server-side: akcrs-handler akcrs-setup akcrs-website akcrs-website/akcrs
Message-ID:  <20120822214622.1C0EC106567B@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tzabal
Date: Wed Aug 22 21:46:20 2012
New Revision: 240747
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240747

Log:
  Fix bug related with the recognize phase.

Modified:
  soc2012/tzabal/server-side/akcrs-handler/confirm_report.wsgi
  soc2012/tzabal/server-side/akcrs-handler/main.py
  soc2012/tzabal/server-side/akcrs-setup/database.sql
  soc2012/tzabal/server-side/akcrs-setup/setup
  soc2012/tzabal/server-side/akcrs-website/akcrs/models.py
  soc2012/tzabal/server-side/akcrs-website/setup.py

Modified: soc2012/tzabal/server-side/akcrs-handler/confirm_report.wsgi
==============================================================================
--- soc2012/tzabal/server-side/akcrs-handler/confirm_report.wsgi	Wed Aug 22 20:56:53 2012	(r240746)
+++ soc2012/tzabal/server-side/akcrs-handler/confirm_report.wsgi	Wed Aug 22 21:46:20 2012	(r240747)
@@ -19,7 +19,7 @@
             report_id = parameters['id'][0]
             code = parameters['code'][0]
             
-            db.query = ('SELECT 1'
+            db.query = ('SELECT bug_id '
                         'FROM reports '
                         'WHERE id = %s AND confirmation_code = %s AND '
                         'confirmed = %s')
@@ -29,8 +29,16 @@
                 response_body = 'Could not execute the query.'
             
             if db.cursor.rowcount == 1:
-                db.query = 'UPDATE Reports SET confirmed = %s WHERE id = %s'
-                db.values = (True, id)
+                bug_id = db.cursor.fetchone()
+                
+                db.query = 'UPDATE reports SET confirmed = %s WHERE id = %s'
+                db.values = (True, report_id)
+                
+                if not db.execute_query():
+                    response_body = 'Could not execute the query.'
+                
+                db.query = 'UPDATE bugs SET reported = reported + 1 WHERE id = %s'
+                db.values = (bug_id, )
                 
                 if not db.execute_query():
                     response_body = 'Could not execute the query.'

Modified: soc2012/tzabal/server-side/akcrs-handler/main.py
==============================================================================
--- soc2012/tzabal/server-side/akcrs-handler/main.py	Wed Aug 22 20:56:53 2012	(r240746)
+++ soc2012/tzabal/server-side/akcrs-handler/main.py	Wed Aug 22 21:46:20 2012	(r240747)
@@ -20,15 +20,19 @@
 db = database.Database()
 
 
-def move_invalid_report(path):
-    if not os.path.isfile(path):
+def move_invalid_report(report):
+    if not os.path.isfile(report.path):
         return
     
     if not os.path.isdir(settings.INVALID_REPORTS_DIR):
         logging.error('Invalid reports directory does not exist')
         return
     
-    shutil.move(path, settings.INVALID_REPORTS_DIR)
+    # If file with same name exists, remove it in order to avoid shutil.Error
+    if os.path.exists(settings.INVALID_REPORTS_DIR + '/' + report.name):
+        os.remove(settings.INVALID_REPORTS_DIR + '/' + report.name)
+    
+    shutil.move(report.path, settings.INVALID_REPORTS_DIR)
 
 
 def send_confirmation_email(report):
@@ -50,7 +54,6 @@
     
     try:
         smtpconn = smtplib.SMTP(smtpserver)
-        print smtpserver
         smtpconn.sendmail(sender, receiver, message.as_string())
     except smtplib.SMTPException, err:
         logging.info(err)
@@ -73,6 +76,7 @@
 
 def store_report(report):
     # Bugs
+    report.bugs_id = None
     if report.bug_id == -1:
         db.query = ('INSERT INTO bugs (state, reported) '
                     'VALUES (%s, %s) '
@@ -85,7 +89,8 @@
         report.bug_id = db.cursor.fetchone()
         db.save()
     elif type(report.bug_id) == type([]):
-        report.bug_id = -1
+        report.bugs_id = report.bug_id
+        report.bug_id = None
     
     # Users
     db.query = 'SELECT id FROM users WHERE email = %s'
@@ -122,18 +127,19 @@
     report.confirmation_code = generate_random_string(16)
     
     db.query = """INSERT INTO reports (bug_id, user_id, confirmation_code,
-    crashtype, crashdate, hostname, ostype, osrelease, version, machine, panic,
-    backtrace, top_significant_func, rem_significant_funcs, ps_axl, vmstat_s,
-    vmstat_m, vmstat_z, vmstat_i, pstat_T, pstat_s, iostat, ipcs_a, ipcs_T,
-    nfsstat, netstat_s, netstat_m, netstat_id, netstat_anr, netstat_anA,
-    netstat_aL, fstat, dmesg, kernelconfig, ddbcapturebuffer)
+    bugs_id, crashtype, crashdate, hostname, ostype, osrelease, version,
+    machine, panic, backtrace, top_significant_func, rem_significant_funcs,
+    ps_axl, vmstat_s, vmstat_m, vmstat_z, vmstat_i, pstat_T, pstat_s, iostat,
+    ipcs_a, ipcs_T, nfsstat, netstat_s, netstat_m, netstat_id, netstat_anr,
+    netstat_anA, netstat_aL, fstat, dmesg, kernelconfig, ddbcapturebuffer)
     VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
-    %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
+    %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
     RETURNING id"""
     
     db.values = (report.bug_id,
                  report.user_id,
                  report.confirmation_code,
+                 report.bugs_id,
                  report.data.commands['crashtype'],
                  report.data.commands['crashdate'],
                  report.data.commands['hostname'],
@@ -206,8 +212,9 @@
         aux = 1
     else:
         aux = 2
-        # If odd, then the average value to the middle element
+        # If odd, then the average value to the middle element (starting from 1)
         values[elems_per_set + 1] = avg
+        #values[elems_per_set] = avg
     
     # How the values will be allocated
     diff = 1
@@ -268,13 +275,18 @@
     
     # Calculate the significant functions of the reports
     significant_funcs = get_significant_funcs(report.data.commands['backtrace'])
-    report.top_significant_func = significant_funcs[0]
-    report.rem_significant_funcs = significant_funcs[1:]
-
+    if len(significant_funcs) > 1:
+        report.top_significant_func = significant_funcs[0]
+        report.rem_significant_funcs = significant_funcs[1:]
+    elif len(significant_funcs) == 1:
+        report.top_significant_func = significant_funcs[0]
+        report.rem_significant_funcs = []
+    else:
+        report.top_significant_func = report.rem_significant_funcs = []
+    
     # Retrieve from the database the confirmed reports
-    db.query = ('SELECT bug_id, panic, top_significant_func, rem_significant_funcs '
-                'FROM Reports '
-                'WHERE confirmed = true')
+    db.query = ('SELECT bug_id, panic, top_significant_func, '
+                'rem_significant_funcs FROM Reports')
     if not db.execute_query():
         return
     loggedreports = db.cursor.fetchall()
@@ -310,8 +322,10 @@
         # percentages for the remaining significant function names.
         # Compare X function names, where X is the length of the report with
         # the fewest remaining significant function names
-        length = min(len(significant_funcs), len(loggedreport[3]))
-        rem_sig_max_percs = allocate_values(length - 1)
+        # sigkrisi tou full sign funcs me tou rem sign funcs twn logged! (fixed)
+        length = min(len(report.rem_significant_funcs), len(loggedreport[3]))
+        #rem_sig_max_percs = allocate_values(length - 1)
+        rem_sig_max_percs = allocate_values(length)
         
         # Then, calculate the percentage of similarity between every remaining
         # significant function name based on the previous calculated percentages
@@ -322,18 +336,17 @@
                                             ).ratio()
             sims[index][1] += rem_sig_max_percs[i] * ratio
     
-    # Find with which reports the examined report is similar based on the value
+    # Find with which bugs the examined report is similar based on the value
     # of the limit percentage
     passlimit = []
     for sim in sims:
         if sim[1] >= settings.LIMIT_PERC:
             passlimit.append(sim[0])
     
-    # Finally, check if the examined report concluded to refer to none or only
-    # one logged bug. If it refers to more than one bugs, then this is an
-    # indication that our algorithm is not accurate.
-    report.bug_id = -1
-    print len(passlimit)
+    # Finally, check if the examined report concluded to refer to none, only
+    # one, or more logged bugs. If it refers to more than one bugs, then this is
+    # an indication that our algorithm is not accurate.
+    report.bug_id = -1 # new bug
     if len(passlimit):
         if passlimit.count(passlimit[0]) == len(passlimit):
             # Refers to a known bug
@@ -488,23 +501,23 @@
             report = crashreport.CrashReport(path)
             print report
             if not check_report(report):
-                move_invalid_report(report.path)
+                move_invalid_report(report)
                 continue
             
             if not parse_crashdata(report):
-                move_invalid_report(report.path)
+                move_invalid_report(report)
                 continue
             
             if not recognize_report(report):
-                move_invalid_report(report.path)
+                move_invalid_report(report)
                 continue
             
             if not store_report(report):
-                move_invalid_report(report.path)
+                move_invalid_report(report)
                 continue
             
             if not send_confirmation_email(report):
-                move_invalid_report(report.path)
+                move_invalid_report(report)
                 continue
             
             discard_report(report.path)

Modified: soc2012/tzabal/server-side/akcrs-setup/database.sql
==============================================================================
--- soc2012/tzabal/server-side/akcrs-setup/database.sql	Wed Aug 22 20:56:53 2012	(r240746)
+++ soc2012/tzabal/server-side/akcrs-setup/database.sql	Wed Aug 22 21:46:20 2012	(r240747)
@@ -9,7 +9,7 @@
 DROP TYPE bugstate;
 
 
-CREATE TYPE bugstate AS ENUM ('NOSTATE', 'Open', 'Analyzed', 'Feedback', 'Closed', 'Suspended');
+CREATE TYPE bugstate AS ENUM ('Open', 'Analyzed', 'Feedback', 'Closed', 'Suspended');
 
 
 CREATE TABLE users
@@ -36,13 +36,14 @@
 CREATE TABLE reports
 (
     id serial NOT NULL,
-    bug_id integer NOT NULL,
+    bug_id integer,
     user_id integer NOT NULL,
     received_datetime timestamp DEFAULT CURRENT_TIMESTAMP,
     --received_date date DEFAULT CURRENT_DATE,
     --received_time time DEFAULT LOCALTIME,
     confirmation_code char(16) NOT NULL,
     confirmed boolean DEFAULT false,
+    bugs_id integer[],
     crashtype text,
     crashdate text,
     hostname text,
@@ -79,6 +80,4 @@
     CONSTRAINT reports_pkey PRIMARY KEY (id),
     CONSTRAINT reports_bug_id_fkey FOREIGN KEY (bug_id) REFERENCES bugs (id),
     CONSTRAINT reports_user_id_fkey FOREIGN KEY (user_id) REFERENCES users (id)
-);
-
-INSERT INTO bugs (id, state, reported) VALUES (-1, 'NOSTATE', -1);
\ No newline at end of file
+);
\ No newline at end of file

Modified: soc2012/tzabal/server-side/akcrs-setup/setup
==============================================================================
--- soc2012/tzabal/server-side/akcrs-setup/setup	Wed Aug 22 20:56:53 2012	(r240746)
+++ soc2012/tzabal/server-side/akcrs-setup/setup	Wed Aug 22 21:46:20 2012	(r240747)
@@ -76,7 +76,7 @@
 make config
 
 # Build, install and clean
-make install clean
+make -DBATCH install clean
 
 # Launch Apache at system startup
 echo 'apache22_enable="YES"' >> /etc/rc.conf

Modified: soc2012/tzabal/server-side/akcrs-website/akcrs/models.py
==============================================================================
--- soc2012/tzabal/server-side/akcrs-website/akcrs/models.py	Wed Aug 22 20:56:53 2012	(r240746)
+++ soc2012/tzabal/server-side/akcrs-website/akcrs/models.py	Wed Aug 22 21:46:20 2012	(r240747)
@@ -47,11 +47,12 @@
     __tablename__ = 'reports'
     
     id = Column(Integer, Sequence('reports_id_seq'), primary_key=True)
-    bug_id = Column(Integer, ForeignKey('bugs.id'), nullable=False)
+    bug_id = Column(Integer, ForeignKey('bugs.id'))
     user_id = Column(Integer, ForeignKey('users.id'), nullable=False)
     received_datetime = Column(TIMESTAMP, default=datetime.datetime.now)
     confirmation_code = Column(CHAR(length=16), nullable=False)
     confirmed = Column(Boolean, default='false')
+    bugs_id = Column(ARRAY(Integer))
     crashtype = Column(Text)
     crashdate = Column(Text)
     hostname = Column(Text)

Modified: soc2012/tzabal/server-side/akcrs-website/setup.py
==============================================================================
--- soc2012/tzabal/server-side/akcrs-website/setup.py	Wed Aug 22 20:56:53 2012	(r240746)
+++ soc2012/tzabal/server-side/akcrs-website/setup.py	Wed Aug 22 21:46:20 2012	(r240747)
@@ -14,8 +14,6 @@
     'pyramid_debugtoolbar',
     'zope.sqlalchemy',
     'waitress',
-    # tutorial added dependency. maybe remove (docutils)
-    'docutils',
     ]
 
 setup(name='akcrs',



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120822214622.1C0EC106567B>