本文整理汇总了Python中database.DBSession.delete方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.delete方法的具体用法?Python DBSession.delete怎么用?Python DBSession.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.DBSession
的用法示例。
在下文中一共展示了DBSession.delete方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_all_installations_for_host
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import delete [as 别名]
def delete_all_installations_for_host(hostname, status=None):
if not can_delete_install(current_user):
abort(401)
db_session = DBSession()
host = get_host(db_session, hostname)
if host is None:
abort(404)
try:
install_jobs = db_session.query(InstallJob).filter(
InstallJob.host_id == host.id, InstallJob.status == status).all()
if not install_jobs:
return jsonify(status="No record fits the delete criteria.")
for install_job in install_jobs:
db_session.delete(install_job)
if status == JobStatus.FAILED:
delete_install_job_dependencies(db_session, install_job.id)
db_session.commit()
return jsonify({'status': 'OK'})
except:
logger.exception('delete_install_job() hit exception')
return jsonify({'status': 'Failed: check system logs for details'})
示例2: get_smu_info_from_cco
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import delete [as 别名]
def get_smu_info_from_cco(self, platform, release):
save_to_db = True
db_session = DBSession()
platform_release = platform + '_' + release
try:
self.smu_meta = SMUMeta(platform_release=platform_release)
# Load data from the SMU XML file
self.load()
# This can happen if the given platform and release is not valid.
# The load() method calls get_smu_info_from_db and failed.
if not self.is_valid:
logger.error('get_smu_info_from_cco() hit exception, platform_release=' + platform_release)
return
db_smu_meta = db_session.query(SMUMeta).filter(SMUMeta.platform_release == platform_release).first()
if db_smu_meta:
if db_smu_meta.created_time == self.smu_meta.created_time:
save_to_db = False
else:
# Delete the existing smu_meta and smu_info for this platform and release
db_session.delete(db_smu_meta)
db_session.commit()
if save_to_db:
db_session.add(self.smu_meta)
else:
db_smu_meta.retrieval_time = datetime.datetime.utcnow()
db_session.commit()
except Exception:
logger.exception('get_smu_info_from_cco() hit exception, platform_release=' + platform_release)
示例3: delete_custom_command_profile
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import delete [as 别名]
def delete_custom_command_profile(profile_name):
db_session = DBSession()
command_profile = get_command_profile(db_session, profile_name)
if command_profile is None:
abort(404)
db_session.delete(command_profile)
db_session.commit()
return jsonify({'status': 'OK'})
示例4: user_delete
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import delete [as 别名]
def user_delete(username):
db_session = DBSession()
user = get_user(db_session, username)
if user is None:
abort(404)
db_session.delete(user)
db_session.commit()
return jsonify({'status': 'OK'})
示例5: software_profile_delete
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import delete [as 别名]
def software_profile_delete(profile_name):
# if not can_delete(current_user):
# abort(401)
db_session = DBSession()
software_profile = get_software_profile(db_session, profile_name)
if software_profile is None:
abort(404)
db_session.delete(software_profile)
db_session.commit()
return jsonify({'status': 'OK'})
示例6: delete_all_installations
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import delete [as 别名]
def delete_all_installations(status=None):
db_session = DBSession()
try:
install_jobs = db_session.query(InstallJob).filter(InstallJob.status == status)
for install_job in install_jobs:
db_session.delete(install_job)
if status == JobStatus.FAILED:
delete_install_job_dependencies(db_session, install_job.id)
db_session.commit()
return jsonify({'status': 'OK'})
except:
logger.exception('delete_install_job() hit exception')
return jsonify({'status': 'Failed: check system logs for details'})
示例7: get_smu_info_from_cco
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import delete [as 别名]
def get_smu_info_from_cco(self, platform, release):
same_as_db = False
db_session = DBSession()
platform_release = platform + '_' + release
try:
self.smu_meta = SMUMeta(platform_release=platform_release)
# Load data from the SMU XML file
self.load()
# This can happen if the given platform and release is not valid.
# The load method calls get_smu_info_from_db and failed.
if self.smu_meta is None:
return
db_smu_meta = db_session.query(SMUMeta).filter(SMUMeta.platform_release == platform + '_' + release).first()
if db_smu_meta is not None:
if db_smu_meta.created_time == self.smu_meta.created_time:
same_as_db = True
else:
# Delete the existing smu_meta and smu_info for this platform and release
db_session.delete(db_smu_meta)
if not same_as_db:
db_session.add(self.smu_meta)
else:
db_smu_meta.retrieval_time = datetime.datetime.utcnow()
# Use Flush to detect concurrent saving condition. It is
# possible that another process may perform the same save.
# If this happens, Duplicate Key may result.
db_session.flush()
db_session.commit()
except IntegrityError:
db_session.rollback()
except Exception:
db_session.rollback()
logger.exception('get_smu_info_from_cco() hit exception')
示例8: api_delete_install_job
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import delete [as 别名]
def api_delete_install_job(id):
if not can_delete_install(current_user):
abort(401)
db_session = DBSession()
install_job = db_session.query(InstallJob).filter(InstallJob.id == id).first()
if install_job is None:
abort(404)
try:
# Install jobs that are in progress cannot be deleted.
if install_job.status is None or install_job.status == JobStatus.FAILED:
db_session.delete(install_job)
delete_install_job_dependencies(db_session, install_job.id)
db_session.commit()
return jsonify({'status': 'OK'})
except:
logger.exception('delete_install_job() hit exception')
return jsonify({'status': 'Failed: check system logs for details'})
示例9: __init__
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import delete [as 别名]
def __init__(self, platform, release):
self.platform = platform
self.release = release
self.smu_meta = None
self.smus = {}
self.service_packs = {}
self.in_transit_smus = {}
db_session = DBSession()
self.smu_meta = db_session.query(SMUMeta).filter(SMUMeta.platform_release == platform + '_' + release).first()
if self.smu_meta == None:
self.get_smu_info_from_cco(db_session, platform + '_' + release)
else:
downloaded_date = self.smu_meta.downloaded_time.split()[0]
current_date = time.strftime('%m/%d/%Y')
if downloaded_date != current_date:
db_session.delete(self.smu_meta)
self.get_smu_info_from_cco(db_session, platform + '_' + release)
else:
self.smus = self.get_smus_by_package_type(self.smu_meta.smu_info, PackageType.SMU)
self.service_packs = self.get_smus_by_package_type(self.smu_meta.smu_info, PackageType.SERVICE_PACK)
self.in_transit_smus = self.get_smus_by_package_type(self.smu_meta.smu_info, PackageType.SMU_IN_TRANSIT)