def init_sites(self): ''' 初始化将所有的站点数据保存在sites中 ''' site_db = Site_Model(); query = site_db.select(); r = query.list(); for site in r: if site and "id" in site: self.sites[site["id"]] = Site(site)
def init_sites(self): ''' 初始化将所有的站点数据保存在sites中 ''' site_db = Site_Model() query = site_db.select() r = query.list() for site in r: if site and "id" in site: self.sites[site["id"]] = Site(site)
def index(): data = 0 sites = Site(current_app) site = sites.totalcount() seeds = Seed(current_app) seed = seeds.totalcount() users = User(current_app) uid = session['uid'] user = users.view(uid) lastlogin = user[0]["lastlogintime"] return render_template("index.html", site=site, seed=seed, data=data, lastlogin=lastlogin)
def edit(site_id): site = Site(current_app) hook_funcs = []; attrs = dir(hooks); for attr in attrs: if attr.find("__") == -1: hook_funcs.append(attr) if request.method == "POST": name = request.form.get("name") url = request.form.get("url") descript = request.form.get("descript") sync_type = request.form.get("sync_type") if not name: error = "请输入站点名称" elif not url: error = "请输入站点链接" elif not sync_type: error = "请选择入库方式" else: site = Site(current_app) sync_profile = { "staticUrl": request.form.get("staticUrl"), "staticType": request.form.get("staticType"), "mysql_server": request.form.get("mysql_server"), "mysql_dbname": request.form.get("mysql_dbname"), "mysql_prefix": request.form.get("mysql_prefix"), "mysql_username": request.form.get("mysql_username"), "mysql_password": request.form.get("mysql_password"), "ftp_server": request.form.get("ftp_server"), "ftp_port": request.form.get("ftp_port"), "ftp_path": request.form.get("ftp_path"), "ftp_username": request.form.get("ftp_username"), "ftp_password": request.form.get("ftp_password"), "access_id": request.form.get("access_id"), "secret_access_key": request.form.get("secret_access_key"), "hook_func": request.form.get("hook_func"), "api_url": request.form.get("api_url") } sync_profile = phpserialize.dumps(sync_profile) site.edit(id=site_id, name=name, url=url, descript=descript, sync_type=sync_type, sync_profile=sync_profile) return redirect(url_for('sites.index')) per = site.view(site_id)[0] if per["sync_profile"]: per["sync_profile"] = phpserialize.loads(per["sync_profile"]) field = Field(current_app) types = field.getSeedType() site_map = Site_map(current_app) website_maps = site_map.list(site_id) maps = {} for website_map in website_maps: if website_map["seed_type"] not in maps: maps[website_map["seed_type"]] = website_map return render_template("site/add.html", site=per, types=types, maps=maps, hook_funcs=hook_funcs)
def add(): error = None site = {} site["sync_profile"] = {} hook_funcs = []; attrs = dir(hooks); for attr in attrs: if attr.find("__") == -1: hook_funcs.append(attr) if request.method == "POST": name = request.form.get("name") url = request.form.get("url") descript = request.form.get("descript") sync_type = request.form.get("sync_type") if not name: error = "请输入站点名称" elif not url: error = "请输入站点链接" elif not sync_type: error = "请选择入库方式" else: site = Site(current_app) sync_profile = { "staticUrl": request.form.get("staticUrl"), "staticType": request.form.get("staticType"), "mysql_server": request.form.get("mysql_server"), "mysql_dbname": request.form.get("mysql_dbname"), "mysql_prefix": request.form.get("mysql_prefix"), "mysql_username": request.form.get("mysql_username"), "mysql_password": request.form.get("mysql_password"), "ftp_server": request.form.get("ftp_server"), "ftp_port": request.form.get("ftp_port"), "ftp_path": request.form.get("ftp_path"), "ftp_username": request.form.get("ftp_username"), "ftp_password": request.form.get("ftp_password"), "access_id": request.form.get("access_id"), "secret_access_key": request.form.get("secret_access_key"), "hook_func": request.form.get("hook_func"), "api_url": request.form.get("api_url") } sync_profile = phpserialize.dumps(sync_profile) id = site.add(name=name, url=url, descript=descript, sync_type=sync_type, sync_profile=sync_profile) if id > 0: return redirect(url_for('sites.index')) else: error = "error" return render_template("site/add.html", error=error, site=site, hook_funcs=hook_funcs)
def index(page=1): site = Site(current_app) filte = None if request.method == "POST": error = None action = request.form.get("do") if action == "delete": uids = request.form.getlist("id[]") if len(uids) > 0: for uid in uids: if uid: site.remove(uid) return redirect(url_for("sites.index")) else: error = "请选择要删除的数据" return error if request.args.get("keywords"): filte = "name='" + request.args.get("keywords") + "'" sites = site.list(page, PER_PAGE, filte) if not sites and page != 1: abort(404) count = site.totalcount() pagination = Pagination(page, PER_PAGE, count) return render_template("site/list.html", pagination=pagination, sites=sites)
from web.models import Site data_path = '/var/www/rnaedit/data/redi_hg38.txt' with open(data_path, 'r') as f: headers = f.readline() for line in f: d = line.rstrip().split('\t') tg = Site() if d[3] == '+': tg.strand = True tg.ref = 'A' tg.ed = 'G' else: tg.strand = False tg.ref = 'T' tg.ed = 'C' tg.key = d[1] + '_' + str(d[2]) + d[3] tg.chromo = d[1] tg.loc = d[2] tg.redi = True tg.hyper = False tg.save()