source: branches/testScripts/NBsvnCommand.py @ 669

Last change on this file since 669 was 648, checked in by jpfasano, 12 years ago

Added function to determine latest stable build number of a project.

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#! /usr/bin/env python
2
3import os
4import urllib2
5import re
6
7import NBlogMessages
8import NBemail
9import NBosCommand
10
11#------------------------------------------------------------------------
12# Function for executing svn commands
13#  svnCmd: String representing svn command
14#  dir: Directory where command is to be run from
15#  project: Coin project running the command (this is used to provide
16#           a better message if an error is detected
17#------------------------------------------------------------------------
18def run(svnCmd,dir,project) :
19  retVal='OK'
20  os.chdir(dir)
21  NBlogMessages.writeMessage('  '+svnCmd)
22  result = NBosCommand.run(svnCmd)
23  if result['returnCode'] != 0 :
24    NBemail.sendCmdMsgs(project,result,svnCmd)
25    retVal='Error'
26  return retVal
27
28
29#------------------------------------------------------------------------
30# Function which returns the latest stable version of a project
31#------------------------------------------------------------------------
32def latestStableVersion(project) :
33  url='https://projects.coin-or.org/svn/'+project+'/stable'
34  handle=urllib2.urlopen(url)
35  html=handle.read()
36  handle.close()
37
38  # In html code find the latest version number
39  #   <li><a href="3.2/">3.2/</a></li>
40  #   <li><a href="3.3/">3.3/</a></li>
41  r=r'<li><a href="(\d*\.\d*)/">(\d*\.\d*)/</a></li>'
42  findResult=re.findall(r,html)
43  latestStableVersionRepeated2Times = findResult[-1:][0]
44  latestStableVersion=latestStableVersionRepeated2Times[0]
45  return latestStableVersion
46 
47 
48 
Note: See TracBrowser for help on using the repository browser.