forked from scaleapi/scaleapi-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
29 lines (23 loc) · 869 Bytes
/
tasks.py
File metadata and controls
29 lines (23 loc) · 869 Bytes
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
class Task(object):
"""Task class, containing task information."""
def __init__(self, param_dict, client):
self.client = client
self.param_dict = param_dict
self.id = param_dict['task_id']
def __getattr__(self, name):
if name in self.param_dict:
return self.param_dict[name]
if name in self.params:
return self.params[name]
raise AttributeError("'%s' object has no attribute %s"
% (type(self).__name__, name))
def __hash__(self):
return hash(self.id)
def __str__(self):
return 'Task(id=%s)' % self.id
def __repr__(self):
return 'Task(%s)' % self.param_dict
def refresh(self):
self.param_dict = self.client._getrequest('task/%s' % self.id)
def cancel(self):
self.client.cancel_task(self.id)