本文整理汇总了Python中bkr.server.model.Job.expired_logs方法的典型用法代码示例。如果您正苦于以下问题:Python Job.expired_logs方法的具体用法?Python Job.expired_logs怎么用?Python Job.expired_logs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Job
的用法示例。
在下文中一共展示了Job.expired_logs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpModule
# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import expired_logs [as 别名]
def setUpModule():
try:
import kerberos
except ImportError:
raise SkipTest('kerberos module not available, but log-delete requires it')
try:
import requests_kerberos
except ImportError:
raise SkipTest('requests_kerberos module not available, but log-delete requires it')
# It makes our tests simpler here if they only need to worry about deleting
# logs which they themselves have created, rather than ones which might have
# been left behind from earlier tests in the run.
for job, _ in Job.expired_logs():
job.delete()
示例2: log_delete
# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import expired_logs [as 别名]
def log_delete(print_logs=False, dry=False, limit=None):
if dry:
logger.info('Dry run only')
logger.info('Getting expired jobs')
failed = False
if not dry:
requests_session = requests.Session()
requests_session.auth = requests_kerberos.HTTPKerberosAuth(
mutual_authentication=requests_kerberos.OPTIONAL)
for job, logs in Job.expired_logs(limit):
logger.info('Deleting logs for %s', job.t_id)
try:
session.begin()
for log in logs:
if not dry:
if urlparse.urlparse(log).scheme:
response = requests_session.delete(log)
if response.status_code not in (200, 204, 404):
response.raise_for_status()
else:
try:
shutil.rmtree(log)
except OSError, e:
if e.errno == errno.ENOENT:
pass
if print_logs:
print log
if not dry:
job.delete()
session.commit()
session.close()
else:
session.close()
except Exception, e:
logger.exception('Exception while deleting logs for %s', job.t_id)
failed = True
# session needs to be open for job.t_id in the log message above
session.close()
continue
示例3: log_delete
# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import expired_logs [as 别名]
def log_delete(print_logs=False, dry=False, limit=None):
if dry:
logger.info('Dry run only')
logger.info('Getting expired jobs')
failed = False
if not dry:
requests_session = requests.Session()
log_delete_user = config.get('beaker.log_delete_user')
log_delete_password = config.get('beaker.log_delete_password')
available_auths = []
available_auth_names = []
if _kerberos_available:
available_auths.append(requests_kerberos.HTTPKerberosAuth(
mutual_authentication=requests_kerberos.DISABLED))
available_auth_names.append('Kerberos')
if log_delete_user and log_delete_password:
available_auths.append(requests.auth.HTTPDigestAuth(log_delete_user,
log_delete_password))
available_auth_names.append('HTTPDigestAuth')
requests_session.auth = MultipleAuth(available_auths)
logger.debug('Available authentication methods: %s' %
', '.join(available_auth_names))
for job, logs in Job.expired_logs(limit):
logger.info('Deleting logs for %s', job.t_id)
try:
session.begin()
for log in logs:
if not dry:
if urlparse.urlparse(log).scheme:
# We need to handle redirects ourselves, since requests
# turns DELETE into GET on 302 which we do not want.
response = requests_session.delete(log, allow_redirects=False)
redirect_limit = 10
while redirect_limit > 0 and response.status_code in (
301, 302, 303, 307):
response = requests_session.delete(
response.headers['Location'],
allow_redirects=False)
redirect_limit -= 1
if response.status_code not in (200, 204, 404):
response.raise_for_status()
else:
try:
shutil.rmtree(log)
except OSError, e:
if e.errno == errno.ENOENT:
pass
if print_logs:
print log
if not dry:
job.delete()
session.commit()
session.close()
else:
session.close()
except Exception, e:
logger.exception('Exception while deleting logs for %s', job.t_id)
failed = True
# session needs to be open for job.t_id in the log message above
session.close()
continue
示例4: setUpModule
# 需要导入模块: from bkr.server.model import Job [as 别名]
# 或者: from bkr.server.model.Job import expired_logs [as 别名]
def setUpModule():
# It makes our tests simpler here if they only need to worry about deleting
# logs which they themselves have created, rather than ones which might have
# been left behind from earlier tests in the run.
for job, _ in Job.expired_logs():
job.delete()