Ticket #333: buildbot-0.7.8-FtpDownload.patch
| File buildbot-0.7.8-FtpDownload.patch, 10.4 kB (added by dtrosset, 4 months ago) |
|---|
-
old-buildbot/buildbot/slave/commands.py
old new 2 2 3 3 import os, re, signal, shutil, types, time 4 4 from stat import ST_CTIME, ST_MTIME, ST_SIZE 5 from ftplib import FTP 5 6 6 7 from zope.interface import implements 7 8 from twisted.internet.protocol import ProcessProtocol … … 1603 1604 1604 1605 registerSlaveCommand("svn", SVN, command_version) 1605 1606 1607 from twisted.protocols.ftp import FTPClient, FileConsumer, DTPFactory 1608 from twisted.internet.protocol import ClientFactory, ClientCreator 1609 1610 class 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 1681 registerSlaveCommand("ftpdownload", FtpDownload, command_version) 1682 1606 1683 class Darcs(SourceBase): 1607 1684 """Darcs-specific VC operation. In addition to the arguments 1608 1685 handled by SourceBase, this command reads the following keys: -
old-buildbot/buildbot/steps/shell.py
old new 276 276 descriptionDone = ["configure"] 277 277 command = ["./configure"] 278 278 279 class 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 279 296 class WarningCountingShellCommand(ShellCommand): 280 297 warnCount = 0 281 298 warningPattern = '.*warning[: ].*' -
old-buildbot/buildbot/steps/source.py
old new 473 473 self.startCommand(cmd, warnings) 474 474 475 475 476 class 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 476 555 class Darcs(Source): 477 556 """Check out a source tree from a Darcs repository at 'repourl'. 478 557 -
old-buildbot/docs/buildbot.texinfo
old new 207 207 * Bzr:: 208 208 * P4:: 209 209 * Git:: 210 * FtpDownload:: 210 211 211 212 Simple ShellCommand Subclasses 212 213 … … 4388 4389 * Bzr:: 4389 4390 * P4:: 4390 4391 * Git:: 4392 * FtpDownload:: 4391 4393 @end menu 4392 4394 4393 4395 @node CVS, SVN, Source Checkout, Source Checkout … … 4763 4765 @end table 4764 4766 4765 4767 4766 @node Git, , P4, Source Checkout4768 @node Git, FtpDownload, P4, Source Checkout 4767 4769 @subsubsection Git 4768 4770 4769 4771 @cindex Git Checkout … … 4789 4791 @end table 4790 4792 4791 4793 4794 @node FtpDownload, , Git, Source Checkout 4795 @subsubsection FtpDownload 4796 @cindex FTP download 4797 @bsindex buildbot.steps.source.FtpDownload 4798 4799 4800 The @code{FtpDownload} build step performs a download of a specified 4801 file from an FTP server (usually a source archive) to the build 4802 directory. 4803 4804 The FtpDownload step only supports one mode argument: export. 4805 4806 The 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. 4814 The 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 4824 The @code{FtpDownload} step can be followed by a @code{Uncompress} 4825 step to expand the downloaded source archive. 4826 4827 4792 4828 @node ShellCommand, Simple ShellCommand Subclasses, Source Checkout, Build Steps 4793 4829 @subsection ShellCommand 4794 4830 … … 4927 4963 file less verbose. 4928 4964 4929 4965 @menu 4966 * Uncompress:: 4930 4967 * Configure:: 4931 4968 * Compile:: 4932 4969 * Test:: … … 4935 4972 * SetProperty:: 4936 4973 @end menu 4937 4974 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 4980 This is intended to handle the @code{tar axvf} step following an FTP 4981 download step. The default command is build from a @code{filename=} 4982 parameter. The command becomes @code{tar axvf <filename> --strip 1}. 4983 Stripping one directory name brings all files directly into the 4984 build directory, allowing further compile steps. The default command 4985 can be changed by providing a @code{command=} parameter. 4986 4987 @node Configure, Compile, Uncompress, Simple ShellCommand Subclasses 4939 4988 @subsubsection Configure 4940 4989 4941 4990 @bsindex buildbot.steps.shell.Configure
![[Buildbot Logo]](/trac/chrome/site/header-text-transparent.png)