-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-installation-pg.py
executable file
·118 lines (96 loc) · 3.23 KB
/
test-installation-pg.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env python
#
# Installation tests (for PostgreSQL)
#
# written by: Andreas Scherbaum <ascherbaum@pivotal.io>
# Andreas Scherbaum <ads@pgug.de>
#
import os
import sys
import logging
# start with the assumption that everything is ok
error = False
logging.getLogger().setLevel(logging.INFO)
if sys.version_info[0] < 3:
sys_modules = [ 're', 'tempfile', 'atexit', 'shutil', 'time', 'subprocess', 'socket', 'sqlite3', 'time', 'argparse', 'yaml', 'hashlib', 'string', 'urllib2', 'StringIO', 'gzip', 'zlib', 'datetime', 'copy', 'glob', 'shlex', 'stat', 'lockfile' ]
else:
sys_modules = [ 're', 'tempfile', 'atexit', 'shutil', 'time', 'subprocess', 'socket', 'sqlite3', 'time', 'argparse', 'yaml', 'hashlib', 'string', 'urllib3', 'io', 'gzip', 'zlib', 'datetime', 'copy', 'glob', 'shlex', 'stat', 'lockfile' ]
for module in sys_modules:
logging.debug("try to import module: " + module)
try:
__import__(module)
except ImportError:
logging.error("failed to load module: " + module)
error = True
# urlparse is different in Python 2 and 3
logging.debug("try to import module: urlparse / urljoin")
try:
from urlparse import urljoin # Python2
except ImportError:
try:
from urllib.parse import urljoin # Python3
except ImportError:
logging.error("failed to load module: urlparse / urljoin")
error = True
# try private modules
logging.debug("try to import private module: Config")
try:
from config import Config
except ImportError:
logging.error("failed to load private module: Config")
error = True
logging.debug("try to import private module: Repository")
try:
from repository import Repository
except ImportError:
logging.error("failed to load private module: Repository")
error = True
logging.debug("try to import private module: Build")
try:
from build import Build
except ImportError:
logging.error("failed to load private module: Build")
error = True
logging.debug("try to import private module: Patch")
try:
from patch import Patch
except ImportError:
logging.error("failed to load private module: Patch")
error = True
logging.debug("try to import private module: Database")
try:
from database import Database
except ImportError:
logging.error("failed to load private module: Database")
error = True
logging.debug("try to import private module: Buildfarm")
try:
from buildfarm import Buildfarm
except ImportError:
logging.error("failed to load private module: Buildfarm")
error = True
# load config file if one is specified
if (len(sys.argv) >= 3 and sys.argv[1] == '-c' and len(sys.argv[2]) > 0):
logging.debug("load config")
try:
config = Config()
config.config_help(False)
config.parse_parameters()
config.load_config()
config.build_and_verify_config()
except:
error = True
else:
# require "-c <config file>" because the Config module loads a config this way - reuse the code
print("")
print("Please specify a config file with: -c <config file>")
print("")
error = True
if (error is True):
print("")
print("Please verify your installation!")
print("")
else:
print("")
print("Everything seems to be OK")
print("")