Package magma ::
Package magma ::
Module create_phex_release_magmas
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 """Create the magma lists for a Phex release via the commandline.
22
23 Usage: create_phex_release_magmas.py <windows-release-path> <osx-release-path> <gnu/linux-file-release-path>
24
25 Examples:
26 - create_phex_release_magmas.py phex_3.2.2.104.exe phex_3.2.2.104_osx.zip phex_3.2.2.104.zip
27
28 Plans:
29 - Use MAGMAv0.4
30 - Do it less hackish: Use the magma module.
31
32 Ideas:
33 - Get list of Sourceforge servers autmatically.
34 """
35
36
37
38 SOURCEFORGE_MIRRORS = ["http://heanet.dl.sourceforge.net/sourceforge/", "http://internap.dl.sourceforge.net/sourceforge/", "http://mesh.dl.sourceforge.net/sourceforge/", "http://puzzle.dl.sourceforge.net/sourceforge/", "http://easynews.dl.sourceforge.net/sourceforge/", "http://osdn.dl.sourceforge.net/sourceforge/", "http://keihanna.dl.sourceforge.net/sourceforge/", "http://optusnet.dl.sourceforge.net/sourceforge/", "http://switch.dl.sourceforge.net/sourceforge/", "http://ovh.dl.sourceforge.net/sourceforge/", "http://kent.dl.sourceforge.net/sourceforge/", "http://osdn.dl.sourceforge.net/sourceforge/", "http://jaist.dl.sourceforge.net/sourceforge/", "http://ufpr.dl.sourceforge.net/sourceforge/", "http://umn.dl.sourceforge.net/sourceforge/", "http://nchc.dl.sourceforge.net/sourceforge/", "http://jaist.dl.sourceforge.net/sourceforge/"]
39
40
41 PHEX_MAGMA_FOOTER = '''
42
43 # Phex: Copyright 2006 The Phex Team - GPL-2 or later.
44 # Link: http://phex.org
45 # Developer-link: http://sf.net/projects/phex
46
47 '''
48
49
51 """Create the magma files for all release types. """
52
53
54 RELEASE_TYPES = ["win", "osx", "other"]
55
56
57 for i in range(len(RELEASE_TYPES)):
58 create_phex_magma(files[i], release_type = RELEASE_TYPES[i])
59
60
73
74
75
76
77
79 """Create the magma file for a specific release type.
80
81 @param release_type: The target platform: win, osx or other
82 @type release_type: String """
83
84
85
86
87
88 if release_type == "osx":
89 magma_data = """#MAGMAv0.2 magnet:?mt=.&as=http://dateien.draketo.de/phex_osx.magma&dn=phex_osx.magma"""
90 elif release_type == "win":
91 magma_data = """#MAGMAv0.2 magnet:?mt=.&as=http://dateien.draketo.de/phex_win.magma&dn=phex_win.magma"""
92 elif release_type == "other":
93 magma_data = """#MAGMAv0.2 magnet:?mt=.&as=http://dateien.draketo.de/phex_win.magma&dn=phex_win.magma"""
94 else:
95 raise Exception("Unsupported release type. Supported types are osx, win, other")
96
97
98
99 magma_data += """
100
101 #This list contains the update URLs for Phex.
102
103 list:
104
105 - """
106
107
108
109 SHA1 = sha1
110
111
112
113 magma_data += '''"magnet:?xt=urn:sha1:''' + SHA1 + '''
114 &dn=''' + filename
115
116
117
118 GNET_CLIENT_SOURCES = ["http://edrikor.dyndns.org:9846/uri-res/N2R?urn:sha1:"]
119 for i in GNET_CLIENT_SOURCES:
120 magma_data += "&xs=" + i + SHA1
121
122
123
124 magma_data += "&as=http://www.freebase.be/g2/dlcount.php?sha1=" + SHA1
125
126
127
128 for i in SOURCEFORGE_MIRRORS:
129 magma_data += "&as=" + i + "phex/" + filename
130
131
132
133 magma_data += '''"'''
134
135
136 magma_data += '''
137 file-name: ''' + filename
138
139
140 magma_data += PHEX_MAGMA_FOOTER
141
142
143 if release_type == "osx":
144 write_to_file("phex_osx.magma", magma_data)
145 elif release_type == "win":
146 write_to_file("phex_win.magma", magma_data)
147 elif release_type == "other":
148 write_to_file("phex_other.magma", magma_data)
149 else:
150 raise Exception("Unsupported release type. Supported types are osx, win, other")
151
152
153
155 """Write the data to a file at the path."""
156 f = open(path, "w")
157 f.write(data)
158 f.close()
159 log("wrote " + path)
160
161
162 -def log(data, log_type = "console"):
163 """Log some data."""
164 if log_type == "console":
165 print data
166
167
168
170 """Usage instructions.
171
172 @return: Usage instructions (String)."""
173
174 usage = __doc__.split("\n\n")[1:]
175 usage_string = "\n\n".join(usage)
176 return usage_string
177
178
179
181 """Do all doctests.
182
183 @return: None"""
184 from doctest import testmod
185 testmod()
186
187
188 if __name__ == "__main__":
189 _test()
190 from sys import argv
191 if argv[1] in ["--help", "-h", "?", "--usage"]:
192 print usage()
193 else:
194 create_phex_magmas(argv[1:])
195