Index: trunk/testing/installer/installer_util.py |
— | — | @@ -88,7 +88,17 @@ |
89 | 89 | print "help<enter> for help" |
90 | 90 | print "^D, exit<enter> or quit<enter> to quit" |
91 | 91 | print |
| 92 | + if not db_works(): |
| 93 | + print "WARNING: Mysql settings do not seem to be correct." |
| 94 | + print "Did you set up mysql correctly in settings.py?" |
92 | 95 | |
| 96 | +def db_works(): |
| 97 | + """check whether our database settings actually work |
| 98 | + by logging in to mysql with an empty line. |
| 99 | + returns true if database works, else returns false.""" |
| 100 | + rv=os.system("echo | "+settings.mysql_command) |
| 101 | + return not rv |
| 102 | + |
93 | 103 | def help_for(something): |
94 | 104 | """If the user types incorrect input, try to gently correct them""" |
95 | 105 | |
Index: trunk/testing/installer/mediawiki_installer.py |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | |
13 | 13 | from installer_util import * |
14 | 14 | from isolation import * |
| 15 | +import installer_util |
15 | 16 | |
16 | 17 | # this still uses some legacy structured code, wrapped in a class so it can't do |
17 | 18 | #too much harm outside this file. Will refactor later when I have more time. |
— | — | @@ -86,6 +87,9 @@ |
87 | 88 | raise Mediawiki_Installer_Exception("Please specify which mediawiki tag or revision you would like to view") |
88 | 89 | |
89 | 90 | name=as_alias or self.as_alias or installer_name |
| 91 | + |
| 92 | + if not installer_util.db_works(): |
| 93 | + raise Installer_Exception("Cannot access database. (Is your settings.py correct?)") |
90 | 94 | |
91 | 95 | install(installer_name, name, self.revision, self.language) |
92 | 96 | return self.is_installed(name) |
— | — | @@ -99,7 +103,9 @@ |
100 | 104 | if not self.is_installed(name): |
101 | 105 | print name+" does not appear to be installed" |
102 | 106 | return |
103 | | - |
| 107 | + if not installer_util.db_works(): |
| 108 | + raise Installer_Exception("Cannot access database. (Is your settings.py correct?)") |
| 109 | + |
104 | 110 | uninstall(name) |
105 | 111 | return not self.is_installed(name) |
106 | 112 | |
— | — | @@ -129,6 +135,9 @@ |
130 | 136 | src is the instance to duplicate |
131 | 137 | dst is the name to copy to. |
132 | 138 | """ |
| 139 | + if not installer_util.db_works(): |
| 140 | + raise Installer_Exception("Cannot access database. (Is your settings.py correct?)") |
| 141 | + |
133 | 142 | if not self.is_installed(src): |
134 | 143 | raise Mediawiki_Installer_Exception(src+" not found.") |
135 | 144 | |
— | — | @@ -260,7 +269,9 @@ |
261 | 270 | def _checkout(command, name): |
262 | 271 | """perform the actual check out, and rename our checked out data to something more useful""" |
263 | 272 | |
264 | | - os.system(command) |
| 273 | + rv=os.system(command)>>8 |
| 274 | + if rv: |
| 275 | + raise Installer_Exception("Download failed") |
265 | 276 | os.rename('phase3',name) |
266 | 277 | |
267 | 278 | |
— | — | @@ -323,29 +334,39 @@ |
324 | 335 | #do_sql(target, settings.installerdir+"/user.sql") |
325 | 336 | phpfile=os.path.join(settings.instancesdir,target,"maintenance","createAndPromote.php") |
326 | 337 | command="php "+phpfile+" --bureaucrat "+settings.adminuser_name+" "+settings.adminuser_password |
327 | | - os.system(command) |
| 338 | + rv=os.system(command)>>8 |
| 339 | + if rv: |
| 340 | + raise Installer_Exception("Failed to create admin user on "+target) |
328 | 341 | |
329 | 342 | def dumpdb(target,outfile): |
330 | 343 | command=settings.mysqldump_command+" "+dbname(target)+" > "+outfile |
331 | | - os.system(command) |
| 344 | + rv=os.system(command)>>8 |
| 345 | + if rv: |
| 346 | + raise Installer_Exception("Failed to dump database"+dbname(target)) |
332 | 347 | |
333 | 348 | def do_sql(target, infile): |
334 | 349 | """execute an sql file, using mysql""" |
335 | 350 | |
336 | 351 | command="< "+infile+" "+settings.mysql_command+" "+dbname(target) |
337 | | - os.system(command) |
| 352 | + rv=os.system(command)>>8 |
| 353 | + if rv: |
| 354 | + raise Installer_Exception("Could not execute sql file "+infile+" for database "+dbname(target)) |
338 | 355 | |
339 | 356 | def createdb(target): |
340 | 357 | """create a database using mysql""" |
341 | 358 | |
342 | 359 | command="echo 'CREATE DATABASE "+dbname(target)+";' | "+settings.mysql_command |
343 | | - os.system(command) |
| 360 | + rv=os.system(command)>>8 |
| 361 | + if rv: |
| 362 | + raise Installer_Exception("Could not create database "+dbname(target)) |
344 | 363 | |
345 | 364 | def dropdb(target): |
346 | 365 | """drop a database using mysql""" |
347 | 366 | |
348 | 367 | command="echo 'DROP DATABASE IF EXISTS "+dbname(target)+";' | "+settings.mysql_command |
349 | | - os.system(command) |
| 368 | + rv=os.system(command)>>8 |
| 369 | + if rv: |
| 370 | + raise Installer_Exception("Could not drop database "+dbname(target)) |
350 | 371 | |
351 | 372 | def delete(target): |
352 | 373 | """delete target mediawiki installation, assumes we are in the revisions directory""" |