1 | #! /usr/bin/env python |
---|
2 | |
---|
3 | import os |
---|
4 | import urllib2 |
---|
5 | import re |
---|
6 | |
---|
7 | import NBlogMessages |
---|
8 | import NBemail |
---|
9 | import 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 | #------------------------------------------------------------------------ |
---|
18 | def 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 | #------------------------------------------------------------------------ |
---|
33 | def 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 | |
---|