mirror of
https://github.com/frappe/bench.git
synced 2024-11-11 15:51:03 +00:00
Fix migrate-3to4, fix #37
This commit is contained in:
parent
4845ed51fa
commit
fedf007a11
@ -1,17 +1,38 @@
|
|||||||
from frappe.installer import add_to_installed_apps
|
from frappe.installer import add_to_installed_apps
|
||||||
from frappe.cli import latest
|
from frappe.cli import latest
|
||||||
from frappe.modules.patch_handler import executed
|
from frappe.modules.patch_handler import executed
|
||||||
from .utils import exec_cmd, get_sites, get_frappe
|
|
||||||
import frappe
|
import frappe
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import imp
|
import imp
|
||||||
import json
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
|
||||||
sites_path = os.environ.get('SITES_PATH', 'sites')
|
sites_path = os.environ.get('SITES_PATH', 'sites')
|
||||||
last_3_patch = 'patches.1401.fix_planned_qty'
|
last_3_patch = 'patches.1401.fix_planned_qty'
|
||||||
|
|
||||||
|
|
||||||
|
def get_frappe(bench='.'):
|
||||||
|
frappe = os.path.abspath(os.path.join(bench, 'env', 'bin', 'frappe'))
|
||||||
|
if not os.path.exists(frappe):
|
||||||
|
print 'frappe app is not installed. Run the following command to install frappe'
|
||||||
|
print 'bench get-app frappe https://github.com/frappe/frappe.git'
|
||||||
|
return frappe
|
||||||
|
|
||||||
|
def get_sites(bench='.'):
|
||||||
|
sites_dir = os.path.join(bench, "sites")
|
||||||
|
sites = [site for site in os.listdir(sites_dir)
|
||||||
|
if os.path.isdir(os.path.join(sites_dir, site)) and site not in ('assets',)]
|
||||||
|
return sites
|
||||||
|
|
||||||
|
def exec_cmd(cmd, cwd='.'):
|
||||||
|
try:
|
||||||
|
subprocess.check_call(cmd, cwd=cwd, shell=True)
|
||||||
|
except subprocess.CalledProcessError, e:
|
||||||
|
print "Error:", e.output
|
||||||
|
raise
|
||||||
|
|
||||||
def main(path):
|
def main(path):
|
||||||
site = copy_site(path)
|
site = copy_site(path)
|
||||||
migrate(site)
|
migrate(site)
|
||||||
@ -59,10 +80,14 @@ def migrate(site):
|
|||||||
def module_to_json(module_path, indent=None, keys=None):
|
def module_to_json(module_path, indent=None, keys=None):
|
||||||
module = imp.load_source('tempmod', module_path)
|
module = imp.load_source('tempmod', module_path)
|
||||||
json_keys = [x for x in dir(module) if not x.startswith('_')]
|
json_keys = [x for x in dir(module) if not x.startswith('_')]
|
||||||
|
|
||||||
if keys:
|
if keys:
|
||||||
json_keys = [x for x in json_keys if x in keys]
|
json_keys = [x for x in json_keys if x in keys]
|
||||||
if 'unicode_literals' in json_keys:
|
if 'unicode_literals' in json_keys:
|
||||||
json_keys.remove('unicode_literals')
|
json_keys.remove('unicode_literals')
|
||||||
|
if 'backup_path' in json_keys:
|
||||||
|
json_keys.remove('backup_path')
|
||||||
|
|
||||||
module = {x:getattr(module, x) for x in json_keys}
|
module = {x:getattr(module, x) for x in json_keys}
|
||||||
return json.dumps(module, indent=indent)
|
return json.dumps(module, indent=indent)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user