Added shutdown function for app and server
This commit is contained in:
parent
be690cabc3
commit
b41970964d
|
@ -1,6 +1,6 @@
|
||||||
from deemix.api.deezer import Deezer
|
from deemix.api.deezer import Deezer
|
||||||
import deemix.utils.localpaths as localpaths
|
import deemix.utils.localpaths as localpaths
|
||||||
from deemix.app.queuemanager import addToQueue, removeFromQueue
|
from deemix.app.queuemanager import addToQueue, removeFromQueue, getQueue, cancelAllDownloads
|
||||||
from deemix.app.settings import initSettings
|
from deemix.app.settings import initSettings
|
||||||
from os import system as execute
|
from os import system as execute
|
||||||
import os.path as path
|
import os.path as path
|
||||||
|
@ -36,6 +36,12 @@ def initialize():
|
||||||
login()
|
login()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def shutdown(socket=None):
|
||||||
|
print(getQueue())
|
||||||
|
cancelAllDownloads(socket)
|
||||||
|
if socket:
|
||||||
|
socket.emit("toast", {'msg': "Server is closed."})
|
||||||
|
|
||||||
def mainSearch(term):
|
def mainSearch(term):
|
||||||
return dz.search_main_gw(term)
|
return dz.search_main_gw(term)
|
||||||
|
|
||||||
|
|
|
@ -198,11 +198,13 @@ def nextItem(dz, socket=None):
|
||||||
|
|
||||||
def callbackQueueDone(result):
|
def callbackQueueDone(result):
|
||||||
global currentItem, currentJob, queueList, queue
|
global currentItem, currentJob, queueList, queue
|
||||||
result['socket']
|
|
||||||
del queueList[currentItem]
|
del queueList[currentItem]
|
||||||
currentItem = ""
|
currentItem = ""
|
||||||
nextItem(result['dz'], result['socket'])
|
nextItem(result['dz'], result['socket'])
|
||||||
|
|
||||||
|
def getQueue():
|
||||||
|
return (queue, queueList)
|
||||||
|
|
||||||
def removeFromQueue(uuid, socket=None):
|
def removeFromQueue(uuid, socket=None):
|
||||||
if uuid == currentItem:
|
if uuid == currentItem:
|
||||||
queueList[uuid]['cancel'] = True
|
queueList[uuid]['cancel'] = True
|
||||||
|
@ -211,3 +213,13 @@ def removeFromQueue(uuid, socket=None):
|
||||||
del queueList[uuid]
|
del queueList[uuid]
|
||||||
if socket:
|
if socket:
|
||||||
socket.emit("removedFromQueue", uuid)
|
socket.emit("removedFromQueue", uuid)
|
||||||
|
|
||||||
|
def cancelAllDownloads(socket=None):
|
||||||
|
queue = []
|
||||||
|
if currentItem != "":
|
||||||
|
queueList[currentItem]['cancel'] = True
|
||||||
|
for uuid in list(queueList.keys()):
|
||||||
|
if uuid != currentItem:
|
||||||
|
del queueList[uuid]
|
||||||
|
if socket:
|
||||||
|
socket.emit("removedAllDownloads")
|
||||||
|
|
Loading…
Reference in New Issue