~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to database/schema/upgrade.py

  • Committer: Stuart Bishop
  • Date: 2011-12-03 04:49:22 UTC
  • mto: This revision was merged to the branch mainline in revision 14433.
  • Revision ID: stuart.bishop@canonical.com-20111203044922-8x98myzxaecyrdah
Lint and review feedback

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
    WHERE start_time = transaction_timestamp() AT TIME ZONE 'UTC';
117
117
    """)
118
118
 
 
119
 
119
120
def to_seconds(td):
120
121
    """Convert a timedelta to seconds."""
121
122
    return td.days * (24 * 60 * 60) + td.seconds + td.microseconds / 1000000.0
209
210
    if updatelog_exists:
210
211
        cur.execute(FINISH_UPDATE_LOG_SQL)
211
212
 
 
213
 
212
214
def apply_patches_replicated():
213
215
    """Update a Slony-I cluster."""
214
216
 
232
234
    # All the SQL we need to run, combined into one file. This minimizes
233
235
    # Slony-I syncs and downtime.
234
236
    combined_sql = NamedTemporaryFile(prefix='dbupdate', suffix='.sql')
 
237
 
235
238
    def add_sql(sql):
236
239
        sql = sql.strip()
237
240
        if sql != '':
238
 
            assert sql.endswith(';'), "SQL fragment not terminated with ';'"
 
241
            assert sql.endswith(';'), "SQL not terminated with ';': %s" % sql
239
242
            print >> combined_sql, sql
240
243
            # Flush or we might lose statements from buffering.
241
244
            combined_sql.flush()
617
620
 
618
621
_bzr_details_cache = None
619
622
 
 
623
 
620
624
def get_bzr_details():
621
625
    """Return (branch_nick, revno, revision_id) of this Bazaar branch.
622
626
 
638
642
        out, err = p.communicate()
639
643
 
640
644
        if p.returncode == 0:
641
 
            branch_nick, revno, revision_id = out.split(' ',3)
 
645
            branch_nick, revno, revision_id = out.split(' ', 3)
642
646
            log.debug("branch-nick: %s", branch_nick)
643
647
            log.debug("revno: %s", revno)
644
648
            log.debug("revision-id: %s", revision_id)