本文整理汇总了Python中maraschino.database.db_session.delete函数的典型用法代码示例。如果您正苦于以下问题:Python delete函数的具体用法?Python delete怎么用?Python delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_module
def remove_module(name):
"""Remove module from the page"""
module = Module.query.filter(Module.name == name).first()
db_session.delete(module)
db_session.commit()
return jsonify({ 'status': 'success' })
示例2: removeStaleServers
def removeStaleServers(current):
servers = PlexServer.query.order_by(PlexServer.id).all()
for server in servers:
if server.machineIdentifier not in current:
db_session.delete(server)
logger.log("Plex :: Removed %s from db as it is stale" % server, 'DEBUG')
db_session.commit()
示例3: delete_application
def delete_application(application_id):
try:
application = Application.query.filter(Application.id == application_id).first()
db_session.delete(application)
db_session.commit()
except:
return jsonify({ 'status': 'error' })
return xhr_applications()
示例4: delete_disk
def delete_disk(disk_id):
try:
disk = HardDisk.query.filter(HardDisk.id == disk_id).first()
db_session.delete(disk)
db_session.commit()
except:
return jsonify({'status': 'error'})
return xhr_diskspace()
示例5: delete_newznab
def delete_newznab(newznab_id):
try:
newznab = NewznabSite.query.filter(NewznabSite.id == newznab_id).first()
db_session.delete(newznab)
db_session.commit()
except:
return jsonify(error=True)
return xhr_search()
示例6: delete_script
def delete_script(script_id):
try:
script = Script.query.filter(Script.id == script_id).first()
db_session.delete(script)
db_session.commit()
except:
logger.log('SCRIPT_LAUNCHER :: Delete Failed', 'ERROR')
return jsonify({ 'status': 'Delete Failed' })
return xhr_script_launcher()
示例7: delete_server
def delete_server(server_id=None):
"""
Deletes a server.
"""
try:
xbmc_server = XbmcServer.query.get(server_id)
db_session.delete(xbmc_server)
db_session.commit()
return render_template('includes/servers.html',
servers = XbmcServer.query.order_by(XbmcServer.position),
)
except:
logger.log('Error deleting server ID %s' % server_id , 'WARNING')
return jsonify({ 'status': 'error' })
示例8: plex_database_upgrade_check
def plex_database_upgrade_check():
logger.log('Starting database upgrade check.', 'INFO')
from maraschino.models import XbmcServer, MediaServer
from maraschino.database import db_session
# Check for any servers in the legacy 'XbmcServer' table. If found migrate over to the new tables
servers = XbmcServer.query.order_by(XbmcServer.position)
for server in servers:
# We have servers so migrate them
logger.log("The server named '" + server.label + "' is being upgraded!", 'INFO')
newServer = MediaServer(server.label, 'XBMC', {'hostname': server.hostname, 'port': server.port,
'username': server.username, 'password': server.password, 'mac_address': server.mac_address},
server.position)
db_session.add(newServer)
db_session.delete(server)
db_session.commit()
logger.log('Finished database upgrade check', 'INFO')
示例9: delete_server
def delete_server(server_id=None):
"""
Deletes a server.
"""
try:
xbmc_server = XbmcServer.query.get(server_id)
db_session.delete(xbmc_server)
db_session.commit()
# Remove the server's cache
label = xbmc_server.label
recent_cache = [label + '_episodes', label + '_movies', label + '_albums']
try:
for entry in recent_cache:
recent_db = RecentlyAdded.query.filter(RecentlyAdded.name == entry).first()
if recent_db:
db_session.delete(recent_db)
db_session.commit()
except:
logger.log('Failed to remove servers database cache' , 'WARNING')
image_dir = os.path.join(maraschino.DATA_DIR, 'cache', 'xbmc', xbmc_server.label)
if os.path.isdir(image_dir):
import shutil
try:
shutil.rmtree(image_dir)
except:
logger.log('Failed to remove servers image cache' , 'WARNING')
return render_template('includes/servers.html',
servers = XbmcServer.query.order_by(XbmcServer.position),
)
except:
logger.log('Error deleting server ID %s' % server_id , 'WARNING')
return jsonify({ 'status': 'error' })
示例10: legacy_disk_migrate
def legacy_disk_migrate():
logger.log('DISKSPACE :: Migrating legacy disks', 'INFO')
disks_db_old = Disk.query.order_by(Disk.position)
for disk_old in disks_db_old:
disk = HardDisk(
data={
'path': disk_old.path,
'name': disk_old.path,
'group': '',
},
position=disk_old.position
)
try:
db_session.add(disk)
db_session.delete(disk_old)
db_session.commit()
except:
return jsonify({'status': 'error'})
示例11: delete_server
def delete_server(server_id=None):
"""
Deletes a server.
"""
try:
xbmc_server = XbmcServer.query.get(server_id)
db_session.delete(xbmc_server)
db_session.commit()
# Remove the server's cache
label = xbmc_server.label
recent_cache = [label + "_episodes", label + "_movies", label + "_albums"]
try:
for entry in recent_cache:
recent_db = RecentlyAdded.query.filter(RecentlyAdded.name == entry).first()
if recent_db:
db_session.delete(recent_db)
db_session.commit()
except:
logger.log("Failed to remove servers database cache", "WARNING")
image_dir = os.path.join(maraschino.DATA_DIR, "cache", "xbmc", xbmc_server.label)
if os.path.isdir(image_dir):
import shutil
try:
shutil.rmtree(image_dir)
except:
logger.log("Failed to remove servers image cache", "WARNING")
return render_template("includes/servers.html", servers=XbmcServer.query.order_by(XbmcServer.position))
except:
logger.log("Error deleting server ID %s" % server_id, "WARNING")
return jsonify({"status": "error"})