-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcodedeploy.py
More file actions
executable file
·42 lines (31 loc) · 1.24 KB
/
codedeploy.py
File metadata and controls
executable file
·42 lines (31 loc) · 1.24 KB
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
#!/usr/bin/env python
import subprocess
import yaml
import zipfile
def main():
print "Iniciando PyCodeDeploy"
data_loaded = ""
with open("/tmp/appspec.yml", 'r') as stream:
data_loaded = yaml.load(stream)
if data_loaded['os'] == 'linux' and data_loaded['version'] == 0.0:
hooks = data_loaded['hooks']
files = data_loaded['files']
steps = ['ApplicationStop', 'DownloadBundle', 'BeforeInstall', 'Install',
'AfterInstall', 'ApplicationStart', 'ValidateService']
dir_destination = files[0]['destination']
for step in steps:
if step == "DownloadBundle":
with zipfile.ZipFile('/tmp/artifactor.zip', "r") as z:
z.extractall(dir_destination)
continue
if step in hooks:
print "### Step: " + str(step)
for task in hooks[step]:
# print task['timeout']
# print task['runas']
print str(step) + " - " + str(task['location'])
rc = subprocess.call("sh " + dir_destination + "/" + task['location'], shell=True)
print(rc)
#input("Debug: ")
if __name__ == "__main__":
main()