~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/importd/util.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2005-06-16 09:16:18 UTC
  • mfrom: (63.1.136)
  • Revision ID: Arch-1:rocketfuel@canonical.com%launchpad--devel--0--patch-1860
Importd update to survive database restarts.
Patches applied:

 * robert.collins@canonical.com/launchpad--devel--0--patch-130
   merge from rf

 * robert.collins@canonical.com/launchpad--devel--0--patch-131
   merge from rf

 * robert.collins@canonical.com/launchpad--devel--0--patch-132
   update importd to use transactions-when-needed to allow survival of database restarts

 * robert.collins@canonical.com/launchpad--devel--0--patch-133
   pull up sync logic from importd.CVSStrategy to importd.CSCVSStrategy

 * robert.collins@canonical.com/launchpad--devel--0--patch-134
   remove forgotten abort

 * robert.collins@canonical.com/launchpad--devel--0--patch-135
   merge from rf

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    # -- David Allouche 2005-02-16
62
62
    from canonical.database.sqlbase import ZopelessTransactionManager
63
63
    if ZopelessTransactionManager._installed is None:
64
 
        return initZopeless()
 
64
        return initZopeless(implicitBegin=False)
65
65
    else:
66
66
        return ZopelessTransactionManager._installed
67
67
 
76
76
                "Tried to get import jobs with status %r" % importstatus)
77
77
 
78
78
    # get a new transaction
79
 
    getTxnManager().abort()
80
 
 
81
 
    # XXX: Awful hack -- launchpad updated the database, so we need to
82
 
    #      reset our connection so that we can see it.
83
 
    #        - Andrew Bennetts, 2005-01-27
84
 
    #      Copied that from buildbot to fix reloading.
85
 
    #        - David Alouche, 2005-01-27
 
79
    # spiv who is reviewing this suggested this XXX abstraction
 
80
    # violation. RBC 20050608
86
81
    from canonical.database.sqlbase import SQLBase
87
 
    SQLBase._connection.rollback()
88
 
    SQLBase._connection.begin()
 
82
    if SQLBase._connection is not None:
 
83
        getTxnManager().abort()
89
84
    getTxnManager().begin()
90
85
 
91
86
    jobs = []
100
95
        job.slave_home = slave_home
101
96
        job.archive_mirror_dir = archive_mirror_dir
102
97
        jobs.append(job)
 
98
    getTxnManager().abort()
103
99
    return jobs
104
100
 
105
101
def jobsBuilders(jobs, slavenames, runner_path=None, autotest=False):
239
235
 
240
236
    def getSeries(self):
241
237
        """return the sourcesource our job is for"""
242
 
        getTxnManager() # init zopeless if needed
243
238
        return ProductSeries.get(self.seriesID)
244
239
 
245
240
    def startBuild(self):
 
241
        getTxnManager().begin()
246
242
        self.setDateStarted()
247
243
        getTxnManager().commit()
248
244
 
249
245
    def setDateStarted(self):
250
 
        #datetime.utcnow() truncates to the day
251
246
        self.getSeries().datestarted = UTC_NOW
252
 
 
 
247
        
253
248
    def buildFinished(self, successful):
 
249
        getTxnManager().begin()
254
250
        self.setDateFinished()
255
251
        if self.getSeries().importstatus == ImportStatus.TESTING:
256
252
            self.setAutotested(successful)
259
255
        getTxnManager().commit()
260
256
 
261
257
    def setDateFinished(self):
262
 
        #datetime.utcnow() truncates to the day
263
258
        self.getSeries().datefinished = UTC_NOW
264
259
 
265
260
    def setAutotested(self, successful):