Ticket #333: buildbot-0.7.8-FtpDownload.patch

File buildbot-0.7.8-FtpDownload.patch, 10.4 kB (added by dtrosset, 4 months ago)

Separate FtpDownload? and Uncompress steps (from pristine 0.7.8, i.e. not from FtpTar?)

  • old-buildbot/buildbot/slave/commands.py

    old new  
    22 
    33import os, re, signal, shutil, types, time 
    44from stat import ST_CTIME, ST_MTIME, ST_SIZE 
     5from ftplib import FTP 
    56 
    67from zope.interface import implements 
    78from twisted.internet.protocol import ProcessProtocol 
     
    16031604 
    16041605registerSlaveCommand("svn", SVN, command_version) 
    16051606 
     1607from twisted.protocols.ftp import FTPClient, FileConsumer, DTPFactory 
     1608from twisted.internet.protocol import ClientFactory, ClientCreator 
     1609 
     1610class FtpDownload(SourceBase): 
     1611    """FTP download operation. In addition to the arguments 
     1612    handled by SourceBase, this command reads the following keys: 
     1613 
     1614    ['ftphost'] (required): the FTP hostname 
     1615    ['ftpfile'] (required): the FTP file to download 
     1616    ['ftpuser'] (required): the FTP username 
     1617    ['ftppass'] (required): the FTP password 
     1618    """ 
     1619 
     1620    header = "FTP download operation" 
     1621 
     1622    def setup(self, args): 
     1623        SourceBase.setup(self, args) 
     1624        self.ftphost = args['ftphost'] 
     1625        self.ftpfile = args['ftpfile'] or 'anonymous' 
     1626        self.ftpuser = args['ftpuser'] or 'buildbot@buildbot.net' 
     1627        self.ftppass = args['ftppass'] 
     1628        self.sourcedata = "%s\n" % self.ftpfile 
     1629 
     1630    def sourcedirIsUpdateable(self): 
     1631        return False 
     1632 
     1633    def doVCFull(self): 
     1634        # Create the build directory 
     1635        self._dirbuild = os.path.join(self.builder.basedir, self.srcdir) 
     1636        os.mkdir(self._dirbuild) 
     1637        # Download the file 
     1638        self._pathfile = os.path.join(self._dirbuild, 
     1639                                      os.path.basename(self.ftpfile)) 
     1640 
     1641        creator = ClientCreator(reactor, FTPClient, username=self.ftpuser, 
     1642                                password=self.ftppass, passive=True) 
     1643        self.sendStatus({'stdout': "Connecting to '" + self.ftphost + "'\n"}) 
     1644        d = creator.connectTCP(self.ftphost, 21) 
     1645        d.addCallbacks(self.connectionMade, self.connectionFail) 
     1646        return d 
     1647        
     1648    def connectionFail(self, failure, toto): 
     1649        self.sendStatus({'stderr': "FTP connection failed: " + failure.getErrorMessage() + "\n"}) 
     1650        return 1 
     1651 
     1652    def connectionMade(self, ftpClient): 
     1653        if ftpClient.greeting: 
     1654            self.sendStatus({'stdout': "  " + str(ftpClient.greeting) + "\n"}) 
     1655        self.sendStatus({'stdout': "Retrieving file '" + self.ftpfile + "' as '" + self._pathfile + "'\n"}) 
     1656        self._file = open(self._pathfile, "w") 
     1657        d = ftpClient.retrieveFile(self.ftpfile, FileConsumer(self._file)) 
     1658        d.addCallbacks(self.transferDone, self.transferFail) 
     1659        return d 
     1660 
     1661    def transferFail(self, failure): 
     1662        self.sendStatus({'stderr': "FTP transfer failed: " + failure.getErrorMessage() + "\n"}) 
     1663        return 1 
     1664 
     1665    def transferDone(self, results): 
     1666        self._file.close() 
     1667        self.sendStatus({'stdout': "FTP transfer done\n"}) 
     1668        try: 
     1669            result = results[0] 
     1670            res, msgs = result[1][0] 
     1671            for msg in msgs: 
     1672                self.sendStatus({'stdout': "  " + msg + "\n"}) 
     1673        except ValueError: 
     1674            pass 
     1675        return 0 
     1676 
     1677    def parseGotRevision(self): 
     1678        return None 
     1679 
     1680 
     1681registerSlaveCommand("ftpdownload", FtpDownload, command_version) 
     1682 
    16061683class Darcs(SourceBase): 
    16071684    """Darcs-specific VC operation. In addition to the arguments 
    16081685    handled by SourceBase, this command reads the following keys: 
  • old-buildbot/buildbot/steps/shell.py

    old new  
    276276    descriptionDone = ["configure"] 
    277277    command = ["./configure"] 
    278278 
     279class Uncompress(ShellCommand): 
     280 
     281    name = "uncompress" 
     282    haltOnFailure = 1 
     283    description = ["uncompressing"] 
     284    descriptionDone = ["uncompress"] 
     285 
     286    def __init__(self, workdir=None, 
     287                 description=None, descriptionDone=None, 
     288                 command=None, filename=None, 
     289                 **kwargs): 
     290        if not command and filename: 
     291            command = ["tar", "axvf", filename, "--strip", "1"] 
     292 
     293        ShellCommand.__init__(self, command=command, **kwargs) 
     294 
     295 
    279296class WarningCountingShellCommand(ShellCommand): 
    280297    warnCount = 0 
    281298    warningPattern = '.*warning[: ].*' 
  • old-buildbot/buildbot/steps/source.py

    old new  
    473473        self.startCommand(cmd, warnings) 
    474474 
    475475 
     476class FtpDownload(Source): 
     477    """I perform FTP download of a source archive file (or any other file). 
     478    """ 
     479 
     480    name = 'ftpdownload' 
     481 
     482    def __init__(self, ftphost=None, ftpuser=None, ftppass=None, ftpfile=None, 
     483                 directory=None, **kwargs): 
     484        """ 
     485        @type  ftphost: string 
     486        @param ftphost: hostname of the FTP server to connect to. 
     487 
     488        @type  ftpfile: string 
     489        @param ftpfile: full path to the file to retreive from FTP server. On 
     490                        slave, only the last path component of this path will 
     491                        be used. 
     492 
     493        @type  ftpuser: string 
     494        @param ftpuser: username to use for logging on the FTP server. 
     495 
     496        @type  ftphost: string 
     497        @param ftphost: password to use for logging on the FTP server. 
     498 
     499        """ 
     500 
     501        if not kwargs.has_key('workdir') and directory is not None: 
     502            # deal with old configs 
     503            warn("Please use workdir=, not directory=", DeprecationWarning) 
     504            kwargs['workdir'] = directory 
     505 
     506        self.ftphost = ftphost 
     507        self.ftpfile = ftpfile 
     508        self.ftpuser = ftpuser 
     509        self.ftppass = ftppass 
     510 
     511        Source.__init__(self, **kwargs) 
     512        self.addFactoryArguments(ftphost=ftphost, 
     513                                 ftpfile=ftpfile, 
     514                                 ftpuser=ftpuser, 
     515                                 ftppass=ftppass, 
     516                                 directory=directory, 
     517                                 ) 
     518 
     519        if not ftpfile or not ftphost: 
     520            raise ValueError("you must specify ftphost and ftpfile") 
     521 
     522 
     523    def computeSourceRevision(self, changes): 
     524        return None  
     525 
     526    def startVC(self, branch, revision, patch): 
     527 
     528        warnings = [] 
     529 
     530        if self.args['mode'] != "export": 
     531            warnings.append("WARNING: FtpDownload slave can only do full " 
     532                            "retreival, do not specify mode other than export") 
     533 
     534        self.args['ftphost'] = self.ftphost 
     535        self.args['ftpfile'] = self.ftpfile 
     536        self.args['ftpuser'] = self.ftpuser 
     537        self.args['ftppass'] = self.ftppass 
     538        self.args['revision'] = revision 
     539        self.args['patch'] = patch 
     540 
     541        revstuff = [] 
     542        if branch is not None and branch != self.branch: 
     543            revstuff.append("[branch]") 
     544        if revision is not None: 
     545            revstuff.append("r%s" % revision) 
     546        if patch is not None: 
     547            revstuff.append("[patch]") 
     548        self.description.extend(revstuff) 
     549        self.descriptionDone.extend(revstuff) 
     550 
     551        cmd = LoggedRemoteCommand("ftpdownload", self.args) 
     552        self.startCommand(cmd, warnings) 
     553 
     554 
    476555class Darcs(Source): 
    477556    """Check out a source tree from a Darcs repository at 'repourl'. 
    478557 
  • old-buildbot/docs/buildbot.texinfo

    old new  
    207207* Bzr::                          
    208208* P4::                           
    209209* Git::                          
     210* FtpDownload::                          
    210211 
    211212Simple ShellCommand Subclasses 
    212213 
     
    43884389* Bzr::                          
    43894390* P4::                           
    43904391* Git::                          
     4392* FtpDownload:: 
    43914393@end menu 
    43924394 
    43934395@node CVS, SVN, Source Checkout, Source Checkout 
     
    47634765@end table 
    47644766 
    47654767 
    4766 @node Git,  , P4, Source Checkout 
     4768@node Git, FtpDownload, P4, Source Checkout 
    47674769@subsubsection Git 
    47684770 
    47694771@cindex Git Checkout 
     
    47894791@end table 
    47904792 
    47914793 
     4794@node FtpDownload,  , Git, Source Checkout 
     4795@subsubsection FtpDownload 
     4796@cindex FTP download 
     4797@bsindex buildbot.steps.source.FtpDownload 
     4798 
     4799 
     4800The @code{FtpDownload} build step performs a download of a specified 
     4801file from an FTP server (usually a source archive) to the build 
     4802directory. 
     4803 
     4804The FtpDownload step only supports one mode argument: export. 
     4805 
     4806The FtpDownload step takes the following arguments: 
     4807 
     4808@table @code 
     4809@item ftphost 
     4810(required): The hostname of the FTP server to connect to. 
     4811 
     4812@item ftpfile 
     4813(required): The full path to the file to dowload from the FTP server. 
     4814The FTP download is done using image (binary) mode. 
     4815 
     4816@item ftpuser 
     4817(optional): The username to use for logging on the FTP server. 
     4818 
     4819@item ftppass 
     4820(optional): The password to use for logging on the FTP server. 
     4821 
     4822@end table 
     4823 
     4824The @code{FtpDownload} step can be followed by a @code{Uncompress} 
     4825step to expand the downloaded source archive. 
     4826 
     4827 
    47924828@node ShellCommand, Simple ShellCommand Subclasses, Source Checkout, Build Steps 
    47934829@subsection ShellCommand 
    47944830 
     
    49274963file less verbose. 
    49284964 
    49294965@menu 
     4966* Uncompress:: 
    49304967* Configure::                    
    49314968* Compile::                      
    49324969* Test::                         
     
    49354972* SetProperty::                  
    49364973@end menu 
    49374974 
    4938 @node Configure, Compile, Simple ShellCommand Subclasses, Simple ShellCommand Subclasses 
     4975@node Uncompress, Configure, Simple ShellCommand Subclasses, Simple ShellCommand Subclasses 
     4976@subsubsection Uncompress 
     4977 
     4978@bsindex buildbot.steps.shell.Uncompress 
     4979 
     4980This is intended to handle the @code{tar axvf} step following an FTP 
     4981download step. The default command is build from a @code{filename=} 
     4982parameter. The command becomes @code{tar axvf <filename> --strip 1}. 
     4983Stripping one directory name brings all files directly into the 
     4984build directory, allowing further compile steps. The default command 
     4985can be changed by providing a @code{command=} parameter. 
     4986 
     4987@node Configure, Compile, Uncompress, Simple ShellCommand Subclasses 
    49394988@subsubsection Configure 
    49404989 
    49414990@bsindex buildbot.steps.shell.Configure