/[collab-qa]/udd/udd/orphaned_packages_gatherer.py
ViewVC logotype

Diff of /udd/udd/orphaned_packages_gatherer.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

udd/src/udd/orphaned_packages_gatherer.py revision 1080 by neronus-guest, Mon Aug 11 23:15:37 2008 UTC udd/udd/orphaned_packages_gatherer.py revision 1976 by lucas, Wed Jul 27 17:22:32 2011 UTC
# Line 7  This script imports the list of orphaned Line 7  This script imports the list of orphaned
7  import aux  import aux
8  from gatherer import gatherer  from gatherer import gatherer
9  import re  import re
10    from psycopg2 import IntegrityError
11    
12  def get_gatherer(connection, config, source):  def get_gatherer(connection, config, source):
13    return orphaned_packages_gatherer(connection, config, source)    return orphaned_packages_gatherer(connection, config, source)
# Line 16  class orphaned_packages_gatherer(gathere Line 17  class orphaned_packages_gatherer(gathere
17      gatherer.__init__(self, connection, config, source)      gatherer.__init__(self, connection, config, source)
18      self.assert_my_config('bugs-path', 'table', 'unarchived-table')      self.assert_my_config('bugs-path', 'table', 'unarchived-table')
19    
20    title_re = re.compile('^(ITA|RFA|O): ([^\s]*) [-]+ (.*)$')    title_re = re.compile('^(ITA|RFA|O): ([^\s]*)( [-]+ (.*))?$')
21    otime_re = re.compile('^<!-- time:([0-9]+) ')    otime_re = re.compile('^<!-- time:([0-9]+) ')
22    chtitle_re = re.compile('^<strong>Changed Bug title to `O:.*$')    chtitle_re = re.compile('^<strong>Changed Bug title to `O:.*$')
23    
# Line 44  class orphaned_packages_gatherer(gathere Line 45  class orphaned_packages_gatherer(gathere
45      #for the new data:      #for the new data:
46      cur = self.cursor()      cur = self.cursor()
47      cur2 = self.cursor()      cur2 = self.cursor()
48      cur.execute("SELECT id, title, arrival FROM %s WHERE package = 'wnpp' AND status != 'done' AND title ~* '^(ITA|RFA|O):' AND id NOT IN (SELECT id from %s WHERE id > merged_with)" % (self.my_config['unarchived-table'], self.my_config['unarchive-table'] + '_merged_with')      cur.execute("SELECT id, title, arrival FROM %s WHERE package = 'wnpp' AND status != 'done' AND title ~* '^(ITA|RFA|O):' AND id NOT IN (SELECT id from %s WHERE id > merged_with)" % (self.my_config['unarchived-table'], self.my_config['unarchived-table'] + '_merged_with'))
49      rows = cur.fetchall()      rows = cur.fetchall()
50    
51      cur2.execute("DELETE FROM %s" % self.my_config['table'])      cur2.execute("DELETE FROM %s" % self.my_config['table'])
52      cur2.execute("PREPARE opkgs_insert AS INSERT INTO %s VALUES ($1, $2, $3, $4, $5)" % self.my_config['table'])      cur2.execute("PREPARE opkgs_insert AS INSERT INTO %s (source, type, bug, description, orphaned_time) VALUES ($1, $2, $3, $4, $5)" % self.my_config['table'])
53    
54      for row in rows:      for row in rows:
55        m = self.title_re.match(row[1])        m = self.title_re.match(row[1])
56        if m == None:        if m == None:
57          print "Invalid bug: #" + str(row[0]) + ": " + row[1]          print "Invalid bug: #" + str(row[0]) + ": " + row[1]
58        else:        else:
59            #print "bug: #" + str(row[0]) + ": " + row[1]
60          time_orphaned = self.get_time_orphaned(row[0])          time_orphaned = self.get_time_orphaned(row[0])
61          if time_orphaned == None:          try:
62            cur2.execute("EXECUTE opkgs_insert(%s,%s,%s,%s,%s)", (            if time_orphaned == None:
63              m.group(2), m.group(1), row[0],              cur2.execute("EXECUTE opkgs_insert(%s,%s,%s,%s,%s)", (
64              m.group(3), row[2]))                m.group(2), m.group(1), row[0],
65          else:                m.group(4), row[2]))
66            cur2.execute("EXECUTE opkgs_insert(%s,%s,%s,%s,%s::abstime)", (            else:
67              m.group(2), m.group(1), row[0],              cur2.execute("EXECUTE opkgs_insert(%s,%s,%s,%s,%s::abstime)", (
68              m.group(3), time_orphaned))                m.group(2), m.group(1), row[0],
69                  m.group(4), time_orphaned))
70            except IntegrityError, message:
71              print "Integrity Error inserting bug " + str(row[0]) + " " + m.group(2)
72              continue
73        cur2.execute("ANALYZE %s" % self.my_config['table'])
74    
75  # vim:set et tabstop=2:  # vim:set et tabstop=2:

Legend:
Removed from v.1080  
changed lines
  Added in v.1976

  ViewVC Help
Powered by ViewVC 1.1.5