Project

General

Profile

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 46356 sandro.lab
if os.path.isdir('/tmp/DSL45'):
44
    shutil.rmtree('/tmp/DSL45')
45 27228 sandro.lab
    print "DELETED Folder"
46 46356 sandro.lab
os.makedirs('/tmp/DSL45')
47 27228 sandro.lab
client = pysvn.Client()
48
49 46708 sandro.lab
def make_job(path, client, f):
50 27228 sandro.lab
    try:
51 46708 sandro.lab
        data =json.loads(client.cat(path))
52 30964 sandro.lab
        if isinstance(data, list):
53
            for d_elem in data:
54
                data_list.append(d_elem)
55
                d = DeployModule(dict_values=d_elem)
56 31377 sandro.lab
                if containsAny(d.name,"\\/:"):
57
                    continue
58 30964 sandro.lab
                f.write(renderer.render(d))
59
                f.write("\n")
60
        else:
61
            data_list.append(data)
62
            d = DeployModule(dict_values=data)
63
            f.write(renderer.render(d))
64
            f.write("\n")
65 27228 sandro.lab
    except Exception as e:
66 46708 sandro.lab
        pass
67 27228 sandro.lab
68 46708 sandro.lab
69
entry_list = client.ls("http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/") + client.ls("http://svn-public.driver.research-infrastructures.eu/driver/LBS/")+ client.ls("http://svn-public.driver.research-infrastructures.eu/driver/dnet50/modules/")
70
71
data_list =[]
72
renderer = pystache.Renderer()
73
74
f = open("/tmp/DSL45/configuration.xml", "w")
75
f.write('<?xml version="1.0"?>')
76 27228 sandro.lab
f.write("\n")
77 46708 sandro.lab
f.write("<modules>")
78
f.write("\n")
79
80
for e in entry_list:
81
    name = e.name
82
    make_job(e.name + "/trunk/deploy.info", client, f)
83
    make_job(e.name + "/branches/saxonHE/deploy.info", client, f)
84
85
86
87
f.write("\n")
88 27228 sandro.lab
f.write("</modules>")
89
f.close()