feat: package migrator
This commit is contained in:
parent
ea93f12a9a
commit
f0ec5cec0e
5 changed files with 131 additions and 0 deletions
0
frappe/custom/doctype/package_migration/__init__.py
Normal file
0
frappe/custom/doctype/package_migration/__init__.py
Normal file
51
frappe/custom/doctype/package_migration/package_migration.js
Normal file
51
frappe/custom/doctype/package_migration/package_migration.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) 2020, Frappe Technologies and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Package Migration', {
|
||||
refresh: function(frm) {
|
||||
if (frm.doc.attach) {
|
||||
frm.add_custom_button(__("Connect"), function() {
|
||||
let dialog = new frappe.ui.Dialog({
|
||||
title: __('Connect to Remote Instance'),
|
||||
fields: [
|
||||
{
|
||||
fieldtype: 'Data',
|
||||
label: 'Remote Instance',
|
||||
fieldname: 'remote_instance',
|
||||
reqd: 1
|
||||
},
|
||||
{
|
||||
fieldtype: 'Data',
|
||||
label: 'User',
|
||||
fieldname: 'user',
|
||||
reqd: 1
|
||||
},
|
||||
{
|
||||
fieldtype: 'Password',
|
||||
label: 'Password',
|
||||
fieldname: 'password',
|
||||
reqd: 1
|
||||
},
|
||||
],
|
||||
primary_action: function() {
|
||||
let values = dialog.get_values();
|
||||
frm.call("install_package_to_remote", {
|
||||
"remote_instance": values.remote_instance,
|
||||
"user": values.user,
|
||||
"password": values.password
|
||||
}).then((r) => {
|
||||
console.log(r);
|
||||
})
|
||||
dialog.hide();
|
||||
},
|
||||
primary_action_label: "Execute"
|
||||
});
|
||||
dialog.show();
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// "erpnext_support_password": "uYrMeEhb2NzuEGOk",
|
||||
// "erpnext_support_url": "https://marketplace.erpnext.com",
|
||||
// "erpnext_support_user": "erpnext_support_fQrhUujW@erpnext.com",
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"actions": [],
|
||||
"creation": "2020-03-17 00:13:31.851579",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"attach"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "attach",
|
||||
"fieldtype": "Attach",
|
||||
"in_list_view": 1,
|
||||
"label": "Attach",
|
||||
"reqd": 1
|
||||
}
|
||||
],
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2020-03-17 10:00:26.676328",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Custom",
|
||||
"name": "Package Migration",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
||||
28
frappe/custom/doctype/package_migration/package_migration.py
Normal file
28
frappe/custom/doctype/package_migration/package_migration.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2020, Frappe Technologies and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.frappeclient import FrappeClient
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
|
||||
class PackageMigration(Document):
|
||||
|
||||
def install_package_to_remote(self, remote_instance, user, password):
|
||||
connection = FrappeClient(remote_instance, user, password)
|
||||
|
||||
package_file = frappe.get_all("File", filters={
|
||||
"attached_to_doctype": "Package Migration",
|
||||
"attached_to_name": "Package Migration"
|
||||
}, limit=1, order_by="creation desc")
|
||||
|
||||
try:
|
||||
connection.post_request({
|
||||
"cmd": "frappe.custom.doctype.package.package.import_package",
|
||||
"package": frappe.get_doc("File", package_file[0].name).get_content()
|
||||
})
|
||||
except Exception:
|
||||
frappe.log_error(frappe.get_traceback())
|
||||
frappe.throw(_("Could not connect to Remote Site."))
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2020, Frappe Technologies and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestPackageMigration(unittest.TestCase):
|
||||
pass
|
||||
Loading…
Add table
Reference in a new issue