def _checkout(command, name): """perform the actual check out, and rename our checked out data to something more useful""" rv = os.system(command) >> 8 if rv: raise Installer_Exception("Download failed") os.rename('phase3', name)
def duplicate(self, src, dst): """Duplicate an existing instance. src is the instance to duplicate dst is the name to copy to. """ if not installer_util.db_works(): raise Installer_Exception( "Cannot access database. (Is your settings.py correct?)") if not self.is_installed(src): raise Mediawiki_Installer_Exception(src + " not found.") if self.is_installed(dst): raise Mediawiki_Installer_Exception(dst + " already exists.") srcpath = os.path.join(settings.instancesdir, src) dstpath = os.path.join(settings.instancesdir, dst) dbtmp = os.path.join(dstpath, "installerdbtmp.sql") print "Copying instance files..." shutil.copytree(srcpath, dstpath, symlinks=True) print "updating unique settings and adminsettings" uniquesettings(dst, self.language) adminsettings(dst) print "Copying instance database..." dumpdb(src, dbtmp) dropdb(dst) createdb(dst) do_sql(dst, dbtmp) print "cleanup" os.unlink(dbtmp) print "done."
def dropdb(target): """drop a database using mysql""" command = "echo 'DROP DATABASE IF EXISTS " + dbname( target) + ";' | " + settings.mysql_command rv = os.system(command) >> 8 if rv: raise Installer_Exception("Could not drop database " + dbname(target))
def createdb(target): """create a database using mysql""" command = "echo 'CREATE DATABASE " + dbname( target) + ";' | " + settings.mysql_command rv = os.system(command) >> 8 if rv: raise Installer_Exception("Could not create database " + dbname(target))
def do_sql(target, infile): """execute an sql file, using mysql""" command = "< " + infile + " " + settings.mysql_command + " " + dbname( target) rv = os.system(command) >> 8 if rv: raise Installer_Exception("Could not execute sql file " + infile + " for database " + dbname(target))
def make_admin(target): """create an admin user using createAndPromote.php""" #do_sql(target, settings.installerdir+"/user.sql") phpfile = os.path.join(settings.instancesdir, target, "maintenance", "createAndPromote.php") command = "php " + phpfile + " --bureaucrat " + settings.adminuser_name + " " + settings.adminuser_password rv = os.system(command) >> 8 if rv: raise Installer_Exception("Failed to create admin user on " + target)
def uninstall(self, installer_name): name = self.as_alias or installer_name if not self.is_installed(name): print name + " does not appear to be installed" return if not installer_util.db_works(): raise Installer_Exception( "Cannot access database. (Is your settings.py correct?)") uninstall(name) return not self.is_installed(name)
def install(self, installer_name=None, as_alias=None): if self.tag: installer_name = self.tag if self.revision: installer_name = "latest" if not installer_name: installer_name = self.instance if not installer_name: raise Mediawiki_Installer_Exception( "Please specify which mediawiki tag or revision you would like to view" ) name = as_alias or self.as_alias or installer_name if not installer_util.db_works(): raise Installer_Exception( "Cannot access database. (Is your settings.py correct?)") install(installer_name, name, self.revision, self.language) return self.is_installed(name)
def dumpdb(target, outfile): command = settings.mysqldump_command + " " + dbname( target) + " > " + outfile rv = os.system(command) >> 8 if rv: raise Installer_Exception("Failed to dump database" + dbname(target))