1 |
27228
|
sandro.lab
|
import os
|
2 |
|
|
import pysvn
|
3 |
|
|
import pystache
|
4 |
|
|
import json
|
5 |
|
|
import shutil
|
6 |
|
|
|
7 |
|
|
|
8 |
31377
|
sandro.lab
|
def containsAny(str, set):
|
9 |
|
|
"""Check whether 'str' contains ANY of the chars in 'set'"""
|
10 |
|
|
return 1 in [c in str for c in set]
|
11 |
|
|
|
12 |
27228
|
sandro.lab
|
class DeployModule(object):
|
13 |
|
|
def __init__(self, name=None, type_source=None, version=None, url=None, mail=None, deploy_repository=None,
|
14 |
31461
|
sandro.lab
|
deploy_repository_url=None, goal=None, dict_values=None, cron=None, nightly=None):
|
15 |
27228
|
sandro.lab
|
if not dict_values:
|
16 |
|
|
self.name = name
|
17 |
|
|
self.type_source = type_source
|
18 |
|
|
self.version = version
|
19 |
|
|
self.url = url
|
20 |
|
|
self.mail = mail
|
21 |
|
|
self.goal = goal
|
22 |
|
|
self.deploy_repository = deploy_repository
|
23 |
|
|
self.deploy_repository_url = deploy_repository_url
|
24 |
27241
|
sandro.lab
|
self.cron = cron
|
25 |
31461
|
sandro.lab
|
self.nightly = nightly
|
26 |
27228
|
sandro.lab
|
else:
|
27 |
|
|
self.name = dict_values['name']
|
28 |
|
|
self.type_source = dict_values['type_source']
|
29 |
|
|
self.version = dict_values['version']
|
30 |
|
|
self.url = dict_values['url']
|
31 |
|
|
self.mail = dict_values['mail']
|
32 |
|
|
self.goal = dict_values['goal']
|
33 |
30964
|
sandro.lab
|
if 'deploy_repository' in dict_values:
|
34 |
|
|
self.deploy_repository = dict_values['deploy_repository']
|
35 |
|
|
if 'deploy_repository_url' in dict_values:
|
36 |
|
|
self.deploy_repository_url = dict_values['deploy_repository_url']
|
37 |
27241
|
sandro.lab
|
if 'cron' in dict_values:
|
38 |
|
|
self.cron = dict_values['cron']
|
39 |
31461
|
sandro.lab
|
if 'nightly' in dict_values:
|
40 |
|
|
self.nightly = dict_values['nightly']
|
41 |
27228
|
sandro.lab
|
|
42 |
|
|
|
43 |
|
|
if os.path.isdir('/tmp/DSL40'):
|
44 |
|
|
shutil.rmtree('/tmp/DSL40')
|
45 |
|
|
print "DELETED Folder"
|
46 |
|
|
os.makedirs('/tmp/DSL40')
|
47 |
|
|
client = pysvn.Client()
|
48 |
|
|
|
49 |
|
|
entry_list = client.ls("http://svn-public.driver.research-infrastructures.eu/driver/dnet40/build/")
|
50 |
|
|
entry_module_list = client.ls("http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/")
|
51 |
31461
|
sandro.lab
|
webapp_module_list = client.ls("http://svn-public.driver.research-infrastructures.eu/driver/dnet40/webapps/")
|
52 |
|
|
entry_list = entry_list+ entry_module_list + webapp_module_list
|
53 |
27228
|
sandro.lab
|
data_list =[]
|
54 |
|
|
renderer = pystache.Renderer()
|
55 |
|
|
|
56 |
|
|
f = open("/tmp/DSL40/configuration.xml", "w")
|
57 |
|
|
f.write('<?xml version="1.0"?>')
|
58 |
|
|
f.write("\n")
|
59 |
|
|
f.write("<modules>")
|
60 |
|
|
f.write("\n")
|
61 |
|
|
|
62 |
|
|
for e in entry_list:
|
63 |
|
|
name = e.name
|
64 |
31461
|
sandro.lab
|
if "dnet-container-openaireplus" in name:
|
65 |
30964
|
sandro.lab
|
print name
|
66 |
27228
|
sandro.lab
|
try:
|
67 |
|
|
data =json.loads(client.cat(e.name + "/trunk/deploy.info"))
|
68 |
30964
|
sandro.lab
|
if isinstance(data, list):
|
69 |
|
|
for d_elem in data:
|
70 |
|
|
data_list.append(d_elem)
|
71 |
|
|
d = DeployModule(dict_values=d_elem)
|
72 |
31377
|
sandro.lab
|
if containsAny(d.name,"\\/:"):
|
73 |
|
|
continue
|
74 |
30964
|
sandro.lab
|
f.write(renderer.render(d))
|
75 |
|
|
f.write("\n")
|
76 |
|
|
else:
|
77 |
|
|
data_list.append(data)
|
78 |
|
|
d = DeployModule(dict_values=data)
|
79 |
|
|
f.write(renderer.render(d))
|
80 |
|
|
f.write("\n")
|
81 |
27228
|
sandro.lab
|
except Exception as e:
|
82 |
|
|
print "NOT FOUND IN %s "% (name.split('/')[-1])
|
83 |
27241
|
sandro.lab
|
print e
|
84 |
27228
|
sandro.lab
|
|
85 |
|
|
f.write("\n")
|
86 |
|
|
f.write("</modules>")
|
87 |
|
|
f.close()
|