source: branches/testScripts/NBsvnCommand.py @ 674

Last change on this file since 674 was 674, checked in by jpfasano, 13 years ago

Tried to create a nicer vpath directory name.
Added log message to indicate current directory.

  • 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('  Current directory: '+dir)
22  NBlogMessages.writeMessage('  '+svnCmd)
23  result = NBosCommand.run(svnCmd)
24  if result['returnCode'] != 0 :
25    NBemail.sendCmdMsgs(project,result,svnCmd)
26    retVal='Error'
27  return retVal
28
29
30#------------------------------------------------------------------------
31# Function which returns the latest stable version of a project
32#------------------------------------------------------------------------
33def latestStableVersion(project) :
34  url='https://projects.coin-or.org/svn/'+project+'/stable'
35  handle=urllib2.urlopen(url)
36  html=handle.read()
37  handle.close()
38
39  # In html code find the latest version number
40  #   <li><a href="3.2/">3.2/</a></li>
41  #   <li><a href="3.3/">3.3/</a></li>
42  r=r'<li><a href="(\d*\.\d*)/">(\d*\.\d*)/</a></li>'
43  findResult=re.findall(r,html)
44  latestStableVersionRepeated2Times = findResult[-1:][0]
45  latestStableVersion=latestStableVersionRepeated2Times[0]
46  return latestStableVersion
47 
48 
49 
Note: See TracBrowser for help on using the repository browser.