X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/a9d643d150d1c3a9cdc33b180ff6e17612fd768f..30380c4b5b28df9670ea5952e14bc485d1d34133:/wizard/app/__init__.py diff --git a/wizard/app/__init__.py b/wizard/app/__init__.py index 4b64f80..1d01966 100644 --- a/wizard/app/__init__.py +++ b/wizard/app/__init__.py @@ -237,14 +237,13 @@ class Application(object): default implementation uses :attr:`resolutions`. """ resolved = True - sh = shell.Shell() files = set() - for status in sh.eval("git", "ls-files", "--unmerged").splitlines(): + for status in shell.eval("git", "ls-files", "--unmerged").splitlines(): files.add(status.split()[-1]) for file in files: # check for newline mismatch # HACK: using git diff to tell if files are binary or not - if not len(sh.eval("git", "diff", file).splitlines()) == 1 and util.mixed_newlines(file): + if not len(shell.eval("git", "diff", file).splitlines()) == 1 and util.mixed_newlines(file): # this code only works on Unix def get_newline(filename): f = open(filename, "U") @@ -257,7 +256,7 @@ class Application(object): return f.newlines def create_reference(id): f = tempfile.NamedTemporaryFile(prefix="wizardResolve", delete=False) - sh.call("git", "cat-file", "blob", ":%d:%s" % (id, file), stdout=f) + shell.call("git", "cat-file", "blob", ":%d:%s" % (id, file), stdout=f) f.close() return get_newline(f.name), f.name def convert(filename, dest_nl): @@ -282,9 +281,9 @@ class Application(object): logging.info("Remerging %s", file) with open(file, "wb") as f: try: - sh.call("git", "merge-file", "--stdout", our_file, common_file, their_file, stdout=f) + shell.call("git", "merge-file", "--stdout", our_file, common_file, their_file, stdout=f) logging.info("New merge was clean") - sh.call("git", "add", file) + shell.call("git", "add", file) continue except shell.CallError: pass @@ -301,7 +300,7 @@ class Application(object): logging.info("Did resolution with spec:\n" + spec) open(file, "w").write(contents) if not resolve.is_conflict(contents): - sh.call("git", "add", file) + shell.call("git", "add", file) else: resolved = False else: @@ -682,11 +681,10 @@ def backup_mysql_database(outdir, deployment): """ Database backups for MySQL using the :command:`mysqldump` utility. """ - sh = shell.Shell() outfile = os.path.join(outdir, "db.sql") try: - sh.call("mysqldump", "--compress", "-r", outfile, *get_mysql_args(deployment.dsn)) - sh.call("gzip", "--best", outfile) + shell.call("mysqldump", "--compress", "-r", outfile, *get_mysql_args(deployment.dsn)) + shell.call("gzip", "--best", outfile) except shell.CallError as e: raise BackupFailure(e.stderr) @@ -704,13 +702,12 @@ def restore_mysql_database(backup_dir, deployment): """ Database restoration for MySQL by piping SQL commands into :command:`mysql`. """ - sh = shell.Shell() if not os.path.exists(backup_dir): raise RestoreFailure("Backup %s doesn't exist", backup_dir.rpartition("/")[2]) sql = open(os.path.join(backup_dir, "db.sql"), 'w+') - sh.call("gunzip", "-c", os.path.join(backup_dir, "db.sql.gz"), stdout=sql) + shell.call("gunzip", "-c", os.path.join(backup_dir, "db.sql.gz"), stdout=sql) sql.seek(0) - sh.call("mysql", *get_mysql_args(deployment.dsn), stdin=sql) + shell.call("mysql", *get_mysql_args(deployment.dsn), stdin=sql) sql.close() def remove_database(deployment): @@ -718,10 +715,9 @@ def remove_database(deployment): Generic database removal function. Actually, not so generic because we go and check if we're on scripts and if we are run a different command. """ - sh = shell.Shell() if deployment.dsn.host == "sql.mit.edu": try: - sh.call("/mit/scripts/sql/bin/drop-database", deployment.dsn.database) + shell.call("/mit/scripts/sql/bin/drop-database", deployment.dsn.database) return except shell.CallError: pass