예제 #1
0
def create_lock(name):
	lock_path = get_lock_path(name)
	if not check_lock(lock_path):
		return touch_file(lock_path)
	else:
		return False
예제 #2
0
def make_boilerplate():
	if not os.path.exists("sites"):
		print "Run from bench! (sites folder must exist)"
		return
	
	hooks = webnotes._dict()
	for key in ("App Name", "App Title", "App Description", "App Publisher", 
		"App Icon", "App Color", "App Email", "App URL", "App License"):
		hook_key = key.lower().replace(" ", "_")
		hook_val = None
		while not hook_val:
			hook_val = raw_input(key + ": ")
			if hook_key=="app_name" and hook_val.lower().replace(" ", "_") != hook_val:
				print "App Name must be all lowercase and without spaces"
				hook_val = ""
		
		hooks[hook_key] = hook_val
		
	webnotes.create_folder(os.path.join(hooks.app_name, hooks.app_name, hooks.app_name))
	webnotes.create_folder(os.path.join(hooks.app_name, hooks.app_name, "templates"))
	webnotes.create_folder(os.path.join(hooks.app_name, hooks.app_name, "config"))
	touch_file(os.path.join(hooks.app_name, hooks.app_name, "__init__.py"))
	touch_file(os.path.join(hooks.app_name, hooks.app_name, hooks.app_name, "__init__.py"))
	touch_file(os.path.join(hooks.app_name, hooks.app_name, "templates", "__init__.py"))
	touch_file(os.path.join(hooks.app_name, hooks.app_name, "config", "__init__.py"))
	
	with open(os.path.join(hooks.app_name, "MANIFEST.in"), "w") as f:
		f.write(manifest_template.format(**hooks))

	with open(os.path.join(hooks.app_name, ".gitignore"), "w") as f:
		f.write(gitignore_template)

	with open(os.path.join(hooks.app_name, "setup.py"), "w") as f:
		f.write(setup_template.format(**hooks))

	with open(os.path.join(hooks.app_name, "requirements.txt"), "w") as f:
		f.write("webnotes")

	touch_file(os.path.join(hooks.app_name, "README.md"))

	with open(os.path.join(hooks.app_name, "license.txt"), "w") as f:
		f.write("License: " + hooks.app_license)

	with open(os.path.join(hooks.app_name, hooks.app_name, "modules.txt"), "w") as f:
		f.write(hooks.app_name)

	with open(os.path.join(hooks.app_name, hooks.app_name, "hooks.txt"), "w") as f:
		f.write(hooks_template.format(**hooks))

	touch_file(os.path.join(hooks.app_name, hooks.app_name, "patches.txt"))

	with open(os.path.join(hooks.app_name, hooks.app_name, "config", "desktop.py"), "w") as f:
		f.write(desktop_template.format(**hooks))