fix: migrate-to now works (#27115)
* chore : migrat-to pre check url * feat: migrate-to now works * fix: unecessary context * chore: remove commented code
This commit is contained in:
parent
f179a1286f
commit
02c680e68d
3 changed files with 13 additions and 22 deletions
|
|
@ -675,19 +675,12 @@ def migrate(context, skip_failing=False, skip_search_index=False):
|
|||
|
||||
|
||||
@click.command("migrate-to")
|
||||
@click.argument("frappe_provider")
|
||||
@pass_context
|
||||
def migrate_to(context, frappe_provider):
|
||||
def migrate_to(context):
|
||||
"Migrates site to the specified provider"
|
||||
from frappe.integrations.frappe_providers import migrate_to
|
||||
|
||||
for site in context.sites:
|
||||
frappe.init(site=site)
|
||||
frappe.connect()
|
||||
migrate_to(site, frappe_provider)
|
||||
frappe.destroy()
|
||||
if not context.sites:
|
||||
raise SiteNotSpecifiedError
|
||||
migrate_to(context)
|
||||
|
||||
|
||||
@click.command("run-patch")
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
# imports - standard imports
|
||||
import sys
|
||||
|
||||
# imports - module imports
|
||||
|
||||
from frappe.integrations.frappe_providers.frappecloud import frappecloud_migrator
|
||||
|
||||
|
||||
def migrate_to(local_site, frappe_provider):
|
||||
if frappe_provider in ("frappe.cloud", "frappecloud.com"):
|
||||
return frappecloud_migrator(local_site)
|
||||
else:
|
||||
print(f"{frappe_provider} is not supported yet")
|
||||
sys.exit(1)
|
||||
def migrate_to():
|
||||
return frappecloud_migrator()
|
||||
|
|
|
|||
|
|
@ -5,10 +5,9 @@ import frappe
|
|||
from frappe.core.utils import html2text
|
||||
|
||||
|
||||
def frappecloud_migrator(local_site):
|
||||
def get_remote_script(remote_site):
|
||||
print("Retrieving Site Migrator...")
|
||||
remote_site = frappe.conf.frappecloud_url or "frappecloud.com"
|
||||
request_url = f"https://{remote_site}/api/method/press.api.script"
|
||||
request_url = f"http://{remote_site}/api/method/press.api.script"
|
||||
request = requests.get(request_url)
|
||||
|
||||
if request.status_code / 100 != 2:
|
||||
|
|
@ -19,8 +18,12 @@ def frappecloud_migrator(local_site):
|
|||
)
|
||||
return
|
||||
|
||||
script_contents = request.json()["message"]
|
||||
return request.json()["message"]
|
||||
|
||||
|
||||
def frappecloud_migrator():
|
||||
remote_site_name = "frappecloud.com"
|
||||
script_contents = get_remote_script(remote_site=remote_site_name)
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
|
@ -29,4 +32,4 @@ def frappecloud_migrator(local_site):
|
|||
script = tempfile.NamedTemporaryFile(mode="w")
|
||||
script.write(script_contents)
|
||||
print(f"Site Migrator stored at {script.name}")
|
||||
os.execv(py, [py, script.name, local_site])
|
||||
os.execv(py, [py, script.name])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue