-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipeline.py
73 lines (58 loc) · 2.15 KB
/
pipeline.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import datetime
import functools
from seesaw.externalprocess import ExternalProcess
from seesaw.pipeline import Pipeline
from seesaw.project import Project
from seesaw.task import Task, LimitConcurrent
from tornado.ioloop import IOLoop
project = Project(
title='Warrior Extras Installer',
project_html='''
<img class="project-logo" alt=""
src="https://tracker.archiveteam.org/~chfoo/image/200px-Applications-system.svg.png"
height="50" />
<h2>Warrior Extras Installer
<span class="links">
<a href="https://github.com/ArchiveTeam/warrior-extras-installer">source code</a>
<span>
</h2>
<p>Select this project, when required, to install extra software components required by other projects.</p>
'''
)
class WarningTask(Task):
def __init__(self):
Task.__init__(self, 'WarningTask')
def enqueue(self, item):
self.start_item(item)
item.may_be_canceled = True
item.log_output(
'This project will install extra software components required by other projects.')
item.log_output('It is intended to be run within a Warrior VM appliance or Warrior Docker container. '
'Press CTRL+C to cancel.')
item.log_output('Update will continue in 10 seconds...')
IOLoop.instance().add_timeout(
datetime.timedelta(seconds=10),
functools.partial(self._finish, item)
)
def _finish(self, item):
item.may_be_canceled = False
self.complete_item(item)
class IdleTask(Task):
def __init__(self):
Task.__init__(self, 'IdleTask')
def enqueue(self, item):
self.start_item(item)
item.may_be_canceled = True
item.log_output('Pausing for 60 seconds...')
IOLoop.instance().add_timeout(
datetime.timedelta(seconds=60),
functools.partial(self._finish, item)
)
def _finish(self, item):
item.may_be_canceled = False
self.complete_item(item)
pipeline = Pipeline(
WarningTask(),
LimitConcurrent(1, ExternalProcess('Install', ['./install.sh'])),
IdleTask(),
)