-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtask.py
40 lines (35 loc) · 1.16 KB
/
task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import json
class TaskTypes:
SUBTITLE = "subs"
VIDEO = "video"
AUDIO = "audio"
REMUX = "remux"
NONE = "none"
#Tasks are capable of serializing, unserializing, and executing themselves. This allows the choice of where to execute them - on the server directly or as part of a cluster.
class Task:
tasktype = None
command = "echo"
arguments = []
forcefdk = False
infile = ""
outfile = ""
def __init__(self,createfrom=None,tasktype=TaskTypes.NONE,command="echo",arguments=[],infile="",outfile="",forcefdk=False):
if createfrom == None:
self.tasktype = tasktype
self.command = command
self.arguments = arguments
self.infile = infile
self.outfile = outfile
self.forcefdk = forcefdk
else:
obj = json.loads(createfrom)
self.tasktype = obj["type"]
self.command = obj["command"]
self.arguments = obj["arguments"]
self.infile = obj["infile"]
self.forcefdk = obj["forcefdk"]
self.outfile = obj["outfile"]
def stringify(self):
return json.dumps({"type":self.tasktype,"command":self.command,"arguments":self.arguments,"infile":self.infile,"outfile":self.outfile, "forcefdk":self.forcefdk})
def __str__(self):
return self.stringify()