Revision a577f110 snf-pithos-web-client/setup.py

b/snf-pithos-web-client/setup.py
174 174
                out.setdefault(package, []).append(prefix+name)
175 175
    return out
176 176

  
177

  
178
"""
179
Gwt clea/build helpers
180
"""
181
import subprocess as sp
182
import glob
183

  
184
def clean_gwt(root="../", public_dir="bin/www/gr.grnet.pithos.web.Pithos/"):
185
    curdir = os.getcwd()
186
    os.chdir(root)
187
    rcode = sp.call(["ant", "clean"])
188
    if rcode == 1:
189
        raise Exception("GWT clean failed")
190
    os.chdir(curdir)
191
    pub_dir = os.path.abspath(os.path.join(root, public_dir))
192
    static_dir = os.path.abspath(os.path.join("pithos_web_client", "static", \
193
        "pithos_web_client"))
194
    templates_dir = os.path.abspath(os.path.join("pithos_web_client", \
195
        "templates", "pithos_web_client"))
196
    clean_static = ["rm", "-r"] + glob.glob(os.path.join(static_dir, "*"))
197
    clean_templates = ["rm", "-r"] + glob.glob(os.path.join(templates_dir, "*"))
198

  
199
    # clean dirs
200
    if len(clean_static) > 2:
201
        sp.call(clean_static)
202
    if len(clean_static) > 2:
203
        sp.call(clean_templates)
204

  
205

  
206
def build_gwt(root="../", public_dir="bin/www/gr.grnet.pithos.web.Pithos/"):
207
    curdir = os.getcwd()
208
    os.chdir(root)
209
    # run ant on root dir
210
    rcode = sp.call(["ant"])
211
    if rcode == 1:
212
        raise Exception("GWT build failed")
213
    os.chdir(curdir)
214

  
215

  
216
    pub_dir = os.path.abspath(os.path.join(root, public_dir))
217
    static_dir = os.path.abspath(os.path.join("pithos_web_client", "static", \
218
        "pithos_web_client"))
219
    templates_dir = os.path.abspath(os.path.join("pithos_web_client", \
220
        "templates", "pithos_web_client"))
221

  
222
    clean_static = ["rm", "-r"] + glob.glob(os.path.join(static_dir, "*"))
223
    clean_templates = ["rm", "-r"] + glob.glob(os.path.join(templates_dir, "*"))
224

  
225
    # clean dirs
226
    if len(clean_static) > 2:
227
        sp.call(clean_static)
228
    if len(clean_static) > 2:
229
        sp.call(clean_templates)
230

  
231
    copy_static = ["cp", "-r"] + glob.glob(os.path.join(pub_dir, "*")) + [static_dir]
232
    copy_index = ["cp", os.path.join(pub_dir, "index.html"), templates_dir]
233
    sp.call(copy_static)
234
    sp.call(copy_index)
235

  
236
    index = os.path.join(templates_dir, "index.html")
237
    index_data = file(index).read()
238
    index_data = index_data.replace('href="', 'href="{{ MEDIA_URL }}pithos_web_client/')
239
    index_data = index_data.replace('" src="', '" src="{{ MEDIA_URL }}pithos_web_client/')
240
    index_data = index_data.replace('\' src=\'', '" src="{{ MEDIA_URL }}pithos_web_client/')
241
    index_data = index_data.replace('url(', 'url({{ MEDIA_URL }}pithos_web_client/')
242

  
243
    ifile = file(index, "w+")
244
    ifile.write(index_data)
245
    ifile.close()
246

  
247

  
248
# do we need to run ant ???
249
if any(x in ''.join(sys.argv) for x in ["sdist", "build"]):
250
    build_gwt()
251

  
252
if any(x in ''.join(sys.argv) for x in ["clean"]):
253
    clean_gwt()
254

  
255

  
177 256
setup(
178 257
    name='snf-pithos-web-client',
179 258
    version=VERSION,
......
197 276
    entry_points={
198 277
        'synnefo': [
199 278
             'web_apps = pithos_web_client.synnefo_settings:installed_apps',
200
             'urls = pithos_web_client.urls:urlpatterns',
279
             'urls = pithos_web_client.synnefo_settings:urlpatterns',
201 280
             'web_static = pithos_web_client.synnefo_settings:static_files'
202 281
        ]
203 282
    }

Also available in: Unified diff