• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python log.exception函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: handle

    def handle(self, options, global_options, *args):
        from uliweb import orm

        if args:
            message = """This command will delete all data of [%s]-[%s] before loading, 
are you sure to load data""" % (
                options.engine,
                ",".join(args),
            )
        else:
            print "Failed! You should pass one or more tables name."
            sys.exit(1)

        ans = get_answer(message, answers="Yn", quit="q")

        path = os.path.join(options.dir, options.engine)
        if not os.path.exists(path):
            os.makedirs(path)

        engine = get_engine(options, global_options)

        tables = get_sorted_tables(
            get_tables(
                global_options.apps_dir,
                engine_name=options.engine,
                settings_file=global_options.settings,
                tables=args,
                local_settings_file=global_options.local_settings,
            )
        )
        _len = len(tables)

        for i, (name, t) in enumerate(tables):
            if global_options.verbose:
                print "[%s] Loading %s..." % (options.engine, show_table(name, t, i, _len))
            try:
                orm.Begin()
                filename = os.path.join(path, name + ".txt")
                if options.text:
                    format = "txt"
                else:
                    format = None
                load_table(
                    t,
                    filename,
                    engine,
                    delimiter=options.delimiter,
                    format=format,
                    encoding=options.encoding,
                    delete=ans == "Y",
                )
                orm.Commit()
            except:
                log.exception("There are something wrong when loading table [%s]" % name)
                orm.Rollback()
开发者ID:xuxiandi,项目名称:uliweb,代码行数:55,代码来源:commands.py


示例17: get_tables

def get_tables(apps_dir, apps=None, engine=None, import_models=False, 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 sqlalchemy import create_engine
    from StringIO import StringIO
    
    if not engine:
        engine = get_engine(apps_dir)
    
    _engine = engine[:engine.find('://')+3]
    
    buf = StringIO()
    
    con = create_engine(_engine, strategy='mock', executor=lambda s, p='': buf.write(str(s) + p))
    db = orm.get_connection(con)
    
    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:
        tables = {}
        for tablename, m in db.metadata.tables.iteritems():
            if hasattr(m, '__appname__') and m.__appname__ in apps:
                tables[tablename] = db.metadata.tables[tablename]
    else:
        tables = db.metadata.tables
                
    return tables
开发者ID:zhangming0305,项目名称:uliweb,代码行数:54,代码来源:commands.py


示例18: use

    def use(vars, env, plugin, *args, **kwargs):
        from uliweb.core.SimpleFrame import get_app_dir
        from uliweb import application as app, settings
        from uliweb.utils.common import is_pyfile_exist

        if plugin in UseNode.__saved_template_plugins_modules__:
            mod = UseNode.__saved_template_plugins_modules__[plugin]
        else:
            #add settings support, only support simple situation
            #so for complex cases you should still write module
            #format just like:
            #
            #[TEMPLATE_USE]
            #name = {
            #   'toplinks':[
            #       'myapp/jquery.myapp.{version}.min.js',
            #   ], 
            #   'depends':[xxxx], 
            #   'config':{'version':'UI_CONFIG/test'},
            #   'default':{'version':'1.2.0'},
            #}
            #
            mod = None
            c = settings.get_var('TEMPLATE_USE/'+plugin)
            if c:
                config = c.pop('config', {})
                default = c.pop('default', {})
                #evaluate config value
                config = dict([(k, settings.get_var(v, default.get(k, ''))) for k, v in config.items()])
                #merge passed arguments
                config.update(kwargs)
                for t in ['toplinks', 'bottomlinks']:
                    if t in c:
                        c[t] = [x.format(**config) for x in c[t]]
                mod = c
            else:
                for p in app.apps:
                    if not is_pyfile_exist(os.path.join(get_app_dir(p), 'template_plugins'), plugin):
                        continue
                    module = '.'.join([p, 'template_plugins', plugin])
                    try:
                        mod = __import__(module, {}, {}, [''])
                    except ImportError, e:
                        log.exception(e)
                        mod = None
            if mod:
                UseNode.__saved_template_plugins_modules__[plugin] = mod
            else:
                log.error("Can't find the [%s] template plugin, please check if you've installed special app already" % plugin)
                if settings.get_var('TEMPLATE/RAISE_USE_EXCEPTION'):
                    raise UseModuleNotFound("Can't find the %s template plugin, check if you've installed special app already" % plugin)
开发者ID:biluo1989,项目名称:uliweb,代码行数:51,代码来源:tags.py


示例19: handle

    def handle(self, options, global_options, *args):
        from uliweb import orm
        
        if args:
            message = """This command will delete all data of [%s]-[%s] before loading, 
are you sure to load data""" % (options.engine, ','.join(args))
        else:
            print "Failed! You should pass one or more tables name."
            sys.exit(1)

        ans = get_answer(message, answers='Yn', quit='q')

        path = os.path.join(options.dir, options.engine)
        if not os.path.exists(path):
            os.makedirs(path)
        
        engine = get_engine(options, global_options)

        tables = get_sorted_tables(get_tables(global_options.apps_dir, 
            engine_name=options.engine, 
            settings_file=global_options.settings, tables=args,
            local_settings_file=global_options.local_settings))
        _len = len(tables)
        
        for i, (name, t) in enumerate(tables):
            if t.__mapping_only__:
                if global_options.verbose:
                    msg = 'SKIPPED(Mapping Table)'
                    print '[%s] Loading %s...%s' % (options.engine, show_table(name, t, i, _len), msg)
                continue
            if global_options.verbose:
                print '[%s] Loading %s...' % (options.engine, show_table(name, t, i, _len)),
            try:
                orm.Begin()
                filename = os.path.join(path, name+'.txt')
                if options.text:
                    format = 'txt'
                else:
                    format = None
                t = load_table(t, filename, engine, delimiter=options.delimiter, 
                    format=format, encoding=options.encoding, delete=ans=='Y', 
                    bulk=int(options.bulk), engine_name=engine.engine_name)
                orm.Commit()
                if global_options.verbose:
                    print t
            except:
                log.exception("There are something wrong when loading table [%s]" % name)
                orm.Rollback()
开发者ID:chenke91,项目名称:uliweb,代码行数:48,代码来源:commands.py


示例20: form_validate

    def form_validate(self, data):
        from uliweb.utils.common import import_attr, log
        from uliweb.orm import Model

        errors = {}

        if data['basemodel']:
            try:
                m = functions.get_model(data['basemodel'])
                if not (isinstance(m, type) and issubclass(m, Model)):
                    errors['basemodel'] = _("Object is not a subclass of Model")
            except Exception as e:
                log.exception(e)
                errors['basemodel'] = _("Model can't be imported")

        return errors    
开发者ID:naomhan,项目名称:uliweb-peafowl,代码行数:16,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pkg.resource_filename函数代码示例发布时间:2022-05-27
下一篇:
Python log.error函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap