[go: up one dir, main page]

Menu

[d859c4]: / presto / install.py  Maximize  Restore  History

Download this file

155 lines (132 with data), 4.8 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
 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/python
def main():
say('Pentaho Report Test Framework Development Setup Helper')
say('Trying to run Java... ')
if run('java -version'):
say('OK!')
else:
fail('java', 'not found. Must be in PATH. Java is needed to run Gradle.')
say('No java.')
say('Trying to run Gradle... ')
gradle = get_for_os('gradle')
if run('%s -v' % gradle):
say('OK!')
else:
fail(gradle, 'not found. Must be in PATH. Gradle is needed to build.')
say('No maven.')
pdiPath = ""
if promptYesNo('Should I look for PDI at %s? [Y/n]: ' % get_for_os('pdi')) == 'yes':
pdiPath = get_for_os('pdi')
else:
while pdiPath == "":
pdiPath = prompt('Ok, where? ')
panPath = os.path.join(pdiPath, get_for_os('pan_script'))
if os.path.exists(panPath):
say('OK!')
else:
fail('pdi', '%s not found. PDI is needed to run tests.' % panPath)
say('No pdi.')
if 'pdi' not in failed:
say('Trying to run Pan... ')
if run('%s -version' % panPath, badExitCode=True):
say('OK!')
else:
fail('pdi', 'Couldn''t run Pan, necessary for tests.')
say('Didn''t work.')
if 'pdi' in failed:
say('PDI wasn''t found, skipped check for Pentaho Reporting Output plugin.')
fail('pdi', 'Pentaho Reporting Output plugin not found, but is needed to run tests.')
if 'pdi' not in failed:
say('Looking for Pentaho Reporting Output plugin...')
outputPluginPath = os.path.join(pdiPath, 'plugins', 'pentaho-reporting-plugin.jar')
if os.path.exists(outputPluginPath):
say('OK!')
else:
fail('pdi', '%s not found.' % outputPluginPath)
if 'pdi' not in failed:
say('Looking for Mifos i18n bundles...')
i18nBundlePath = os.path.join(pdiPath, 'org', 'mifos', 'bi', 'reports')
if os.path.exists(i18nBundlePath):
say('OK!')
else:
fail('pdi', '%s not found, but is needed to run tests.' % i18nBundlePath)
userHome = os.getenv('USERPROFILE') or os.getenv('HOME')
prestoSettings = os.path.join(userHome, '.presto')
if 'pdi' not in failed:
if os.path.exists(prestoSettings) and promptYesNo('%s exists. Overwrite? [Y/n]: ' % prestoSettings) == 'yes' \
or not os.path.exists(prestoSettings):
say('Storing local settings...')
prestoSettingsFd = open(prestoSettings, 'w')
print >> prestoSettingsFd, 'pdiPath=%s' % pdiPath
prestoSettingsFd.close()
say('Wrote %s' % prestoSettings)
if 'pdi' not in failed:
dbSettingsFile = os.path.join(pdiPath, 'simple-jndi', 'jdbc.properties')
say('')
say('Be sure to configure your database connections in %s' % dbSettingsFile)
say('SourceDB must be a Mifos OLTP database, DestinationDB must be a Mifos BI data warehouse.')
say('Mysql connection URL must include useUnicode=true&characterEncoding=UTF-8.')
say('')
say('DONE.')
say('')
if failed:
say('THERE WERE ERRORS. Fix the following, then try again:')
for msg in failmsgs:
say(msg)
else:
say('Ready to test Pentaho reports! Build using "gradle build".')
import os
import re
import subprocess
default_locations = {
'pdi': {
'nt' : os.path.join('Program Files', 'Pentaho Data Integration'),
'posix': os.path.join('/', 'opt', 'pentaho', 'data-integration'),
},
'pan_script': {
'nt' : 'pan.bat',
'posix': 'pan.sh',
},
'gradle': {
'nt' : 'gradle.bat',
'posix': 'gradle',
},
}
failed = []
failmsgs = []
def format_string_for_user(msg):
return '*** ' + msg
def get_for_os(program_nickname):
return default_locations[program_nickname][os.name]
def say(msg):
'Tell the user something.'
print format_string_for_user(msg)
def prompt(msg):
'Ask for user input.'
answer = raw_input(format_string_for_user(msg))
return answer
def promptYesNo(msg):
'Ask for yes/no response'
answer = raw_input(format_string_for_user(msg))
if answer == '' or re.match('y', answer, re.IGNORECASE):
return 'yes'
else:
return 'no'
def fail(what, why):
failmsg = what + ' FAIL: ' + why
failmsgs.append(failmsg)
failed.append(what)
def run(cmd, badExitCode=False):
'Run an external command.'
exit_status = 1
try:
exit_status = subprocess.call(cmd.split())
except OSError as e:
say("%s" % e)
return False
if exit_status == 0 or badExitCode:
return True
else:
return False
if __name__ == '__main__':
main()