mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-22 14:13:40 -07:00
Fix mobile_app.py
This commit is contained in:
parent
de09c9f481
commit
eddcc7f566
1 changed files with 12 additions and 12 deletions
|
@ -67,17 +67,17 @@ def get_mobile_devices(device_id=None, device_token=None):
|
|||
args = []
|
||||
|
||||
if device_id or device_token:
|
||||
where = 'WHERE '
|
||||
where = "WHERE "
|
||||
if device_id:
|
||||
where_id += 'device_id = ?'
|
||||
where_id += "device_id = ?"
|
||||
args.append(device_id)
|
||||
if device_token:
|
||||
where_token = 'device_token = ?'
|
||||
where_token = "device_token = ?"
|
||||
args.append(device_token)
|
||||
where += ' AND '.join([w for w in [where_id, where_token] if w])
|
||||
where += " AND ".join([w for w in [where_id, where_token] if w])
|
||||
|
||||
db = database.MonitorDatabase()
|
||||
result = db.select('SELECT * FROM mobile_devices %s' % where, args=args)
|
||||
result = db.select("SELECT * FROM mobile_devices %s" % where, args=args)
|
||||
|
||||
return result
|
||||
|
||||
|
@ -128,7 +128,7 @@ def get_mobile_device_config(mobile_device_id=None):
|
|||
return None
|
||||
|
||||
db = database.MonitorDatabase()
|
||||
result = db.select_single('SELECT * FROM mobile_devices WHERE id = ?',
|
||||
result = db.select_single("SELECT * FROM mobile_devices WHERE id = ?",
|
||||
args=[mobile_device_id])
|
||||
|
||||
if result['onesignal_id'] == _ONESIGNAL_DISABLED:
|
||||
|
@ -163,11 +163,11 @@ def delete_mobile_device(mobile_device_id=None, device_id=None):
|
|||
|
||||
if mobile_device_id:
|
||||
logger.debug("Tautulli MobileApp :: Deleting mobile_device_id %s from the database." % mobile_device_id)
|
||||
result = db.action('DELETE FROM mobile_devices WHERE id = ?', args=[mobile_device_id])
|
||||
result = db.action("DELETE FROM mobile_devices WHERE id = ?", args=[mobile_device_id])
|
||||
return True
|
||||
elif device_id:
|
||||
logger.debug("Tautulli MobileApp :: Deleting device_id %s from the database." % device_id)
|
||||
result = db.action('DELETE FROM mobile_devices WHERE device_id = ?', args=[device_id])
|
||||
result = db.action("DELETE FROM mobile_devices WHERE device_id = ?", args=[device_id])
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -179,9 +179,9 @@ def set_official(device_id, onesignal_id):
|
|||
platform = 'android' if official > 0 else None
|
||||
|
||||
try:
|
||||
result = db.action('UPDATE mobile_devices '
|
||||
'SET official = ?, platform = coalesce(platform, ?) '
|
||||
'WHERE device_id = ?',
|
||||
result = db.action("UPDATE mobile_devices "
|
||||
"SET official = ?, platform = coalesce(platform, ?) "
|
||||
"WHERE device_id = ?",
|
||||
args=[official, platform, device_id])
|
||||
except Exception as e:
|
||||
logger.warn("Tautulli MobileApp :: Failed to set official flag for device: %s." % e)
|
||||
|
@ -193,7 +193,7 @@ def set_last_seen(device_token=None):
|
|||
last_seen = helpers.timestamp()
|
||||
|
||||
try:
|
||||
result = db.action('UPDATE mobile_devices SET last_seen = ? WHERE device_token = ?',
|
||||
result = db.action("UPDATE mobile_devices SET last_seen = ? WHERE device_token = ?",
|
||||
args=[last_seen, device_token])
|
||||
except Exception as e:
|
||||
logger.warn("Tautulli MobileApp :: Failed to set last_seen time for device: %s." % e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue