示例#1
0
	def querySetting( self, setting ):
		cmd = [ sys.executable, self.getBuildScript(), 'query', setting ] + self.getParameters()
		runner = RunCommand( cmd, 1800 )
		runner.run()
		if runner.getReturnCode() != 0:
			raise MomError( 'Cannot query setting "{0}" for build script "{1}":\n {2}!'\
				.format( setting, self.getBuildScript(), runner.getStdErrAsString() ) )

		output = runner.getStdOutAsString()
		if not output:
			raise MomError( 'The build script "{0}" did not return a value! It said:\n {1}'
				.format( self.getBuildScript(), runner.getStdErrAsString() ) )

		line = output.strip()
		groups = re.search( '^(.+?): (.+)$', line )
		if not groups:
			raise MomError( 'Did not understand this output: "{0}"!'.format( line ) )

		variable = groups.groups()[1]
		return variable
示例#2
0
	def __getXmlSvnLog( self, url, revision, cap ):
		cmd = [ self.getCommand(), '--non-interactive', 'log', '--xml' ]
		if revision == 0:
			cmd.extend( ['--limit', '1' ] )
		cmd.extend( ['-rHEAD:{0}'.format( str( revision ).strip() ), url ] )
		runner = RunCommand( cmd, 3600, searchPaths = self.getCommandSearchPaths() )
		runner.run()
		if runner.getReturnCode() == 0:
			return minidom.parseString( runner.getStdOut().encode( "utf-8" ) )
		elif runner.getTimedOut() == True:
			raise ConfigurationError( 'Getting svn log for "{0}" timed out.'.format( self.getUrl() ) )
		else:
			msg = runner.getStdErrAsString().strip()
			raise ConfigurationError( 'Getting svn log failed: "{0}"'.format( msg ) )
	def update( self, folder ):
		cmd = [ 'git', 'pull' ]
		if self.getUseRebase():
			cmd.append( '--rebase' )
		runner = RunCommand( cmd )
		runner.setWorkingDir( folder )
		runner.run()
		if runner.getReturnCode() == 0:
			mApp().debugN( self, 2, 'Updated the git repository at "{0}"'.format( folder ) )
		else:
			# we are not raising an exception, because we do not want the master to die because of, for example, a temporary 
			# network outage
			message = runner.getStdErrAsString()
			mApp().message( self, 'Updating the git repository at "{0}" failed: "{1}"'.format( folder, message ) )
示例#4
0
	def runCommand( self, cmd, description, timeout = None, zeroReturnCode = True ):
		'''Helper method to run shell commands in tests. It creates a RunCommand object, runs it,
		and returns it. If the return code is not zero, it dumps the output of the command.'''

		runner = RunCommand( cmd, timeout )
		runner.run()
		if zeroReturnCode and runner.getReturnCode() != 0:
			print( '\n' )
			print( 'command failed: {0}'.format( description ) )
			print( 'output:' )
			print( runner.getStdOutAsString() )
			print( 'error output:' )
			print( runner.getStdErrAsString() )
		self.assertEqual( runner.getReturnCode() == 0, zeroReturnCode )
		return runner