瀏覽代碼

[minor] add move to wnf.py

version-14
Pratik Vyas 11 年之前
父節點
當前提交
729239109e
共有 1 個檔案被更改,包括 19 行新增0 行删除
  1. +19
    -0
      wnf.py

+ 19
- 0
wnf.py 查看文件

@@ -115,6 +115,10 @@ def setup_utilities(parser):
# misc
parser.add_argument("--backup", default=False, action="store_true",
help="Take backup of database in backup folder [--with_files]")
parser.add_argument("--move", default=False, action="store_true",
help="Move site to different directory defined by --dest_dir")
parser.add_argument("--dest_dir", nargs=1, metavar="DEST-DIR",
help="Move site to different directory")
parser.add_argument("--with_files", default=False, action="store_true",
help="Also take backup of files")
parser.add_argument("--docs", default=False, action="store_true",
@@ -298,6 +302,21 @@ def backup(site=None, with_files=False):
print "backup taken -", odb.backup_path_db, "- on", now()
return odb

@cmd
def move(site=None, dest_dir=None):
import os
import shutil
if not dest_dir:
raise Exception, "--dest_dir is required for --move"
dest_dir = dest_dir[0]
if not os.path.isdir(dest_dir):
raise Exception, "destination is not a directory or does not exist"
webnotes.init(site=site)
old_path = webnotes.utils.get_site_path()
new_path = os.path.join(dest_dir, site)
shutil.move(old_path, new_path)
webnotes.destroy()

@cmd
def docs():
from core.doctype.documentation_tool.documentation_tool import write_static


Loading…
取消
儲存