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
def make_job(path, client, f):
50
    try:
51
        data =json.loads(client.cat(path))
52
        if isinstance(data, list):
53
            for d_elem in data:
54
                data_list.append(d_elem)
55
                d = DeployModule(dict_values=d_elem)
56
                if containsAny(d.name,"\\/:"):
57
                    continue
58
                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
    except Exception as e:
66
        pass
67

    
68

    
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
f.write("\n")
77
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
    make_job(e.name + "/branches/saxonHE-SOLR772/deploy.info", client, f)
85
    make_job(e.name + "/branches/solr75/deploy.info", client, f)
86
    make_job(e.name + "/branches/dnet-hadoop/deploy.info", client, f)
87

    
88

    
89
    
90

    
91
f.write("\n")
92
f.write("</modules>")
93
f.close()
(1-1/6)