def _do_backout(self, repo, uri, db, backout_statement): connection = db.connect() repo_cursor = connection.cursor() repo_uri = get_repo_uri(uri, repo) try: repo_id = get_repo_id(repo_uri, repo_cursor, db) except RepoNotFound: # Repository isn't in there, so it's likely already backed out printerr("Repository not found, is it in the database?") return True finally: repo_cursor.close() update_cursor = connection.cursor() execute_statement(statement(backout_statement, db.place_holder), (repo_id,), update_cursor, db, "Couldn't backout extension", exception=ExtensionBackoutError) update_cursor.close() connection.commit() connection.close()
def run(self, repo, uri, db): # Start the profiler, per every other extension profiler_start("Running BugFixMessage extension") # Open a connection to the database and get cursors self.db = db connection = self.db.connect() read_cursor = connection.cursor() write_cursor = connection.cursor() # Try to get the repository and get its ID from the database try: repo_uri = get_repo_uri(uri, repo) repo_id = get_repo_id(repo_uri, read_cursor, db) except NotImplementedError: raise ExtensionRunError( \ "BugFixMessage extension is not supported for %s repos" % \ (repo.get_type())) except Exception, e: raise ExtensionRunError( \ "Error creating repository %s. Exception: %s" % \ (repo.get_uri(), str(e)))