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/DSL45'):
44
    shutil.rmtree('/tmp/DSL45')
45
    print "DELETED Folder"
46
os.makedirs('/tmp/DSL45')
47
client = pysvn.Client()
48

    
49

    
50
entry_list = client.ls("http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/")
51
data_list =[]
52
renderer = pystache.Renderer()
53

    
54
f = open("/tmp/DSL45/configuration.xml", "w")
55
f.write('<?xml version="1.0"?>')
56
f.write("\n")
57
f.write("<modules>")
58
f.write("\n")
59

    
60
for e in entry_list:
61
    name = e.name
62
    if "dnet-container-openaireplus" in name:
63
        print name
64
    try:
65
        data =json.loads(client.cat(e.name + "/trunk/deploy.info"))
66
        if isinstance(data, list):
67
            for d_elem in data:
68
                data_list.append(d_elem)
69
                d = DeployModule(dict_values=d_elem)
70
                if containsAny(d.name,"\\/:"):
71
                    continue
72
                f.write(renderer.render(d))
73
                f.write("\n")
74
        else:
75
            data_list.append(data)
76
            d = DeployModule(dict_values=data)
77
            f.write(renderer.render(d))
78
            f.write("\n")
79
    except Exception as e:
80
        print "NOT FOUND IN %s "% (name.split('/')[-1])
81
        print e
82

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