Project

General

Profile

1
import os
2
import pysvn
3
import pystache
4
import json
5
import shutil
6

    
7

    
8
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
class DeployModule(object):
13
    def __init__(self, name=None, type_source=None, version=None, url=None, mail=None, deploy_repository=None,
14
                 deploy_repository_url=None, goal=None, dict_values=None, cron=None, nightly=None):
15
        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
            self.cron = cron
25
            self.nightly = nightly
26
        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
            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
            if 'cron' in dict_values:
38
                self.cron = dict_values['cron']
39
            if 'nightly' in dict_values:
40
                self.nightly = dict_values['nightly']
41

    
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
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
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
    if "dnet-container-openaireplus" in name:
65
        print name
66
    try:
67
        data =json.loads(client.cat(e.name + "/trunk/deploy.info"))
68
        if isinstance(data, list):
69
            for d_elem in data:
70
                data_list.append(d_elem)
71
                d = DeployModule(dict_values=d_elem)
72
                if containsAny(d.name,"\\/:"):
73
                    continue
74
                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
    except Exception as e:
82
        print "NOT FOUND IN %s "% (name.split('/')[-1])
83
        print e
84

    
85
f.write("\n")
86
f.write("</modules>")
87
f.close()
(1-1/5)