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
|
||||
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 os import system as execute
|
||||
import os.path as path
|
||||
|
@ -36,6 +36,12 @@ def initialize():
|
|||
login()
|
||||
return True
|
||||
|
||||
def shutdown(socket=None):
|
||||
print(getQueue())
|
||||
cancelAllDownloads(socket)
|
||||
if socket:
|
||||
socket.emit("toast", {'msg': "Server is closed."})
|
||||
|
||||
def mainSearch(term):
|
||||
return dz.search_main_gw(term)
|
||||
|
||||
|
|
|
@ -198,11 +198,13 @@ def nextItem(dz, socket=None):
|
|||
|
||||
def callbackQueueDone(result):
|
||||
global currentItem, currentJob, queueList, queue
|
||||
result['socket']
|
||||
del queueList[currentItem]
|
||||
currentItem = ""
|
||||
nextItem(result['dz'], result['socket'])
|
||||
|
||||
def getQueue():
|
||||
return (queue, queueList)
|
||||
|
||||
def removeFromQueue(uuid, socket=None):
|
||||
if uuid == currentItem:
|
||||
queueList[uuid]['cancel'] = True
|
||||
|
@ -211,3 +213,13 @@ def removeFromQueue(uuid, socket=None):
|
|||
del queueList[uuid]
|
||||
if socket:
|
||||
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