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


Python LOG.exception方法代码示例

本文整理汇总了Python中scalrpy.LOG.exception方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.exception方法的具体用法?Python LOG.exception怎么用?Python LOG.exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scalrpy.LOG的用法示例。


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

示例1: do_iteration

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
 def do_iteration(self):
     for envs in self.analytics.load_envs():
         msg = "Processing environments: {}".format([env['id'] for env in envs])
         LOG.debug(msg)
         try:
             self.analytics.load_env_credentials(envs)
             unique = {}
             for env in envs:
                 try:
                     credentials = self.analytics.get_credentials([env])
                     for cred in credentials:
                         if cred.platform == 'ec2' and env.get('ec2.detailed_billing.enabled', '0') == '1':
                             continue
                         unique.setdefault(cred.unique, {'envs_ids': [], 'cred': cred})
                         unique[cred.unique]['envs_ids'].append(env['id'])
                 except:
                     msg = 'Processing environment: {} failed'.format(env['id'])
                     LOG.exception(msg)
             for data in unique.values():
                 while len(self.pool) > self.config['pool_size'] * 5 / 10:
                     gevent.sleep(0.1)
                 self.pool.apply_async(process_credential,
                                       args=(data['cred'],),
                                       kwds={'envs_ids': data['envs_ids']})
                 gevent.sleep(0)  # force switch
         except:
             msg = 'Processing environments: {} failed'.format([env['id'] for env in envs])
             LOG.exception(msg)
     self.pool.join()
开发者ID:bbnathan,项目名称:scalr,代码行数:31,代码来源:analytics_poller.py

示例2: __call__

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
 def __call__(self):
     self.change_permissions()
     while True:
         try:
             self.iteration_timestamp = time.time()
             self.before_iteration()
             g = self._do_iteration()
             try:
                 g.get(timeout=self.iteration_timeout)
             except:
                 self.on_iteration_error()
                 raise
             finally:
                 if not g.ready():
                     g.kill()
                 self.after_iteration()
             iteration_time = time.time() - self.iteration_timestamp
             msg = 'End iteration: {0:.1f} seconds'.format(iteration_time)
             LOG.debug(msg)
         except:
             LOG.exception('Iteration failed')
             time.sleep(self.error_sleep)
         finally:
             if self.config['interval']:
                 next_iteration_time = self.iteration_timestamp + self.config['interval']
                 time.sleep(next_iteration_time - time.time())
开发者ID:sacredwebsite,项目名称:scalr,代码行数:28,代码来源:application.py

示例3: _handle_exception

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
def _handle_exception(e, msg):
    if isinstance(e, boto.exception.EC2ResponseError) and e.status in (401, 403):
        LOG.warning(msg)
    elif isinstance(
        e,
        (
            libcloud.common.types.InvalidCredsError,
            libcloud.common.types.LibcloudError,
            libcloud.common.types.MalformedResponseError,
            libcloud.common.exceptions.BaseHTTPError,
            oauth2client.client.AccessTokenRefreshError,
            gevent.timeout.Timeout,
            socket.timeout,
            socket.gaierror,
        ),
    ):
        LOG.warning(msg)
    elif isinstance(e, socket.error):
        LOG.warning(msg)
    elif isinstance(e, googleapiclient.errors.HttpError) and e.resp["status"] in ("403",):
        LOG.warning(msg)
    elif isinstance(e, ssl.SSLError):
        LOG.warning(msg)
    elif isinstance(e, greenlet.GreenletExit):
        pass
    elif "userDisabled" in str(e):
        LOG.warning(msg)
    elif isinstance(e, exceptions.MissingCredentialsError):
        LOG.debug(msg)
    else:
        LOG.exception(msg)
开发者ID:scalr,项目名称:scalr,代码行数:33,代码来源:analytics_poller.py

示例4: do_iteration

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
 def do_iteration(self):
     for envs in self.analytics.load_envs():
         msg = "Processing environments: {}".format([env["id"] for env in envs])
         LOG.debug(msg)
         try:
             self.analytics.load_env_credentials(envs)
             unique = {}
             for env in envs:
                 try:
                     credentials = self.analytics.get_credentials([env])
                     for cred in credentials:
                         if cred.platform == "ec2" and env.get("ec2.detailed_billing.enabled", "0") == "1":
                             continue
                         unique.setdefault(cred.unique, {"envs_ids": [], "cred": cred})
                         unique[cred.unique]["envs_ids"].append(env["id"])
                 except:
                     msg = "Processing environment: {} failed".format(env["id"])
                     LOG.exception(msg)
             for data in unique.values():
                 while len(self.pool) > self.config["pool_size"] * 5 / 10:
                     gevent.sleep(0.1)
                 self.pool.apply_async(process_credential, args=(data["cred"],), kwds={"envs_ids": data["envs_ids"]})
                 gevent.sleep(0)  # force switch
         except:
             msg = "Processing environments: {} failed".format([env["id"] for env in envs])
             LOG.exception(msg)
     self.pool.join()
开发者ID:scalr,项目名称:scalr,代码行数:29,代码来源:analytics_poller.py

示例5: process_aws_billing

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
    def process_aws_billing(self):
        if self.args['--recalculate']:
            return

        dtime_from, dtime_to = self.get_aws_billing_interval()
        msg = 'AWS billing interval: {0} - {1}'
        msg = msg.format(dtime_from, dtime_to)
        LOG.debug(msg)

        with self._lock:
            if not self.aws_billing_dtime_from:
                self.aws_billing_dtime_from = dtime_from
            else:
                self.aws_billing_dtime_from = min(self.aws_billing_dtime_from, dtime_from)

        for envs in self.analytics.load_envs():
            unique = {}
            for env in envs:
                if env.get('ec2.detailed_billing.enabled', '0') != '1':
                    continue
                bucket_name = env['ec2.detailed_billing.bucket']
                creds = self.analytics.get_creds([env])
                cred = next(cred for cred in creds if cred.platform == 'ec2')
                unique.setdefault(cred.unique,
                                  {'envs_ids': [], 'cred': cred, 'bucket_name': bucket_name})
                unique[cred.unique]['envs_ids'].append(env['id'])

            for data in unique.values():
                while len(self.pool) > self.config['pool_size'] * 5 / 10:
                    gevent.sleep(0.1)
                self.pool.apply_async(self.process_aws_account, args=(data, dtime_from, dtime_to))

        self.pool.join()

        if not self.aws_billing_dtime_from:
            return

        dtime_from = self.aws_billing_dtime_from

        if self.config['dtime_to']:
            dtime_to = self.config['dtime_to']
        else:
            dtime_hour_ago = datetime.datetime.utcnow() - datetime.timedelta(hours=1)
            dtime_to = dtime_hour_ago.replace(minute=59, second=59, microsecond=999999)

        # fill farm_usage_d
        dtime_cur = dtime_from
        while dtime_cur <= dtime_to:
            date, hour = dtime_cur.date(), dtime_cur.hour
            try:
                self.analytics.fill_farm_usage_d(date, hour)
            except:
                msg = 'Unable to fill farm_usage_d table for date {0}, hour {1}'.format(date, hour)
                LOG.exception(msg)
            dtime_cur += datetime.timedelta(hours=1)
开发者ID:nguyensdeveloper,项目名称:scalr,代码行数:57,代码来源:analytics_processing.py

示例6: main

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
def main():
    app = AnalyticsProcessing()
    try:
        app.load_config()
        app.configure()
        app.run()
    except exceptions.AlreadyRunningError:
        LOG.info(helper.exc_info())
    except (SystemExit, KeyboardInterrupt):
        pass
    except:
        LOG.exception('Oops')
开发者ID:afrank,项目名称:scalr,代码行数:14,代码来源:analytics_processing.py

示例7: main

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
def main():
    global app
    app = LoadStatistics()
    try:
        app.load_config()
        app.configure()
        app.run()
    except exceptions.AlreadyRunningError:
        LOG.info(helper.exc_info(where=False))
    except (SystemExit, KeyboardInterrupt):
        pass
    except:
        LOG.exception('Oops')
开发者ID:afrank,项目名称:scalr,代码行数:15,代码来源:load_statistics.py

示例8: _do_iteration

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
 def _do_iteration(self):
     try:
         return self.do_iteration()
     except SystemExit:
         if sys.exc_info()[1].args[0] != 0:
             raise
     except exceptions.QuitError:
         return
     except KeyboardInterrupt:
         raise
     except exceptions.NothingToDoError:
         time.sleep(self.nothing_to_do_sleep)
     except:
         if logging.getLevelName(self.args['--verbosity']) < logging.ERROR:
             LOG.exception(helper.exc_info(where=False))
         raise
开发者ID:sacredwebsite,项目名称:scalr,代码行数:18,代码来源:application.py

示例9: process_aws_account

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
    def process_aws_account(self, data, dtime_from, dtime_to):
        try:
            # Iterate over months from dtime_from to dtime_to
            dtime = dtime_from
            while dtime.month <= dtime_to.month:
                try:
                    csv_zip_file = self.download_aws_billing_file(data['cred'],
                                                                  data['bucket_name'],
                                                                  date=dtime.date())
                    if csv_zip_file is None:
                        continue

                    with zipfile.ZipFile(csv_zip_file, 'r') as f:
                        f.extract(f.infolist()[0], self.tmp_dir)
                    csv_file = os.path.join(self.tmp_dir,
                                            os.path.basename(csv_zip_file.strip('.zip')))

                    for rows in self.csv_reader(csv_file, dtime_from=dtime):
                        records = self.get_aws_records(rows)
                        records = [rec for rec in records if int(rec['env_id']) in data['envs_ids']]
                        if records:
                            with self._lock:
                                min_records_dtime = min([record['dtime'] for record in records])
                                if self.aws_billing_dtime_from:
                                    self.aws_billing_dtime_from = min(self.aws_billing_dtime_from,
                                                                      min_records_dtime)
                                else:
                                    self.aws_billing_dtime_from = min_records_dtime
                        for record in records:
                            self.pool.wait()
                            if self.args['--recalculate']:
                                self.pool.apply_async(self.analytics.update_record, (record,))
                            else:
                                self.pool.apply_async(self.analytics.insert_record, (record,))
                            gevent.sleep(0)  # force switch
                except:
                    msg = 'AWS billing for environments {0}, month {1} failed'
                    msg = msg.format(data['envs_ids'], dtime.month)
                    LOG.exception(msg)
                finally:
                    dtime = helper.next_month(dtime)
        except:
            msg = 'AWS billing for environments {0} failed'
            msg = msg.format(data['envs_ids'])
            LOG.exception(msg)
开发者ID:sacredwebsite,项目名称:scalr,代码行数:47,代码来源:analytics_processing.py

示例10: do_iteration

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
    def do_iteration(self):
        try:
            self.process_poller_billing()
        except:
            msg = 'Unable to process poller_sessions table, reason: {0}'
            msg = msg.format(helper.exc_info(where=False))
            LOG.exception(msg)

        try:
            self.process_aws_billing()
        except:
            msg = 'Unable to process AWS billing information, reason: {0}'
            msg = msg.format(helper.exc_info(where=False))
            LOG.exception(msg)


        if self.args['--recalculate']:
            sys.exit(0)
开发者ID:sacredwebsite,项目名称:scalr,代码行数:20,代码来源:analytics_processing.py

示例11: get_szr_ver_from_repo

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
    def get_szr_ver_from_repo(self, devel_branch=None, force=False):
        out = {}

        if devel_branch:
            if "devel_repos" not in self.scalr_config["scalarizr_update"]:
                return out
            if not force:
                try:
                    return self.get_szr_ver_from_repo.im_func.devel_cache[devel_branch]
                except AttributeError:
                    self.get_szr_ver_from_repo.im_func.devel_cache = {}
                except KeyError:
                    pass
            norm_branch = devel_branch.replace("/", "-").replace("_", "-")
            repos = self.scalr_config["scalarizr_update"]["devel_repos"]
        else:
            if not force:
                try:
                    return self.get_szr_ver_from_repo.im_func.cache
                except AttributeError:
                    pass
            norm_branch = None
            repos = self.scalr_config["scalarizr_update"]["repos"]

        for repo_type, repo in repos.iteritems():
            for k, func in {
                "deb": self.ver_from_deb_repo,
                "rpm": self.ver_from_rpm_repo,
                "win": self.ver_from_win_repo,
            }.iteritems():
                try:
                    data = func(repo, branch=norm_branch)
                    if data:
                        out.update(data)
                        out.setdefault(repo_type, {})[k] = data.values()[0]
                except:
                    msg = "{0} repository {1} failed".format(k, repo_type)
                    LOG.exception(msg)

        if devel_branch:
            self.get_szr_ver_from_repo.im_func.devel_cache[devel_branch] = out
        else:
            self.get_szr_ver_from_repo.im_func.cache = out
        return out
开发者ID:complues,项目名称:scalr,代码行数:46,代码来源:szr_upd_service.py

示例12: get_szr_ver_from_repo

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
    def get_szr_ver_from_repo(self, devel_branch=None, force=False):
        out = {}

        if devel_branch:
            if 'devel_repos' not in self.scalr_config['scalarizr_update']:
                return out
            if not force:
                try:
                    return self.get_szr_ver_from_repo.im_func.devel_cache[devel_branch]
                except AttributeError:
                    self.get_szr_ver_from_repo.im_func.devel_cache = {}
                except KeyError:
                    pass
            norm_branch = devel_branch.replace('/', '-').replace('_', '-')
            repos = self.scalr_config['scalarizr_update']['devel_repos']
        else:
            if not force:
                try:
                    return self.get_szr_ver_from_repo.im_func.cache
                except AttributeError:
                    pass
            norm_branch = None
            repos = self.scalr_config['scalarizr_update']['repos']

        for repo_type, repo in repos.iteritems():
            for k, func in {
                    'deb': self.ver_from_deb_repo,
                    'rpm': self.ver_from_rpm_repo,
                    'win': self.ver_from_win_repo}.iteritems():
                try:
                    data = func(repo, branch=norm_branch)
                    if data:
                        out.update(data)
                        out.setdefault(repo_type, {})[k] = data.values()[0]
                except:
                    msg = '{0} repository {1} failed'.format(k, repo_type)
                    LOG.exception(msg)

        if devel_branch:
            self.get_szr_ver_from_repo.im_func.devel_cache[devel_branch] = out
        else:
            self.get_szr_ver_from_repo.im_func.cache = out
        return out
开发者ID:sacredwebsite,项目名称:scalr,代码行数:45,代码来源:szr_upd_service.py

示例13: run

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
    def run(self):
        try:
            self.configure()

            t = self._serve_forever()
            while not t.is_alive():
                time.sleep(0.5)

            # wait before change permissions to allow cherrypy read certificates
            time.sleep(2)

            # change permissions
            if self.config['group']:
                helper.set_gid(self.config['group'])
            if self.config['user']:
                helper.set_uid(self.config['user'])

            LOG.info('Plotter started')
            t.join()
        except:
            LOG.exception(helper.exc_info())
开发者ID:afrank,项目名称:scalr,代码行数:23,代码来源:load_statistics.py

示例14: _handle_exception

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
def _handle_exception(e, msg):
    if isinstance(e, boto.exception.EC2ResponseError) and e.status in (401, 403):
        LOG.warning(msg)
    elif isinstance(e, (libcloud.common.types.InvalidCredsError,
                        libcloud.common.types.LibcloudError,
                        libcloud.common.types.MalformedResponseError,
                        oauth2client.client.AccessTokenRefreshError,
                        gevent.timeout.Timeout,
                        socket.timeout,
                        socket.gaierror)):
        LOG.warning(msg)
    elif isinstance(e, socket.error) and e.errno in (110, 111, 113):
        LOG.warning(msg)
    elif isinstance(e, googleapiclient.errors.HttpError) and e.resp['status'] in ('403'):
        LOG.warning(msg)
    elif isinstance(e, ssl.SSLError):
        LOG.warning(msg)
    elif isinstance(e, greenlet.GreenletExit):
        pass
    elif 'userDisabled' in str(e):
        LOG.warning(msg)
    else:
        LOG.exception(msg)
开发者ID:sacredwebsite,项目名称:scalr,代码行数:25,代码来源:analytics_poller.py

示例15: wrapper

# 需要导入模块: from scalrpy import LOG [as 别名]
# 或者: from scalrpy.LOG import exception [as 别名]
 def wrapper(*args, **kwds):
     try:
         return f(*args, **kwds)
     except:
         LOG.exception('Exception')
         raise
开发者ID:bbnathan,项目名称:scalr,代码行数:8,代码来源:helper.py


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