improve default logging + virtualenv creation
authorymh <ymh.work@gmail.com>
Mon, 11 Feb 2013 14:10:22 +0100
changeset 31 29caac899e1f
parent 27 daaafc916dc4
child 32 21b0003310f3
improve default logging + virtualenv creation
.hgignore
.pydevproject
run/.keepme
run/log/.keepme
src/egonomy/config.py.tmpl
virtualenv/res/lib/lib_create_env.py
virtualenv/res/src/distribute-0.6.31.tar.gz
virtualenv/res/src/jpegsrc.v9.tar.gz
virtualenv/res/src/zlib-1.2.7.tar.gz
virtualenv/web/res/res_create_env.py
--- a/.hgignore	Wed Feb 06 13:15:27 2013 +0100
+++ b/.hgignore	Mon Feb 11 14:10:22 2013 +0100
@@ -11,4 +11,4 @@
 \.DS_Store$
 ^web/static/media
 ^src/log\.txt$
-
+^run/log/
\ No newline at end of file
--- a/.pydevproject	Wed Feb 06 13:15:27 2013 +0100
+++ b/.pydevproject	Mon Feb 11 14:10:22 2013 +0100
@@ -1,8 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?eclipse-pydev version="1.0"?>
-
-<pydev_project>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">egonomy_python</pydev_property>
+<?eclipse-pydev version="1.0"?><pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python_egonomy</pydev_property>
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
 <path>/egonomy/src</path>
--- a/src/egonomy/config.py.tmpl	Wed Feb 06 13:15:27 2013 +0100
+++ b/src/egonomy/config.py.tmpl	Mon Feb 11 14:10:22 2013 +0100
@@ -60,15 +60,13 @@
 # Make this unique, and don't share it with anybody.
 SECRET_KEY = 'abc123'
 
+LOG_FILE = os.path.abspath(os.path.join(BASE_DIR,"../../run/log/log.txt"))
+LOG_LEVEL = logging.DEBUG
 # A sample logging configuration. The only tangible logging
 # performed by this configuration is to send an email to
 # the site admins on every HTTP 500 error when DEBUG=False.
 # See http://docs.djangoproject.com/en/dev/topics/logging for
 # more details on how to customize your logging configuration.
-#LOG_FILE = os.path.abspath(os.path.join(BASE_DIR,"../../run/log/log.txt"))
-#LOG_LEVEL = logging.DEBUG
-#logging.basicConfig(filename=LOG_FILE, level=LOG_LEVEL)
-
 LOGGING = {
     'version': 1,
     'disable_existing_loggers': False,
@@ -76,18 +74,46 @@
         'require_debug_false': {
             '()': 'django.utils.log.RequireDebugFalse'
         }
+    },    
+    'formatters' : {
+        'simple' : {
+            'format': "%(asctime)s - %(levelname)s : %(message)s",
+        },
+        'semi-verbose': {
+            'format': '%(levelname)s %(asctime)s %(module)s %(message)s'
+        },                    
     },
     'handlers': {
         'mail_admins': {
             'level': 'ERROR',
             'filters': ['require_debug_false'],
             'class': 'django.utils.log.AdminEmailHandler'
-        }
+        },
+        'stream_to_console': {
+            'level': LOG_LEVEL,
+            'class': 'logging.StreamHandler'
+        },
+        'file': {
+            'level': LOG_LEVEL,
+            'class': 'logging.FileHandler',
+            'filename': LOG_FILE,
+            'formatter': 'semi-verbose',
+        },
     },
     'loggers': {
+        'django.db.backends':{
+            'handlers': ['file'],
+            'level': LOG_LEVEL,
+            'propagate': True,
+        },                
         'django.request': {
-            'handlers': ['mail_admins'],
-            'level': 'ERROR',
+            'handlers': ['file'],
+            'level': LOG_LEVEL,
+            'propagate': True,
+        },
+        'egonomy': {
+            'handlers': ['file'],
+            'level': LOG_LEVEL,
             'propagate': True,
         },
     }
--- a/virtualenv/res/lib/lib_create_env.py	Wed Feb 06 13:15:27 2013 +0100
+++ b/virtualenv/res/lib/lib_create_env.py	Mon Feb 11 14:10:22 2013 +0100
@@ -22,7 +22,7 @@
     'DJANGO-REGISTRATION': { 'setup': 'django-registration', 'url':'https://bitbucket.org/ubernostrum/django-registration/get/v0.8.tar.gz', 'local':"django-registration-0.8.tar.gz", 'install': {'method': 'easy_install', 'option_str': '-Z', 'dict_extra_env': None}},
     'SOUTH': { 'setup': 'South', 'url':'http://www.aeracode.org/releases/south/south-0.7.5.tar.gz', 'local':"south-0.7.5.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
     'SORL_THUMBNAIL' : { 'setup': 'sorl-thumbnail', 'url':'https://github.com/sorl/sorl-thumbnail/archive/master.tar.gz', 'local':"sorl-thumbnail-v11.12.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
-    'LIBJPEG': {'setup': None, 'url':'jpegsrc.v8d.tar.gz', 'local':'jpegsrc.v8d.tar.gz', 'install': {'method': 'install_libjpeg', 'option_str': None, 'dict_extra_env': None}},
+    'LIBJPEG': {'setup': None, 'url':'jpegsrc.v9.tar.gz', 'local':'jpegsrc.v9.tar.gz', 'install': {'method': 'install_libjpeg', 'option_str': None, 'dict_extra_env': None}},
     'ZLIB': {'setup': None, 'url':'zlib-1.2.7.tar.gz', 'local':'zlib-1.2.7.tar.gz', 'install': {'method': 'install_zlib', 'option_str': None, 'dict_extra_env': None}},
     'PYCRYPTO': {'setup': 'pycrypto', 'url':'https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz', 'local':'pycrypto-2.6.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
     'PARAMIKO': {'setup': 'paramiko', 'url':'https://github.com/paramiko/paramiko/archive/v1.9.0.tar.gz', 'local':'paramiko-1.9.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}},
@@ -172,6 +172,7 @@
     
     def install_lib(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop):
         lib_src = os.path.join(src_dir,lib_name+".tar.gz")
+        logger.notify("Copy %s to %s " % (res_env.URLS[lib_key][res_source_key],lib_src))
         shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src)
         tf = tarfile.open(lib_src,'r:gz')
         lib_base_path = os.path.join(src_dir, lib_name) 
@@ -181,30 +182,27 @@
         
         lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0])
     
-        logger.notify(libname + " configure")
-        call_subprocess(['configure', '--prefix='+os.path.abspath(home_dir)] + configure_options,
+        logger.notify(lib_name + " configure in " + lib_src_path)
+        call_subprocess(['./configure', '--prefix='+os.path.abspath(home_dir)] + configure_options,
                         cwd=os.path.abspath(lib_src_path),
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
         
-        logger.notify(libname + " make")
+        logger.notify(lib_name + " make in " + lib_src_path)
         call_subprocess(['make'],
                         cwd=os.path.abspath(lib_src_path),
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
     
-        logger.notify(libname + "make install")
+        logger.notify(lib_name + "make install in " + lib_src_path)
         call_subprocess(['make', 'install'],
                         cwd=os.path.abspath(lib_src_path),
                         filter_stdout=filter_python_develop,
                         show_stdout=True)
-        return install_lib
+    return install_lib
 
 install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared'])
 install_zlib = gen_install_comp_lib("zlib", "ZLIB", [])
-
-
-    
     
 
 def lib_generate_install_methods(path_locations, src_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None):
@@ -302,6 +300,7 @@
                     extra_env['TMPDIR'] = os.path.abspath(tmp_dir)          
                 #isinstance(lst, (list, tuple))
                 if key not in ignore_packages:
+                    logger.notify("install %s with method %s" % (key, repr(method)))
                     if callable(method):
                         method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop)
                     elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']:  
Binary file virtualenv/res/src/distribute-0.6.31.tar.gz has changed
Binary file virtualenv/res/src/jpegsrc.v9.tar.gz has changed
Binary file virtualenv/res/src/zlib-1.2.7.tar.gz has changed
--- a/virtualenv/web/res/res_create_env.py	Wed Feb 06 13:15:27 2013 +0100
+++ b/virtualenv/web/res/res_create_env.py	Mon Feb 11 14:10:22 2013 +0100
@@ -27,6 +27,11 @@
     'DJANGO-TASTYPIE',
 ]
 
+if system_str != "Windows" and 'PIL' in INSTALLS:
+    i = INSTALLS.index('PIL')
+    INSTALLS.insert(i, 'ZLIB')
+    INSTALLS.insert(i, 'LIBJPEG')
+
 if system_str == "Linux":
     INSTALLS.insert(2, 'DISTRIBUTE')