1 |
#!/usr/local/bin/python
|
2 |
import commands
|
3 |
import time
|
4 |
import sys
|
5 |
import os
|
6 |
import platform
|
7 |
from subprocess import call
|
8 |
|
9 |
apt_platforms = ["Ubuntu","Debian"]
|
10 |
yum_platforms = ["Fedora","RedHat Enterprise","Fedora","CentOS"]
|
11 |
|
12 |
PossibleApplications = ["PostgreSQL","MySQL","SQLite","Apache","Memcached","Patch","CVS","GIT","Mercurial","Perforce","Subversion","PyLucene","Amazons3storage","Nose","Pycrypto","Sphinx"]
|
13 |
|
14 |
InstallOrGuide=""
|
15 |
|
16 |
positivelist = ["Yes", "yes", "Y", "y"]
|
17 |
negativelist = ["No", "no", "N", "n"]
|
18 |
|
19 |
OperatingSystem=platform.uname()[0]
|
20 |
Version=platform.uname()[2]
|
21 |
Arch=platform.uname()[4]
|
22 |
|
23 |
def ListOfApplications():
|
24 |
for Application in PossibleApplications:
|
25 |
print Application
|
26 |
|
27 |
|
28 |
|
29 |
if OperatingSystem == "Linux":
|
30 |
SystemInfo = platform.linux_distribution()
|
31 |
Platform = SystemInfo[0]
|
32 |
if Platform in apt_platforms:
|
33 |
kind = "Standards"
|
34 |
#ADD YAM KIND HERE
|
35 |
|
36 |
elif OperatingSystem =="Windows":
|
37 |
if(Arch == "AMD64"):
|
38 |
kind="X64"
|
39 |
else:
|
40 |
kind="X86"
|
41 |
|
42 |
|
43 |
if len(sys.argv)==1:
|
44 |
empty=raw_input("You need to choose an application to install.(ex: Practice Mysql) for a list of all dependencies press L: \n")
|
45 |
if empty in ["L", "l"]:
|
46 |
ListOfApplications()
|
47 |
sys.exit()
|
48 |
else:
|
49 |
if sys.argv[1] not in PossibleApplications:
|
50 |
print "The application does not exist! This is the list of applications supported:"
|
51 |
ListOfApplications()
|
52 |
sys.exit()
|
53 |
else:
|
54 |
ApplicationName=sys.argv[1]
|
55 |
filename = ("%s.%s.%s" % (OperatingSystem,kind,ApplicationName))
|
56 |
Ins=raw_input("Would you like us to install " + ApplicationName + " for you?(Yes,No)")
|
57 |
if Ins in negativelist:
|
58 |
InstallOrGuide="guide"
|
59 |
elif Ins in positivelist:
|
60 |
if(OperatingSystem=="Linux"):
|
61 |
if(os.getuid() == 0):
|
62 |
InstallOrGuide="install"
|
63 |
else:
|
64 |
print "You need to run this application as an administrator in order to install " + ApplicationName
|
65 |
sys.exit()
|
66 |
else:
|
67 |
InstallOrGuide="install"
|
68 |
else:
|
69 |
print "Please select one of the two"
|
70 |
sys.exit(1)
|
71 |
|
72 |
responsible_module = __import__(filename, fromlist=[filename])
|
73 |
responsible_function = getattr(responsible_module, InstallOrGuide)
|
74 |
responsible_function()
|