def post(self): self.require_login() pdfmark = ''.join(self.get_arguments('pdfmark')).encode('utf8') remarks = ''.join(self.get_arguments('remarks')).encode('utf8') pdf = db.mdb('topdf', 'pdf').perform() user = (lambda: self.get_cookie('username') and self.get_cookie( 'username') or self.get_cookie('account'))() _pdf = pdf.find_one({'pdf': pdfmark}) if _pdf['pdf'] == None: self.write('f') return if self.get_cookie('username'): if _pdf['username'] != user: self.write('f') else: pdf.update({'pdf': pdfmark}, {'$set': {'remark': remarks}}) # set cache else: if _pdf['account'] != user: self.write('f') else: pdf.update({'pdf': pdfmark}, {'$set': {'remark': remarks}}) # set cache self.write('t')
def topdf(self): # self.f_pdf = os.path.join('static/pdf', self.fileExt+'.pdf') # self.filename = os.path.join('static/img',self.fileExt + '.jpg') self.f_pdf = self.fileExt + '.pdf' self.filename = self.fileExt + '.jpg' w = 612.0 h = w * self.height / self.width self.codes = "".join(unquote(self.base64img).split(',')[1:]) # static file (CDN) img = open(self.filename, 'wb') img.write(base64.b64decode(self.codes)) img.close() sd = img2pdf.convert([StringIO.StringIO(base64.b64decode(self.codes))], 150, x=620, y="") hand = open(self.f_pdf, 'wb') hand.write(sd) hand.close() #self.save_pdf() pdfexsit = db.mdb('topdf', 'pdfexsit').perform() pdfexsit.insert({'pdf': self.fileExt}) return self.f_pdf
def post(self): pdfcode = self.get_argument('pdfcode') pdfexsit = db.mdb('topdf', 'pdfexsit').perform() if pdfexsit.find_one({'pdf': pdfcode}) == None: self.write('f') else: self.write('t')
def post(self): self.require_login() pdfmark = ''.join(self.get_arguments('pdfmark')).encode('utf8') remarks = ''.join(self.get_arguments('remarks')).encode('utf8') pdf = db.mdb('topdf', 'pdf').perform() user = (lambda: self.get_cookie('username') and self.get_cookie('username') or self.get_cookie('account'))() _pdf = pdf.find_one({'pdf': pdfmark}) if _pdf['pdf'] == None: self.write('f') return if self.get_cookie('username'): if _pdf['username'] != user: self.write('f') else: pdf.update({'pdf': pdfmark}, {'$set': {'remark': remarks}}) # set cache else: if _pdf['account'] != user: self.write('f') else: pdf.update({'pdf': pdfmark}, {'$set': {'remark': remarks}}) # set cache self.write('t')
def __init__(self,userdetails): self.muser = userdetails[0] self.muser_id = userdetails[1] print(self.muser) d = mdb() self._conn = d.get_con() self._db = self._conn.telegram
def get(self, input): if input == 'github': data = { 'client_id': GITHUB_CLIENT_ID, 'client_secret' : GITHUB_CLIENT_SECRRET } data['code'] = ''.join(self.get_arguments('code')) headers = {'Accept': 'application/json'} token = requests.post(GITHUB_TOKEN, data=data, headers = headers).json() user = requests.get(GITHUB_API + token['access_token'], headers = headers).json() self.set_cookie("username", user['login']) users = db.mdb('topdf', 'user').perform() if users.find_one({'username': user['login']}) == None: users.insert({'username': user['login'], 'token': token['access_token'], 'oauth':'github'}) else: users.update({'username': user['login'], 'oauth': 'github'},{'$set': { 'token': token['access_token']} }) self.redirect('/people') elif input == 'douban': data = { 'client_id': DOUBAN_CLIENT_ID, 'client_secret' : DOUBAN_CLIENT_SECRECT, 'redirect_uri': DOUBAN_REDIRECT_URI, 'grant_type': 'authorization_code' } data['code'] = ''.join(self.get_arguments('code')).encode('utf8') headers = {'Accept': 'application/json'} token = requests.post(DOUBAN_TOKEN, data=data, headers = headers).json() self.set_cookie("username", token['douban_user_name'].encode('utf8')) users = db.mdb('topdf', 'user').perform() if users.find_one({'username': token['douban_user_name']}) == None: users.insert({'username': token['douban_user_name'], 'token': token['access_token'], 'oauth':'github'}) else: users.update({'username': token['douban_user_name'], 'oauth': 'github'},{'$set': { 'token': token['access_token']} }) self.redirect('/people') else: self.redirect('/login')
def post(self): self.require_login() pdfmark = ''.join(self.get_arguments('pdfmark')).encode('utf8') user = (lambda: self.get_cookie('username') and self.get_cookie('username') or self.get_cookie('account'))() pdf = db.mdb('topdf', 'pdf').perform() pdfexsit = db.mdb('topdf', 'pdfexsit').perform() _pdf = pdf.find_one({'pdf': pdfmark}) if _pdf['pdf'] == None: self.write('f') return if self.get_cookie('username') and _pdf['username'] == user: pdf.remove({'pdf': _pdf['pdf']}) pdfexsit.remove({'pdf': _pdf['pdf']}) else: pdf.remove({'pdf': _pdf['pdf']}) pdfexsit.remove({'pdf': _pdf['pdf']}) self.write('t')
def post(self): self.require_login() pdfmark = ''.join(self.get_arguments('pdfmark')) user = (lambda: self.get_cookie('username') and self.get_cookie('username') or self.get_cookie('account'))() pdflist = db.mdb('topdf', 'pdf').perform() if self.get_cookie('username'): pdflist.insert({'username': user, 'pdf': pdfmark}) else: pdflist.insert({'account': user, 'pdf': pdfmark}) self.write('t')
def post(self): self.require_login() pdfmark = ''.join(self.get_arguments('pdfmark')) user = (lambda: self.get_cookie('username') and self.get_cookie( 'username') or self.get_cookie('account'))() pdflist = db.mdb('topdf', 'pdf').perform() if self.get_cookie('username'): pdflist.insert({'username': user, 'pdf': pdfmark}) else: pdflist.insert({'account': user, 'pdf': pdfmark}) self.write('t')
def post(self): self.require_login() pdfmark = ''.join(self.get_arguments('pdfmark')).encode('utf8') user = (lambda: self.get_cookie('username') and self.get_cookie( 'username') or self.get_cookie('account'))() pdf = db.mdb('topdf', 'pdf').perform() pdfexsit = db.mdb('topdf', 'pdfexsit').perform() _pdf = pdf.find_one({'pdf': pdfmark}) if _pdf['pdf'] == None: self.write('f') return if self.get_cookie('username') and _pdf['username'] == user: pdf.remove({'pdf': _pdf['pdf']}) pdfexsit.remove({'pdf': _pdf['pdf']}) else: pdf.remove({'pdf': _pdf['pdf']}) pdfexsit.remove({'pdf': _pdf['pdf']}) self.write('t')
def post(self): account = "".join(self.get_arguments("account")) password = hashlib.sha1("".join(self.get_arguments("password"))).hexdigest() users = db.mdb("topdf", "user").perform() _user = users.find_one({"account": account}) if _user == None: users.insert({"account": account, "password": password}) self.set_cookie("account", account) self.redirect("/people") else: self.redirect("/join")
def get(self, input): if input == "github": data = {"client_id": GITHUB_CLIENT_ID, "client_secret": GITHUB_CLIENT_SECRRET} data["code"] = "".join(self.get_arguments("code")) headers = {"Accept": "application/json"} token = requests.post(GITHUB_TOKEN, data=data, headers=headers).json() user = requests.get(GITHUB_API + token["access_token"], headers=headers).json() self.set_cookie("username", user["login"]) users = db.mdb("topdf", "user").perform() if users.find_one({"username": user["login"]}) == None: users.insert({"username": user["login"], "token": token["access_token"], "oauth": "github"}) else: users.update({"username": user["login"], "oauth": "github"}, {"$set": {"token": token["access_token"]}}) self.redirect("/people") elif input == "douban": data = { "client_id": DOUBAN_CLIENT_ID, "client_secret": DOUBAN_CLIENT_SECRECT, "redirect_uri": DOUBAN_REDIRECT_URI, "grant_type": "authorization_code", } data["code"] = "".join(self.get_arguments("code")).encode("utf8") headers = {"Accept": "application/json"} token = requests.post(DOUBAN_TOKEN, data=data, headers=headers).json() self.set_cookie("username", token["douban_user_name"].encode("utf8")) users = db.mdb("topdf", "user").perform() if users.find_one({"username": token["douban_user_name"]}) == None: users.insert({"username": token["douban_user_name"], "token": token["access_token"], "oauth": "github"}) else: users.update( {"username": token["douban_user_name"], "oauth": "github"}, {"$set": {"token": token["access_token"]}}, ) self.redirect("/people") else: self.redirect("/login")
def post(self): account = ''.join(self.get_arguments('account')) password = hashlib.sha1(''.join(self.get_arguments('password'))).hexdigest() users = db.mdb('topdf', 'user').perform() print type('account') _user = users.find_one({'account': account}) if _user == None: self.redirect('/login') elif _user['password'] != password: self.redirect('/login') else: self.set_cookie('account', account) self.redirect('/people')
def get(self): self.require_login() user = (lambda: self.get_cookie('username') and self.get_cookie('username') or self.get_cookie('account'))() pdflist = db.mdb('topdf', 'pdf').perform() if self.get_cookie('username'): _lists = pdflist.find({'username': user}) lists = [] for i in _lists: if 'remark' in i: lists.append([i['remark'], i['pdf']]) else: lists.append(['', i['pdf']]) self.write(json.dumps({'pdflist': lists})) else: _lists = pdflist.find({'account': user}) lists = [] for i in _lists: if 'remark' in i: lists.append([i['remark'], i['pdf']]) else: lists.append(['', i['pdf']]) self.write(json.dumps({'pdflist': lists}))
def topdf(self): # self.f_pdf = os.path.join('static/pdf', self.fileExt+'.pdf') # self.filename = os.path.join('static/img',self.fileExt + '.jpg') self.f_pdf = self.fileExt+'.pdf' self.filename = self.fileExt + '.jpg' w = 612.0 h = w * self.height / self.width self.codes = "".join(unquote(self.base64img).split(',')[1:]) # static file (CDN) img = open(self.filename,'wb') img.write(base64.b64decode(self.codes)) img.close() sd = img2pdf.convert([StringIO.StringIO(base64.b64decode(self.codes))], 150, x=620, y="") hand = open(self.f_pdf, 'wb') hand.write(sd) hand.close() #self.save_pdf() pdfexsit = db.mdb('topdf', 'pdfexsit').perform() pdfexsit.insert({'pdf':self.fileExt}) return self.f_pdf
def get(self): self.require_login() user = (lambda: self.get_cookie('username') and self.get_cookie( 'username') or self.get_cookie('account'))() pdflist = db.mdb('topdf', 'pdf').perform() if self.get_cookie('username'): _lists = pdflist.find({'username': user}) lists = [] for i in _lists: if 'remark' in i: lists.append([i['remark'], i['pdf']]) else: lists.append(['', i['pdf']]) self.write(json.dumps({'pdflist': lists})) else: _lists = pdflist.find({'account': user}) lists = [] for i in _lists: if 'remark' in i: lists.append([i['remark'], i['pdf']]) else: lists.append(['', i['pdf']]) self.write(json.dumps({'pdflist': lists}))
def get(self): users = db.mdb("topdf", "user").perform() print list(users.find()) self.write("1")
def get(self): users = db.mdb('topdf', 'user').perform() print list(users.find()) self.write('1')
def __init__(self): d = mdb() self._conn = d.get_con() self._db = self._conn.telegram
from telegram_bot import poster from medium_check import medium_parser import time from db import mdb d = mdb() _conn = d.get_con() p = poster() try: cursor = _conn.telegram.medium_users.find({"mstatus": 1}, { "_id": 1, "medium_id": 1 }) for user in cursor: mp = medium_parser([user["medium_id"], user["_id"]]) result = mp.get_new_pubs() if len(result) > 0: for post in result: url = mp.get_post_url(post) p.send_message(url) time.sleep(2) mp.insert_new_pubs(result) except Exception as e: print("Unexpected exception - mcronpy", type(e), e)