def getReleaseVersion(): ver = "%s"%( getCurrentTime("%Y%m%d%H%M%S%f") ) release_path = app.config.get('RELEASE_PATH') if release_path and os.path.exists( release_path ): with open(release_path,'r') as f: ver=f.readline() return ver
def reg(): if request.method == "GET": return ops_render("member/reg.html") req = request.values nickname = req['nickname'] if "nickname" in req else "" login_name = req['login_name'] if "login_name" in req else "" login_pwd = req['login_pwd'] if "login_pwd" in req else "" login_pwd2 = req['login_pwd2'] if "login_pwd2" in req else "" if login_name is None or len(login_name) < 1: return ops_renderErrJSON(msg="请输入正确的登录用户名~~") if login_pwd is None or len(login_pwd) < 6: return ops_renderErrJSON(msg="请输入正确的登录密码,并且不能小于6个字符~~") if login_pwd != login_pwd2: return ops_renderErrJSON(msg="请输入正确的确认登录密码~~") user_info = User.query.filter_by(login_name=login_name).first() if user_info: return ops_renderErrJSON(msg="登录用户名已被注册,请换一个~~") model_user = User() model_user.login_name = login_name model_user.nickname = nickname if nickname is not None else login_name model_user.login_salt = UserService.geneSalt(8) model_user.login_pwd = UserService.genePwd(login_pwd, model_user.login_salt) model_user.created_time = model_user.updated_time = getCurrentTime() db.session.add(model_user) db.session.commit() return ops_renderJSON(msg="注册成功~~")
def reg(): if request.method == "GET": return ops_render("member/reg.html") req = request.values # 如果值在里面则取,不在则取空 login_name = req['login_name'] if "login_name" in req else "" login_pwd = req['login_pwd'] if "login_pwd" in req else "" login_pwd2 = req['login_pwd2'] if "login_pwd2" in req else "" #后端输入验证 if login_name is None or len(login_name) < 1: return ops_renderErrorJSON(msg="请输入正确的管理员账户名") if login_pwd is None or len(login_pwd) < 6: return ops_renderErrorJSON(msg="请正确输入管理员账户密码,并且不能小于6个字符!") if login_pwd != login_pwd2: return ops_renderErrorJSON(msg="请确认管理员账户密码!") #后端数据库信息验证 user_info = User.query.filter_by(login_name=login_name).first() if user_info: return ops_renderErrorJSON(msg="此管理员账户名已存在,请重新输入!") model_user = User() #model实例化 model_user.login_name = login_name model_user.login_salt = UserService.geneSalt(8) model_user.login_pwd = UserService.genePwd(login_pwd, model_user.login_salt) model_user.created_time = model_user.updated_time = getCurrentTime() db.session.add(model_user) db.session.commit() return ops_renderJSON(msg="注册提交成功,等待审核!")
def reg(): if request.method == 'GET': return ops_render('member/reg.html') req = request.values login_name = req['login_name'] if 'login_name' in req else '' login_pwd = req['login_pwd'] if 'login_pwd' in req else '' login_pwd2 = req['login_pwd2'] if 'login_pwd2' in req else '' if not login_name or len(login_name) < 1: return ops_renderErrJSON(msg="Please input correct username!") if not login_pwd or len(login_pwd) < 6: return ops_renderErrJSON( msg="Please input correct password! At least 6 characters!") if login_pwd != login_pwd2: return ops_renderErrJSON( msg="Password not match!Please check and input again!") user_info = User.query.filter_by(login_name=login_name).first() if user_info: return ops_renderErrJSON(msg="Username already exist!") model_user = User() model_user.login_name = login_name model_user.nickname = login_name model_user.login_salt = UserService.genSalt(8) model_user.login_pwd = UserService.genePwd(login_pwd, model_user.login_salt) model_user.created_time = model_user.updated_time = getCurrentTime() db.session.add(model_user) db.session.commit() return ops_renderJSON(msg="Register Success!")
def reg(): if request.method == "GET": return render_template("member/reg.html") req = request.values login_name = req["login_name"] if "login_name" in req else "" login_pwd = req["login_pwd"] if "login_pwd" in req else "" login_pwd2 = req["login_pwd2"] if "login_pwd2" in req else "" if login_name is None or len(login_name) < 1: return ops_renderErrJSON(msg="请输入正确的登陆用户名~~") if login_pwd is None or len(login_pwd) < 6: return ops_renderErrJSON(msg="请你输入正确的登陆秘密,并且不能小于6个字符~~") if login_pwd != login_pwd2: return ops_renderErrJSON(msg="请确认你的登陆秘密是否一致~~") user_info = User1.query.filter_by(login_name=login_name).first() if user_info: return ops_renderErrJSON(msg="登陆用户名被注册,请换一个~~") model_user = User1() model_user.login_name = login_name model_user.nickname = login_name model_user.login_salt = UserService.geneSalt(8) model_user.login_pwd = UserService.genePwd(login_pwd, model_user.login_salt) model_user.created_time = model_user.updated_time = getCurrentTime() db.session.add(model_user) db.session.commit() return ops_renderJSON(msg="注册成功~~")
def run(self, params): act = params['act'] self.date = getCurrentTime(frm="%Y%m%d") if act == "list": self.getList() self.parseInfo() elif act == "parse": self.parseInfo()
def getReleaseVersion(): ''' 版本管理 开发模式 使用时间作为我们的版本号 生产环境 使用版本文件进行管理,覆盖开发模式的值 :return: ''' ver = "%s" % (getCurrentTime("%Y%m%d%H%M%S%f")) release_path = app.config.get('RELEASE_PATH') if release_path and os.path.exists(release_path): with open(release_path, 'r') as f: ver = f.readline() return ver
def goods_add_page(): if request.method == "GET": return ops_render("func/goods_add.html") req = request.values # 如果值在里面则取,不在则取空 title = req['title'] if "title" in req else "" brand = req['brand'] if "brand" in req else "" arctic = req['arctic'] if "arctic" in req else "" regist_date = req['regist_date'] if "regist_date" in req else "" mileage = req['mileage'] if "mileage" in req else "" emissions = req['emissions'] if "emissions" in req else "" gear = req['gear'] if "gear" in req else "" price = req['price'] if "price" in req else "" cars_local = req['cars_local'] if "cars_local" in req else "" describe = req['describe'] if "describe" in req else "" img_desc = req['img_desc'] if "img_desc" in req else "" picture2 = req['picture2'] if "picture2" in req else "" picture3 = req['picture3'] if "picture3" in req else "" picture4 = req['picture4'] if "picture4" in req else "" picture5 = req['picture5'] if "picture5" in req else "" picture6 = req['picture6'] if "picture6" in req else "" picture1 = req['picture1'] if "picture1" in req else "" model_cars_info = CarsInfo() # model实例化 model_cars_info.title = title model_cars_info.describe = describe model_cars_info.picture3 = picture3 model_cars_info.picture1 = picture1 model_cars_info.img_desc = img_desc model_cars_info.picture6 = picture6 model_cars_info.picture5 = picture5 model_cars_info.cars_local = cars_local model_cars_info.picture4 = picture4 model_cars_info.picture2 = picture2 model_cars_info.price = price model_cars_info.mileage = mileage model_cars_info.gear = gear model_cars_info.emissions = emissions model_cars_info.brand = brand model_cars_info.arctic = arctic model_cars_info.regist_date = regist_date model_cars_info.created_date = getCurrentTime() db.session.add(model_cars_info) db.session.commit() return ops_renderJSON(msg="提交成功!") name = "imooc" context = {"name": name} return ops_render("func/goods_add.html", context)
def parseInfo(self): config = self.url path_root = config['path'] + self.date path_info = path_root + '/info' path_json = path_root + '/json' path_vid = path_root + '/vid' for filename in os.listdir(path_info): tmp_json_path = path_json + '/' + filename tmp_info_path = path_info + '/' + filename tmp_vid_path = path_vid + '/' + filename tmp_data = json.loads(self.getContent(tmp_json_path), encoding='utf-8') tmp_content = self.getContent(tmp_info_path) tmp_soup = BeautifulSoup(tmp_content, 'html.parser') try: tmp_pub_date = tmp_soup.select('div.vod div.vod_intro dl dd')[0].getText() tmp_desc = tmp_soup.select('div.vod div.vod_intro div.des')[0].getText() tmp_classify = tmp_soup.select('div.vod div.vod_intro dl dd')[2].getText() tmp_actor = tmp_soup.select('div.vod div.vod_intro dl dd')[6].getText() tmp_pic_list = tmp_soup.select('div.vod div.vod_img img') tmp_pics = [] for tmp_pic in tmp_pic_list: tmp_pics.append(tmp_pic['src']) tmp_download_content = self.getContent(tmp_vid_path) tmp_vid_soup = BeautifulSoup(tmp_download_content, 'html.parser') tmp_download_list = tmp_vid_soup.findAll('a', href=re.compile('magnet:?')) tmp_magnet_url = '' if tmp_download_list: tmp_magnet_url = tmp_download_list[0]['href'] tmp_data['pub_date'] = tmp_pub_date tmp_data['desc'] = tmp_desc tmp_data['classify'] = tmp_classify tmp_data['actor'] = tmp_actor tmp_data['magnet_url'] = tmp_magnet_url tmp_data['source'] = self.source tmp_data['created_time'] = tmp_data['updated_time'] = getCurrentTime() if tmp_pics: tmp_data['cover_pic'] = tmp_pics[0] tmp_data['pics'] = json.dumps(tmp_pics) tmp_movie_info = Movie.query.filter_by(hash = tmp_data['hash']).first() if tmp_movie_info: continue tmp_model_movie = Movie(**tmp_data) db.session.add(tmp_model_movie) db.session.commit() except: continue return True
def news_add_page(): if request.method == "GET": return ops_render("func/news_add.html") req = request.values # 如果值在里面则取,不在则取空 news_title = req['news_title'] if "news_title" in req else "" news_img = req['news_img'] if "news_img" in req else "" news_src = req['news_src'] if "news_src" in req else "" news_desc = req['news_desc'] if "news_desc" in req else "" model_news = News() #model实例化 model_news.news_title = news_title model_news.news_img = news_img model_news.news_src = news_src model_news.news_desc = news_desc model_news.created_date = getCurrentTime() db.session.add(model_news) db.session.commit() return ops_renderJSON(msg="提交成功!")
def registered(): if request.method == "GET": return render_template("Registered_page.html") form = Register(request.form) if form.validate(): # 将用户信息注册进数据库 model_user = User() model_user.login_name = form.username.data # 使用加密方法存储密码 model_user._login_pwd = generate_password_hash(form.password.data) model_user.created_time = model_user.updated_time = getCurrentTime() try: db.session.add(model_user) db.session.commit() except Exception as error: return ops_renderErrJSON(msg=str(error)) else: return ops_renderJSON(msg="注册成功~~") else: # 返回表单验证中的错误信息 return ops_renderJSON(msg=str(form.errors))
def parseInfo(self): config = self.url path_root = config['path'] + self.date path_info = path_root + "/info" path_json = path_root + "/json" # path_vid = path_root + "/vid" for filename in os.listdir(path_info): tmp_json_path = path_json + "/" + filename tmp_info_path = path_info + "/" + filename # tmp_vid_path = path_vid + "/" + filename tmp_data = json.loads(self.getContent(tmp_json_path), encoding="UTF-8") tmp_content = self.getContent(tmp_info_path) # app.logger.info(tmp_data) # exit() tmp_soup = BeautifulSoup(tmp_content, "html.parser") try: tmp_pub_date = tmp_soup.select( "div.book-last-chapter div.lastchapter span")[2].getText() app.logger.info(tmp_pub_date) # exit(0) tmp_desc = tmp_soup.select( "div.book-info div.book-info-bookintro")[0].getText() app.logger.info(tmp_desc) # exit(0) tmp_classify = tmp_soup.select( "div.book-info div.book-info-bookstate")[0].getText() app.logger.info(tmp_classify) # exit(0) tmp_actor = tmp_soup.select( "div.book-info div.book-info-bookname span")[1].getText() app.logger.info(tmp_actor) # exit(0) tmp_pic_list = tmp_soup.select( "div.book-info div.book-cover-wrapper img") tmp_pics = [] for tmp_pic in tmp_pic_list: tmp_pics.append(tmp_pic['data-original']) app.logger.info(tmp_pics) # exit(0) #获取下载地址 # tmp_download_content = self.getContent( tmp_vid_path ) # tmp_vid_soup = BeautifulSoup( tmp_download_content ,"html.parser") # tmp_download_list = tmp_vid_soup.findAll( "a",href = re.compile( "magnet:?" ) ) # tmp_magnet_url = "" # if tmp_download_list: # tmp_magnet_url = tmp_download_list[0]['href'] tmp_data['pub_date'] = tmp_pub_date tmp_data['desc'] = tmp_desc tmp_data['classify'] = tmp_classify tmp_data['actor'] = tmp_actor # tmp_data['magnet_url'] = tmp_magnet_url tmp_data['source'] = self.source tmp_data['created_time'] = tmp_data[ 'updated_time'] = getCurrentTime() if tmp_pics: tmp_data['cover_pic'] = tmp_pics[0] tmp_data['pics'] = json.dumps(tmp_pics) app.logger.info(tmp_data) tmp_novel_info = Novel.query.filter_by( hash=tmp_data['hash']).first() if tmp_novel_info: continue tmp_model_movie = Novel(**tmp_data) db.session.add(tmp_model_movie) db.session.commit() except: continue return True