Package omero :: Package install :: Module bzip2_tool
[hide private]
[frames] | no frames]

Source Code for Module omero.install.bzip2_tool

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  """ 
 5   
 6     Function for enabling/disabling the bzip2.dll which 
 7     comes with PyTables. 
 8   
 9     Copyright 2009 Glencoe Software, Inc. All rights reserved. 
10     Use is subject to license terms supplied in LICENSE.txt 
11   
12  """ 
13   
14  import os, sys 
15   
16 -def bzip2_tool(disable=False):
17 """ 18 Renames the bzip2.dll library which comes with PyTables. 19 """ 20 21 import tables 22 f = tables.__file__ 23 p = os.path.dirname(f) 24 p = os.path.abspath(p) 25 b = os.path.join(p, "bzip2.dll") 26 d = os.path.join(p, "bzip2_DISABLED.dll") 27 if disable: 28 _swap(b,d) 29 else: 30 _swap(d,b)
31
32 -def _swap(f, t):
33 if not os.path.exists(f): 34 print "%s doesn't exist" % f 35 sys.exit(0) 36 os.rename(f, t)
37 38 if __name__ == "__main__": 39 try: 40 if len(sys.argv) == 2: 41 which = sys.argv[1] 42 if which == "disable": 43 which = True 44 elif which == "enable": 45 which = False 46 else: 47 print "Unknown command: ", which 48 sys.exit(2) 49 bzip2_tool(disable=which) 50 sys.exit(0) 51 except Exception, e: 52 print "bzip2_tool failed: ", e 53 sys.exit(1) 54 55 print "Usage: %s disable|enable" % sys.argv[0] 56 sys.exit(2) 57