"""
Database restoration for MySQL by piping SQL commands into :command:`mysql`.
"""
- if not os.path.exists(backup_dir): # XXX possibly buggy
+ if not os.path.exists(backup_dir):
raise RestoreDatabaseError("Backup %s doesn't exist" % backup_dir.rpartition("/")[2])
sql = open(os.path.join(backup_dir, "db.sql"), 'w+')
shell.call("gunzip", "-c", os.path.join(backup_dir, "db.sql.gz"), stdout=sql)