本文整理汇总了Python中tinyms.core.common.Utils.mkdirs方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.mkdirs方法的具体用法?Python Utils.mkdirs怎么用?Python Utils.mkdirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinyms.core.common.Utils
的用法示例。
在下文中一共展示了Utils.mkdirs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pack_client
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import mkdirs [as 别名]
def pack_client(self):
user_id = self.get_current_user()
root_path = self.get_webroot_path()
download_path = root_path + "/download/validwork/"
Utils.mkdirs(download_path)
client_zip_name = download_path + Utils.md5("%i_client" % user_id) + ".zip"
key_file_name = download_path + Utils.md5("%i_keyfile" % user_id)
ip_file_name = download_path + "ip.txt"
exe_file_name = download_path + "FingerTemplateHelper.exe"
libcurl = download_path + "libcurl.dll"
zlib1 = download_path + "zlib1.dll"
if os.path.exists(key_file_name):
os.remove(key_file_name)
key = self.kengen()
Utils.text_write(key_file_name, [key], "")
if not os.path.exists(ip_file_name):
Utils.text_write(ip_file_name, [self.request.host], "")
if os.path.exists(client_zip_name):
os.remove(client_zip_name)
f = ZipFile(client_zip_name, "w")
self.compress(f, ip_file_name, "ip.txt")
self.compress(f, key_file_name, "temp.key")
self.compress(f, exe_file_name, "指纹采集助手.exe")
self.compress(f, libcurl, "libcurl.dll")
self.compress(f, zlib1, "zlib1.dll")
f.close()
return client_zip_name
示例2: post
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import mkdirs [as 别名]
def post(self, *args, **kwargs):
self.set_header("Content-Type", "text/json;charset=utf-8")
#build path
upload_path = "/upload/%s/%s" % (Utils.format_year_month(Utils.current_datetime()),
Utils.current_datetime().date().day)
path = self.get_webroot_path() + upload_path
Utils.mkdirs(path)
files = self.request.files
items = list()
for key in files:
item = dict()
meta = files[key]
file_name = meta["filename"]
ext_name = os.path.splitext(file_name)
name_ = Utils.uniq_index()
if not ext_name:
new_file_name = name_
else:
new_file_name = "%s.%s" % (name_, ext_name)
save_path = "%s/%s" % (path, new_file_name)
with open(save_path, "wb") as uploader:
uploader.write(meta["body"])
item["local_name"] = file_name
item["ext_name"] = ext_name
item["upload_path"] = "%s/%s" % (upload_path, new_file_name)
item["archives_id"] = self.get_current_user()
items.append(item)
self.write(Utils.encode(["OK"]))
示例3: create
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import mkdirs [as 别名]
def create(self):
if not ObjectPool.mode_dev:
return ["failure"]
name = self.param("name")
if not name:
return ["failure"]
abs_path = self.request.get_webroot_path()
tpl_path = abs_path + "templates/" + name + "/"
Utils.mkdirs(tpl_path)
page_html_file = tpl_path + "/page.html"
if not os.path.exists(page_html_file):
Utils.text_write(page_html_file, ProjectApi.create_page_template())
Utils.mkdirs(abs_path + name)
#create __init__.py
items = list()
pack_file = abs_path + name + "/__init__.py"
if not os.path.exists(pack_file):
items.append("from %s.entity import *" % name)
items.append("from %s.controller import *" % name)
items.append("from %s.dao import *" % name)
items.append("from %s.common import *" % name)
Utils.text_write(pack_file, items)
#create sample py, example: controller.py, dao.py, common.py, entity.py
items.clear()
controller_file = abs_path + name + "/controller.py"
if not os.path.exists(controller_file):
items.append("from tinyms.core.common import Utils")
items.append("from tinyms.core.web import IAuthRequest")
items.append("from tinyms.core.annotation import route, ui")
Utils.text_write(controller_file, items)
items.clear()
dao_file = abs_path + name + "/dao.py"
if not os.path.exists(dao_file):
items.append("from tinyms.core.common import Utils")
items.append("from sqlalchemy import func, or_, cast")
items.append("from tinyms.core.orm import SessionFactory")
pkg = "from tinyms.core.annotation import autocomplete, datatable_provider, dataview_provider, ajax, api"
items.append(pkg)
Utils.text_write(dao_file, items)
items.clear()
common_file = abs_path + name + "/common.py"
if not os.path.exists(common_file):
items.append("from tinyms.core.common import Utils")
items.append("from tinyms.core.annotation import reg_point, points, setting, server_starup")
Utils.text_write(common_file, items)
items.clear()
entity_file = abs_path + name + "/entity.py"
if not os.path.exists(entity_file):
a = "from sqlalchemy import Column, Integer, String, DateTime, Text, Date, Numeric"
b = "from tinyms.core.orm import Entity, Simplify, many_to_one, many_to_many"
items.append(a)
items.append(b)
Utils.text_write(entity_file, items)
return ["success"]