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
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"]