r50962 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50961‎ | r50962 | r50963 >
Date:20:54, 24 May 2009
Author:kim
Status:deferred
Tags:
Comment:
Add more sanity checks and warnings.
* Installer Refuses to attempt an install if it can't log in to mysql
* Installer warns if it can't log in to mysql
* More checks during mediawiki install process
Modified paths:
  • /trunk/testing/installer/installer_util.py (modified) (history)
  • /trunk/testing/installer/mediawiki_installer.py (modified) (history)

Diff [purge]

Index: trunk/testing/installer/installer_util.py
@@ -88,7 +88,17 @@
8989 print "help<enter> for help"
9090 print "^D, exit<enter> or quit<enter> to quit"
9191 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?"
9295
 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+
93103 def help_for(something):
94104 """If the user types incorrect input, try to gently correct them"""
95105
Index: trunk/testing/installer/mediawiki_installer.py
@@ -11,6 +11,7 @@
1212
1313 from installer_util import *
1414 from isolation import *
 15+import installer_util
1516
1617 # this still uses some legacy structured code, wrapped in a class so it can't do
1718 #too much harm outside this file. Will refactor later when I have more time.
@@ -86,6 +87,9 @@
8788 raise Mediawiki_Installer_Exception("Please specify which mediawiki tag or revision you would like to view")
8889
8990 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?)")
9094
9195 install(installer_name, name, self.revision, self.language)
9296 return self.is_installed(name)
@@ -99,7 +103,9 @@
100104 if not self.is_installed(name):
101105 print name+" does not appear to be installed"
102106 return
103 -
 107+ if not installer_util.db_works():
 108+ raise Installer_Exception("Cannot access database. (Is your settings.py correct?)")
 109+
104110 uninstall(name)
105111 return not self.is_installed(name)
106112
@@ -129,6 +135,9 @@
130136 src is the instance to duplicate
131137 dst is the name to copy to.
132138 """
 139+ if not installer_util.db_works():
 140+ raise Installer_Exception("Cannot access database. (Is your settings.py correct?)")
 141+
133142 if not self.is_installed(src):
134143 raise Mediawiki_Installer_Exception(src+" not found.")
135144
@@ -260,7 +269,9 @@
261270 def _checkout(command, name):
262271 """perform the actual check out, and rename our checked out data to something more useful"""
263272
264 - os.system(command)
 273+ rv=os.system(command)>>8
 274+ if rv:
 275+ raise Installer_Exception("Download failed")
265276 os.rename('phase3',name)
266277
267278
@@ -323,29 +334,39 @@
324335 #do_sql(target, settings.installerdir+"/user.sql")
325336 phpfile=os.path.join(settings.instancesdir,target,"maintenance","createAndPromote.php")
326337 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)
328341
329342 def dumpdb(target,outfile):
330343 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))
332347
333348 def do_sql(target, infile):
334349 """execute an sql file, using mysql"""
335350
336351 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))
338355
339356 def createdb(target):
340357 """create a database using mysql"""
341358
342359 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))
344363
345364 def dropdb(target):
346365 """drop a database using mysql"""
347366
348367 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))
350371
351372 def delete(target):
352373 """delete target mediawiki installation, assumes we are in the revisions directory"""

Status & tagging log