-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInstall.py
executable file
·108 lines (91 loc) · 2.78 KB
/
Install.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import subprocess
from shutil import copyfile
import sys
import time
import datetime
def printMessage(s):
print("--------------------------------------------------------")
print(" ", s)
print("--------------------------------------------------------")
def installPyMsSql():
try:
# Now install pymssql
printMessage("Install pymssql")
commands = [ \
['apt-get', '--assume-yes', 'update' ], \
['apt-get', '--assume-yes', 'install', 'freetds-dev', 'freetds-bin'], \
['apt-get', '--assume-yes', 'install', 'python-dev', 'python-pip'], \
['pip', 'install', 'pymssql'], \
]
"""
for i in range(len(commands)):
for j in range(len(commands[i])):
print(commands[i][j])
print()
"""
for i in range(len(commands)):
cmd = " ".join(commands[i])
printMessage("Running...." + cmd)
process = subprocess.Popen(commands[i], stdout=subprocess.PIPE)
while True:
s = process.stdout.readline().decode('utf-8')
s = s.replace("\n","")
if not s:
break
print(s)
process.terminate()
except KeyboardInterrupt:
pass
return
def installIfStat():
try:
# Update first
command = ['apt-get', 'update']
process = subprocess.Popen(command, stdout=subprocess.PIPE)
while True:
s = process.stdout.readline().decode('utf-8')
s = s.replace("\n","")
if not s:
break
print(s)
# Now install sysstat
printMessage("Install ifstat")
command = ['apt-get', '--assume-yes', 'install','ifstat']
process = subprocess.Popen(command, stdout=subprocess.PIPE)
while True:
s = process.stdout.readline().decode('utf-8')
s = s.replace("\n","")
if not s:
break
print(s)
except KeyboardInterrupt:
pass
return
def installIoStat():
try:
# Update first
command = ['apt-get', 'update']
process = subprocess.Popen(command, stdout=subprocess.PIPE)
while True:
s = process.stdout.readline().decode('utf-8')
s = s.replace("\n","")
if not s:
break
print(s)
# Now install sysstat
printMessage("Install iostat")
command = ['apt-get', '--assume-yes', 'install','sysstat']
process = subprocess.Popen(command, stdout=subprocess.PIPE)
while True:
s = process.stdout.readline().decode('utf-8')
s = s.replace("\n","")
if not s:
break
print(s)
except KeyboardInterrupt:
pass
return
print("Installing Python on Ubuntu")
installIoStat()
installIfStat()
installPyMsSql()