当前位置: 首页>>代码示例>>Python>>正文


Python log.exception函数代码示例

本文整理汇总了Python中uliweb.utils.common.log.exception函数的典型用法代码示例。如果您正苦于以下问题:Python exception函数的具体用法?Python exception怎么用?Python exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了exception函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

 def delete(self, key):
     _file = os.path.join(self.path_to, self.subdir, self.get_key(key))
     if os.path.exists(_file):
         try:
             os.remove(_file)
         except:
             log.exception()
开发者ID:chyhutu,项目名称:plugs,代码行数:7,代码来源:__init__.py

示例2: execute

    def execute(self, args, options, global_options):
        from uliweb.utils.common import check_apps_dir

        #add apps_dir to global_options and insert it to sys.path
        global_options.apps_dir = apps_dir = os.path.normpath(os.path.join(global_options.project, 'apps'))
        if apps_dir not in sys.path:
            sys.path.insert(0, apps_dir)
        
        if self.check_apps_dirs:
            check_apps_dir(global_options.apps_dir)
        if self.check_apps and args: #then args should be apps
            all_apps = self.get_apps(global_options)
            apps = args
            args = []
            for p in apps:
                if p not in all_apps:
                    print 'Error: Appname %s is not a valid app' % p
                    sys.exit(1)
                else:
                    args.append(p)
        try:
            self.handle(options, global_options, *args)
        except CommandError, e:
            log.exception(e)
            sys.exit(1)
开发者ID:victorlv,项目名称:uliweb,代码行数:25,代码来源:commands.py

示例3: enable_attachments

def enable_attachments(slug, obj, path, movefile=False):
    """
    Used to process new object files upload
    it'll rename the filename to new path and also add content_object according obj
    and if slug is None, then it'll do nothing
    """
    fileserving = AttachmentsFileServing()
    
    for f in get_attachments(slug or obj):
        f.enabled = True
        f.content_object = obj
        if slug and movefile:
            r_filename = fileserving.get_filename(f.filepath, convert=False)
            dir = os.path.dirname(f.filepath)
            _file = os.path.basename(f.filepath)
            new_filename = os.path.join(dir, str(path), _file)
            f.filepath = new_filename
            r_new_filename = fileserving.get_filename(new_filename, convert=False)
            
            #check if the new directory is existed
            new_dir = os.path.dirname(r_new_filename)
            if not os.path.exists(new_dir):
                os.makedirs(new_dir)
            try:
                os.rename(r_filename, r_new_filename)
            except Exception, e:
                log.exception(e)
                log.info("from %s to %s", r_filename, r_new_filename)
        f.save()
        
开发者ID:chyhutu,项目名称:plugs,代码行数:29,代码来源:__init__.py

示例4: get_redis

def get_redis(**options):
    """
    if no options defined, then it'll use settings options
    
    #unix_socket_path = '/tmp/redis.sock'
    connection_pool = {'host':'localhost', 'port':6379}
    #if test after created redis client object
    test_first = False
    
    """
    from uliweb import settings
    from uliweb.utils.common import log
    import redis
        
    options = (options or {})
    options.update(settings.REDIS)
    if 'unix_socket_path' in options:
        client = redis.Redis(unix_socket_path=options['unix_socket_path'])
    else:
        global __connection_pool__
    
        if not __connection_pool__ or __connection_pool__[0] != options['connection_pool']:
            d = {'host':'localhost', 'port':6379}
            d.update(options['connection_pool'])
            __connection_pool__ = (d, redis.ConnectionPool(**d))
        client = redis.Redis(connection_pool=__connection_pool__[1])
        
    if settings.REDIS.test_first:
        try:
            client.info()
        except Exception as e:
            log.exception(e)
            client = None
    return client
    
开发者ID:08haozi,项目名称:uliweb,代码行数:34,代码来源:__init__.py

示例5: get_redis

def get_redis():
    from uliweb import settings
    from uliweb.utils.common import log
    import redis
        
    options = settings.REDIS
    if 'unix_socket_path' in options:
        client = redis.Redis(unix_socket_path=options['unix_socket_path'])
    else:
        global __connection_pool__
    
        if not __connection_pool__ or __connection_pool__[0] != options['connection_pool']:
            d = {'host':'localhost', 'port':6379}
            d.update(options['connection_pool'])
            __connection_pool__ = (d, redis.ConnectionPool(**d))
        client = redis.Redis(connection_pool=__connection_pool__[1])
        
    if settings.REDIS.test_first:
        try:
            client.info()
        except Exception as e:
            log.exception(e)
            client = None
    return client
    
开发者ID:biluo1989,项目名称:uliweb,代码行数:24,代码来源:__init__.py

示例6: delete_filename

 def delete_filename(self, filename):
     f = self.get_filename(filename, filesystem=True, convert=False)
     if os.path.exists(f):
         try:
             os.unlink(f)
         except Exception, e:
             log.exception(e)
开发者ID:biluo1989,项目名称:uliweb,代码行数:7,代码来源:__init__.py

示例7: develop_app_conf

def develop_app_conf():
    module = request.GET['module']
    app_path = pkg.resource_filename(module, '')
    
    form = '<h3>Nothing need to configure!</h3>'
    message = ''
    if is_pyfile_exist(app_path, 'conf'):
        try:
            mod = __import__(module + '.conf', {}, {}, [''])
            f = getattr(mod, 'ManageForm', None)
            if f:
                form = f(action=url_for(develop_app_conf)+'?module=%s' % module, method='post')
                if request.method == 'POST':
                    ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
                    default_ini = Ini(os.path.join(app_path, 'settings.ini'))
                    r = form.validate(request.POST)
                    if r:
                        flag = form_to_ini(form, ini, default_ini)
                        if flag:
                            message = '<div class="note">Changes have been saved!</div>'
                            ini.save()
                        else:
                            message = '<div class="important">There are no changes.</div>'
                    else:
                        message = '<div class="warning">There are some errors.</div>'
                elif request.method == 'GET':
                    ini = Ini()
                    ini_file = os.path.join(app_path, 'settings.ini')
                    if os.path.exists(ini_file):
                        ini.read(ini_file)
                    ini.read(os.path.join(application.apps_dir, 'settings.ini'))
                    ini_to_form(form, ini)
        
        except ImportError, e:
            log.exception(e)
开发者ID:datakungfu,项目名称:uliweb,代码行数:35,代码来源:views.py

示例8: handle

    def handle(self, options, global_options, *args):
        from uliweb import orm
        
        if args:
            message = """This command will delete all data of [%s] before loading, 
are you sure to load data""" % ','.join(args)
        else:
            message = """This command will delete whole database before loading, 
are you sure to load data"""

        get_answer(message)

        if not os.path.exists(options.dir):
            os.makedirs(options.dir)
        
        engine = get_engine(global_options.apps_dir)
        con = orm.get_connection(engine)

        for name, t in get_tables(global_options.apps_dir, args, engine=engine, settings_file=global_options.settings, local_settings_file=global_options.local_settings).items():
            if global_options.verbose:
                print 'Loading %s...' % name
            try:
                con.begin()
                filename = os.path.join(options.dir, name+'.txt')
                if options.text:
                    format = 'txt'
                else:
                    format = None
                load_table(t, filename, con, delimiter=options.delimiter, 
                    format=format, encoding=options.encoding)
                con.commit()
            except:
                log.exception("There are something wrong when loading table [%s]" % name)
                con.rollback()
开发者ID:zhangming0305,项目名称:uliweb,代码行数:34,代码来源:commands.py

示例9: get_object

def get_object(model, tablename, id):
    """
    Get cached object from redis
    
    if id is None then return None:
    """
    from uliweb.utils.common import log
    
    if not id:
        return 
    
    if not check_enable():
        return
    
    redis = get_redis()
    if not redis: return
    _id = get_id(model.get_engine_name(), tablename, id)
    try:
        if redis.exists(_id):
            v = redis.hgetall(_id)
            o = model.load(v)
            log.debug("objcache:get:id="+_id)
            return o
    except Exception, e:
        log.exception(e)
开发者ID:08haozi,项目名称:uliweb,代码行数:25,代码来源:__init__.py

示例10: deletefile

def deletefile(f_id):
    from uliweb.utils.common import log
    
    fileserving = AttachmentsFileServing()
    
    Attachment = functions.get_model('generic_attachment')
    Tables = functions.get_model('tables')
    
    obj = Attachment.get(int(f_id))
    if obj:
        
        #get tablename
        tablename = Tables.get(obj.table_id)
        check_func = settings.Generic_Attachment_Download_Checking.get(tablename)
        if check_func:
            enable = check_func(obj.content_object, request.user, 'delete')
        else:
            enable = True
        
        if enable:
            filename = obj.filepath
            obj.delete()
            try:
                fileserving.delete_filename(filename)
            except Exception as e:
                log.exception(e)
        else:
            raise Forbidden("You have no permission to delete the file.")
        
    return json({'success':True})
开发者ID:chyhutu,项目名称:plugs,代码行数:30,代码来源:views.py

示例11: internal_error

 def internal_error(self, e):
     tmp_file = template.get_templatefile('500'+settings.GLOBAL.TEMPLATE_SUFFIX, self.template_dirs)
     if tmp_file:
         response = self.render(tmp_file, {'url':local.request.path}, status=500)
     else:
         response = e
     log.exception(e)
     return response
开发者ID:lssebastian,项目名称:uliweb,代码行数:8,代码来源:SimpleFrame.py

示例12: internal_error

 def internal_error(self, e):
     tmp_file = self.template_loader.resolve_path('500'+settings.GLOBAL.TEMPLATE_SUFFIX)
     if tmp_file:
         response = self.render(tmp_file, {'url':local.request.path}, status=500)
     else:
         response = InternalServerError()
     log.exception(e)
     return response
开发者ID:bluesky4485,项目名称:uliweb,代码行数:8,代码来源:SimpleFrame.py

示例13: install_apps

 def install_apps(self):
     for p in self.apps:
         try:
             myimport(p)
         except ImportError, e:
             pass
         except BaseException, e:
             log.exception(e)
开发者ID:lssebastian,项目名称:uliweb,代码行数:8,代码来源:SimpleFrame.py

示例14: f

 def f():
     _id = get_id(model.get_engine_name(), tablename, instance.id)
     redis = get_redis()
     if not redis: return
     
     try:
         redis.delete(_id)
         log.debug("objcache:post_delete:id="+_id)
     except Exception, e:
         log.exception(e)
开发者ID:08haozi,项目名称:uliweb,代码行数:10,代码来源:__init__.py

示例15: get_tables

def get_tables(apps_dir, apps=None, engine=None, import_models=False, tables=None,
    settings_file='settings.ini', local_settings_file='local_settings.ini'):
    from uliweb.core.SimpleFrame import get_apps, get_app_dir
    from uliweb import orm
    from StringIO import StringIO
    
    engine = orm.engine_manager[engine]
    e = engine.options['connection_string']
    engine_name = e[:e.find('://')+3]
    
    buf = StringIO()
    
    if import_models:
        apps = get_apps(apps_dir, settings_file=settings_file, local_settings_file=local_settings_file)
        if apps:
            apps_list = apps
        else:
            apps_list = apps[:]
        models = []
        for p in apps_list:
            if p not in apps:
                log.error('Error: Appname %s is not a valid app' % p)
                continue
            if not is_pyfile_exist(get_app_dir(p), 'models'):
                continue
            m = '%s.models' % p
            try:
                mod = __import__(m, {}, {}, [''])
                models.append(mod)
            except ImportError:
                log.exception("There are something wrong when importing module [%s]" % m)
        
    else:
        old_models = orm.__models__.keys()
        try:
            for tablename, m in orm.__models__.items():
                orm.get_model(tablename)
        except:
            print "Problems to models like:", list(set(old_models) ^ set(orm.__models__.keys()))
            raise
            
    if apps:
        t = {}
        for tablename, m in engine.metadata.tables.items():
            if hasattr(m, '__appname__') and m.__appname__ in apps:
                t[tablename] = engine.metadata.tables[tablename]
    elif tables:
        t = {}
        for tablename, m in engine.metadata.tables.items():
            if tablename in tables:
                t[tablename] = engine.metadata.tables[tablename]
    else:
        t = engine.metadata.tables
                
    return t
开发者ID:tangjn,项目名称:uliweb,代码行数:55,代码来源:commands.py


注:本文中的uliweb.utils.common.log.exception函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。