Project

General

Profile

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

    
7

    
8
class DeployModule(object):
9
    def __init__(self, name=None, type_source=None, version=None, url=None, mail=None, deploy_repository=None,
10
                 deploy_repository_url=None, goal=None, dict_values=None, cron=None):
11
        if not dict_values:
12
            self.name = name
13
            self.type_source = type_source
14
            self.version = version
15
            self.url = url
16
            self.mail = mail
17
            self.goal = goal
18
            self.deploy_repository = deploy_repository
19
            self.deploy_repository_url = deploy_repository_url
20
            self.cron = cron
21
        else:
22
            self.name = dict_values['name']
23
            self.type_source = dict_values['type_source']
24
            self.version = dict_values['version']
25
            self.url = dict_values['url']
26
            self.mail = dict_values['mail']
27
            self.goal = dict_values['goal']
28
            if 'deploy_repository' in dict_values:
29
                self.deploy_repository = dict_values['deploy_repository']
30
            if 'deploy_repository_url' in dict_values:
31
                self.deploy_repository_url = dict_values['deploy_repository_url']
32
            if 'cron' in dict_values:
33
                self.cron = dict_values['cron']
34

    
35

    
36
if os.path.isdir('/tmp/DSL40'):
37
    shutil.rmtree('/tmp/DSL40')
38
    print "DELETED Folder"
39
os.makedirs('/tmp/DSL40')
40
client = pysvn.Client()
41

    
42
entry_list = client.ls("http://svn-public.driver.research-infrastructures.eu/driver/dnet40/build/")
43
entry_module_list = client.ls("http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/")
44
entry_list = entry_list+ entry_module_list
45
data_list =[]
46
renderer = pystache.Renderer()
47

    
48
f = open("/tmp/DSL40/configuration.xml", "w")
49
f.write('<?xml version="1.0"?>')
50
f.write("\n")
51
f.write("<modules>")
52
f.write("\n")
53

    
54
for e in entry_list:
55
    name = e.name
56
    if "dnet-postgres-mdstore" in name:
57
        print name
58
    try:
59
        data =json.loads(client.cat(e.name + "/trunk/deploy.info"))
60
        if isinstance(data, list):
61
            for d_elem in data:
62
                data_list.append(d_elem)
63
                d = DeployModule(dict_values=d_elem)
64
                f.write(renderer.render(d))
65
                f.write("\n")
66
        else:
67
            data_list.append(data)
68
            d = DeployModule(dict_values=data)
69
            f.write(renderer.render(d))
70
            f.write("\n")
71
    except Exception as e:
72
        print "NOT FOUND IN %s "% (name.split('/')[-1])
73
        print e
74

    
75
f.write("\n")
76
f.write("</modules>")
77
f.close()
(1-1/4)