text
stringlengths 0
828
|
|---|
self.print_message(""Resetting database for app '%s'"" % self.args.destination_app)
|
args = [
|
""heroku"",
|
""pg:reset"",
|
""--app=%s"" % self.args.destination_app,
|
""DATABASE_URL"",
|
]
|
subprocess.check_call(args)"
|
923,"def replace_heroku_db(self, file_url):
|
"""""" Replace Heroku database with database from specified source. """"""
|
self.print_message(""Replacing database for Heroku app '%s'"" % self.args.destination_app)
|
self.reset_heroku_database()
|
if file_url:
|
self.print_message(""Restoring from URL '%s'"" % file_url)
|
args = [
|
""heroku"",
|
""pg:backups:restore"",
|
file_url,
|
""--app=%s"" % self.args.destination_app,
|
""DATABASE"",
|
""--confirm"",
|
self.args.destination_app,
|
]
|
if self.args.use_pgbackups:
|
args = [
|
""heroku"",
|
""pgbackups:restore"",
|
""--app=%s"" % self.args.destination_app,
|
""DATABASE_URL"",
|
""--confirm"",
|
self.args.destination_app,
|
file_url,
|
]
|
subprocess.check_call(args)
|
else:
|
# TODO perhaps add support for file -> heroku by piping to pg:psql
|
self.print_message(""Pushing data from database '%s'"" % self.databases['source']['name'])
|
self.print_message(""NOTE: Any postgres authentication settings you passed to paragres ""
|
""will be ignored.\nIf desired, you can export PG* variables.\n""
|
""You will be prompted for your psql password."")
|
args = [
|
""heroku"",
|
""pg:push"",
|
self.databases['source']['name'],
|
""DATABASE_URL"",
|
""--app=%s"" % self.args.destination_app,
|
]
|
subprocess.check_call(args)"
|
924,"def run(self):
|
"""""" Replace a database with the data from the specified source. """"""
|
self.print_message(""\nBeginning database replacement process.\n"")
|
if self.args.source_settings:
|
settings = self.parse_db_settings(self.args.source_settings)
|
self.initialize_db_args(settings, 'source')
|
if self.args.settings:
|
settings = self.parse_db_settings(self.args.settings)
|
self.initialize_db_args(settings, 'destination')
|
if self.args.capture:
|
self.capture_heroku_database()
|
file_url = self.args.url
|
if self.args.source_app:
|
self.print_message(""Sourcing data from backup for Heroku app '%s'""
|
% self.args.source_app)
|
file_url = self.get_file_url_for_heroku_app(self.args.source_app)
|
if self.args.destination_app:
|
self.replace_heroku_db(file_url)
|
elif self.databases['destination']['name']:
|
self.replace_postgres_db(file_url)
|
self.print_message(""\nDone.\n\nDon't forget to update the Django Site entry if necessary!"")"
|
925,"def import_task_modules():
|
""""""
|
Import all installed apps and add modules to registry
|
""""""
|
top_level_modules = settings.INSTALLED_APPS
|
module_names = []
|
for module in top_level_modules:
|
#Import package
|
mod = import_module(module)
|
#Find all modules in package path
|
for loader, module_name, is_pkg in pkgutil.walk_packages(mod.__path__):
|
if not module_name.startswith(""__""):
|
#If the module is not __init__, add it to the registry
|
submod_name = ""{0}.{1}"".format(module,module_name)
|
module_names.append(submod_name)
|
#Once everything is imported, the metaclass will register them automatically
|
modules = map(import_module, module_names)
|
return modules"
|
926,"def find_in_registry(category = None, namespace = None, name = None):
|
""""""
|
Find a given category/namespace/name combination in the registry
|
category - string, see utils.inputs.registrycategories
|
namespace - module namespace, see settings.NAMESPACE
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.