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