improve logging
authorymh <ymh.work@gmail.com>
Fri, 04 Jun 2010 19:39:17 +0200
changeset 46 5503cfcdea68
parent 45 6f0e728839d6
child 47 16e91607ef4a
improve logging
sbin/create_python_env.py
--- a/sbin/create_python_env.py	Fri Jun 04 19:09:02 2010 +0200
+++ b/sbin/create_python_env.py	Fri Jun 04 19:39:17 2010 +0200
@@ -96,12 +96,12 @@
     try:
         
         #get pylucene
-        logger.info("Get Pylucene from %s " % URLS['PYLUCENE'][res_source_key])
+        logger.notify("Get Pylucene from %s " % URLS['PYLUCENE'][res_source_key])
         pylucene_src = os.path.join(src_dir,"pylucene.tar.gz")
         urllib.urlretrieve(URLS['PYLUCENE'][res_source_key], pylucene_src)
         tf = tarfile.open(pylucene_src,'r:gz')
         pylucene_base_path = os.path.join(src_dir,"pylucene") 
-        logger.info("Extract Pylucene to %s " % pylucene_base_path)
+        logger.notify("Extract Pylucene to %s " % pylucene_base_path)
         tf.extractall(pylucene_base_path)
         tf.close()
         
@@ -114,23 +114,23 @@
         if system_str == 'Linux' :
             olddir = os.getcwd()
             patch_dest_path = os.path.join(lib_dir,'site-packages','setuptools-0.6c11-py'+'%s.%s' % (sys.version_info[0], sys.version_info[1])+'.egg')
-            logger.info("Patch jcc : %s " % (patch_dest_path))
+            logger.notify("Patch jcc : %s " % (patch_dest_path))
             os.chdir(patch_dest_path)
             p = patch.fromfile(os.path.join(jcc_src_path,"jcc","patches","patch.43.0.6c11"))
             p.apply()
             os.chdir(olddir)
 
-        logger.info("Install jcc")
+        logger.notify("Install jcc")
         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'],
                         cwd=jcc_src_path,
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
         #install pylucene
         
-        logger.info("Install pylucene")
+        logger.notify("Install pylucene")
         #modify makefile
         makefile_path = os.path.join(pylucene_src_path,"Makefile")
-        logger.info("Modify makefile %s " % makefile_path)
+        logger.notify("Modify makefile %s " % makefile_path)
         shutil.move( makefile_path, makefile_path+"~" )
 
         destination= open( makefile_path, "w" )
@@ -157,31 +157,39 @@
         destination.close()
         os.remove(makefile_path+"~" )
 
+        logger.notify("pylucene make")
         call_subprocess(['make'],
                         cwd=os.path.abspath(pylucene_src_path),
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
 
+        logger.notify("pylucene make install")
         call_subprocess(['make', 'install'],
                         cwd=os.path.abspath(pylucene_src_path),
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
 
+        logger.notify("PyXML install : %s " % URLS['PYXML'][res_source_key])
         if sys.version_info >= (2,6):
+            logger.notify("PyXML -> python version >= 2.6 : patching")
             pyxml_src = os.path.join(src_dir,"pyxml.tar.gz")
             urllib.urlretrieve(URLS['PYXML'][res_source_key], pyxml_src)
+            logger.notify("PyXML -> python version >= 2.6 : extract archive")
             tf = tarfile.open(pyxml_src,'r:gz')
             pyxml_base_path = os.path.join(src_dir,"pyxml") 
             tf.extractall(pyxml_base_path)
             tf.close()
+
             #patch
             pyxml_version = os.listdir(pyxml_base_path)[0]            
             pyxml_path = os.path.join(pyxml_base_path, pyxml_version)
             olddir = os.getcwd()
             os.chdir(pyxml_path)
+            logger.notify("PyXML -> python version >= 2.6 : do patch %s : %s " % (pyxml_path, URLS['PYXML']['patch']))
             p = patch.fromfile(URLS['PYXML']['patch'])
             p.apply()
             os.chdir(olddir)
+            logger.notify("PyXML -> python version >= 2.6 : install")
             call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), '--build='+os.path.abspath(pyxml_base_path), '--no-download', pyxml_version],
                     cwd=os.path.abspath(tmp_dir),
                     filter_stdout=filter_python_develop,
@@ -192,27 +200,31 @@
                     filter_stdout=filter_python_develop,
                     show_stdout=True)
         
-                        
+        logger.notify("Install Distribute from %s" % URLS['DISTRIBUTE'][res_source_key])
         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['DISTRIBUTE'][res_source_key]],
                         cwd=os.path.abspath(tmp_dir),
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
                         
+        logger.notify("Install Psycopg2 from %s" % URLS['PSYCOPG2'][res_source_key])
         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PSYCOPG2'][res_source_key]],
                         cwd=os.path.abspath(tmp_dir),
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
 
+        logger.notify("Install PIL from %s" % URLS['PIL'][res_source_key])
         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PIL'][res_source_key]],
                         cwd=os.path.abspath(tmp_dir),
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
-
+                        
+        logger.notify("Install 4Suite-XML from %s" % URLS['FOURSUITE_XML'][res_source_key])
         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), URLS['FOURSUITE_XML'][res_source_key]],
                         cwd=os.path.abspath(tmp_dir),
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
                         
+        logger.notify("Clear source dir")
         shutil.rmtree(src_dir)
 
     finally:
@@ -223,7 +235,7 @@
 
 def ensure_dir(dir):
     if not os.path.exists(dir):
-        logger.info('Creating directory %s' % dir)
+        logger.notify('Creating directory %s' % dir)
         os.makedirs(dir)
 
 def filter_python_develop(line):