svn-gvsig-desktop / branches / v2_0_0_prep / build / buildman / bin / bmplugins / SVNPlugIn.py @ 27363
History | View | Annotate | Download (2.45 KB)
1 |
from bmbase.IPlugIn import IPlugIn |
---|---|
2 |
from bmbase.PlugInManager import PlugInManager |
3 |
from bmcore.BMUtil import BMUtil |
4 |
import os |
5 |
|
6 |
class SVNPlugIn(IPlugIn): |
7 |
def __init__(self): |
8 |
IPlugIn.__init__(self)
|
9 |
self._options = ['co','up', 'checkout', 'update'] |
10 |
self._option = "" |
11 |
self._projectPath = "" |
12 |
self._svnUrl = "" |
13 |
|
14 |
|
15 |
def init(self): |
16 |
self.addGoal("svn", "This plugin is able to do checkout or update of a svn repository") |
17 |
self.addGoalOption("svn","--option", "sets the option of subversion: "+ str(self._options)) |
18 |
self.addGoalOption("svn","--project-path", "sets the path of the project.") |
19 |
self.addGoalOption("svn","--url", "sets the path of the url") |
20 |
execute = False
|
21 |
while self._arguments.read("svn"): |
22 |
execute = True
|
23 |
if execute:
|
24 |
args = [""]
|
25 |
while self._arguments.read("--option",args): |
26 |
self._option = args[0] |
27 |
|
28 |
args = [""]
|
29 |
while self._arguments.read("--project-path",args): |
30 |
self._projectPath=args[0] |
31 |
|
32 |
args = [""]
|
33 |
while self._arguments.read("--url",args): |
34 |
self._svnUrl=args[0] |
35 |
|
36 |
self.setExecute(True) |
37 |
|
38 |
def initFromXML(self,node): |
39 |
if node.localName=="svn": |
40 |
if node.hasAttributes():
|
41 |
if node.attributes.has_key("option"): |
42 |
self._option = node.attributes.get("option").value |
43 |
if node.attributes.has_key("project-path"): |
44 |
self._projectPath = node.attributes.get("project-path").value |
45 |
if node.attributes.has_key("url"): |
46 |
self._svnUrl = node.attributes.get("url").value |
47 |
|
48 |
def execute(self): |
49 |
if self._option=="": |
50 |
self.reportError("Missing svn option, use one of " + str(self._options)) |
51 |
return False |
52 |
if self._option not in self._options: |
53 |
self.reportError("not supported svn option, use one of " + str(self._options)) |
54 |
return False |
55 |
if self._projectPath=="": |
56 |
self.reportError("Missing required project path option") |
57 |
return False |
58 |
if self._option == "co" or self._option == "checkout": |
59 |
if self._svnUrl == "": |
60 |
self.reportError("Missing required svn url ption") |
61 |
return False |
62 |
|
63 |
self._projectPath = os.path.abspath(self._projectPath) |
64 |
projectName = os.path.basename(self._projectPath)
|
65 |
|
66 |
print "Executing Plugin:" + str(self.__class__) |
67 |
bmutil = BMUtil() |
68 |
svnCommand = "svn " + self._option |
69 |
if self._option in ['co', 'checkout']: |
70 |
svnCommand += " " + self._svnUrl + " " + self._projectPath |
71 |
else:
|
72 |
if self._option in ['up', 'update']: |
73 |
svnCommand += " " + self._projectPath |
74 |
os.system(svnCommand) |
75 |
return True |
76 |
|
77 |
PlugInManager().registerPlugIn("SVNPlugIn",SVNPlugIn())
|
78 |
|
79 |
|