Package buildslave :: Package commands :: Module base :: Class SourceBaseCommand
[frames] | no frames]

Class SourceBaseCommand

source code

Command --+
          |
         SourceBaseCommand
Known Subclasses:

Abstract base class for Version Control System operations (checkout and update). This class extracts the following arguments from the dictionary received from the master:

Instance Methods
 
setup(self, args)
Override this in a subclass to extract items from the args dict.
source code
 
getCommand(self, name)
Wrapper around utils.getCommand that will output a resonable error message and raise AbandonChain if the command cannot be found
source code
 
start(self)
Start the command.
source code
 
maybeClobber(self, d) source code
 
interrupt(self)
Override this in a subclass to allow commands to be interrupted.
source code
 
doVC(self, res) source code
 
sourcedataMatches(self) source code
 
sourcedirIsPatched(self) source code
 
parseGotRevision(self)
Override this in a subclass.
source code
 
readSourcedata(self)
Read the sourcedata file and return its contents
source code
 
writeSourcedata(self, res) source code
 
sourcedirIsUpdateable(self)
Returns True if the tree can be updated.
source code
 
doVCUpdate(self)
Returns a deferred with the steps to update a checkout.
source code
 
doVCFull(self)
Returns a deferred with the steps to do a fresh checkout.
source code
 
maybeDoVCFallback(self, rc) source code
 
doVCFallback2(self, res) source code
 
maybeNotDoVCFallback(self, rc)
Override this in a subclass if you want to detect unrecoverable checkout errors where clobbering the repo wouldn't help, and stop the current VC chain before it clobbers the repo for future builds.
source code
 
maybeDoVCRetry(self, res)
We get here somewhere after a VC chain has finished.
source code
 
doClobber(self, dummy, dirname, chmodDone=False) source code
 
doClobberTryChmodIfFail(self, rc, dirname) source code
 
doCopy(self, res) source code
 
doPatch(self, res) source code
 
setFileContents(self, filename, contents)
Put the given contents in filename; this is a bit more succinct than opening, writing, and closing, and has the advantage of being patchable in tests.
source code

Inherited from Command: __init__, __providedBy__, __provides__, doInterrupt, doStart, sendStatus

Class Variables
  sourcedata = ''

Inherited from Command: __implemented__, debug, interrupted, running

Method Details

setup(self, args)

source code 

Override this in a subclass to extract items from the args dict.

Overrides: Command.setup
(inherited documentation)

start(self)

source code 

Start the command. This method should return a Deferred that will fire when the command has completed. The Deferred's argument will be ignored.

This method should be overridden by subclasses.

Overrides: Command.start
(inherited documentation)

interrupt(self)

source code 

Override this in a subclass to allow commands to be interrupted. May be called multiple times, test and set self.interrupted=True if this matters.

Overrides: Command.interrupt
(inherited documentation)

parseGotRevision(self)

source code 

Override this in a subclass. It should return a string that represents which revision was actually checked out, or a Deferred that will fire with such a string. If, in a future build, you were to pass this 'got_revision' string in as the 'revision' component of a SourceStamp, you should wind up with the same source code as this checkout just obtained.

It is probably most useful to scan self.command.stdout for a string of some sort. Be sure to set keepStdout=True on the VC command that you run, so that you'll have something available to look at.

If this information is unavailable, just return None.

readSourcedata(self)

source code 

Read the sourcedata file and return its contents

Returns:
source data

maybeNotDoVCFallback(self, rc)

source code 

Override this in a subclass if you want to detect unrecoverable checkout errors where clobbering the repo wouldn't help, and stop the current VC chain before it clobbers the repo for future builds.

Use 'raise AbandonChain' to pass up a halt if you do detect such.

maybeDoVCRetry(self, res)

source code 

We get here somewhere after a VC chain has finished. res could be:

- 0: the operation was successful
- nonzero: the operation failed. retry if possible
- AbandonChain: the operation failed, someone else noticed. retry.
- Failure: some other exception, re-raise

setFileContents(self, filename, contents)

source code 

Put the given contents in filename; this is a bit more succinct than opening, writing, and closing, and has the advantage of being patchable in tests. Note that the enclosing directory is not automatically created, nor is this an "atomic" overwrite.