def _showMessage(self): c.requestIP = request.remote_addr c.maskedFrom = h.maskEmail(c.message.cfrom) c.displayMessage = self._processMsg(c.message) c.copyYear = c.message.tposted.year c.copyName = c.message.cfrom.split("<")[0].strip().replace("\"", "") return render("/message.html")
def index(self, id=None): which = id or "asciipaper" if self._need_refresh("last_rate_check", 15): self._update_exchange_rate() c.bcrate_link = ACCT_URL.get(which, ACCT_URL["asciipaper"]) url = ACCT_URL.get(which, ACCT_URL["asciipaper"]) if self._need_refresh("account_check", 2): resp = requests.get(url) coin_json = resp.json() # Store in session session["workers"] = coin_json["workers"] session["confirmed_nmc_reward"] = float(coin_json["confirmed_nmc_reward"]) session["confirmed_reward"] = float(coin_json["confirmed_reward"]) session["estimated_reward"] = float(coin_json["estimated_reward"]) session["unconfirmed_nmc_reward"] = float(coin_json["unconfirmed_nmc_reward"]) session["unconfirmed_reward"] = float(coin_json["unconfirmed_reward"]) session["hashrate"] = float(coin_json["hashrate"]) c.workers = session.get("workers") c.confirmed_nmc_reward = float(session.get("confirmed_nmc_reward")) c.confirmed_reward = float(session.get("confirmed_reward")) c.estimated_reward = float(session.get("estimated_reward")) c.unconfirmed_nmc_reward = float(session.get("unconfirmed_nmc_reward")) c.unconfirmed_reward = float(session.get("unconfirmed_reward")) c.hashrate = float(session.get("hashrate")) c.exchange_rate = float(session.get("bitcoin_exch_rate", 0)) c.value = c.exchange_rate * c.confirmed_reward c.bcrate_link = BITCOIN_RATE_URL session.save() return render("/bitcoincz.html")
def index(self, id=None): mthd = request.method self._returnHTML = ("html" in request.headers["Accept"]) if mthd == "DELETE": return self._delAlias(id) prefix = request.headers.get("Prefix", "ed") if prefix == "None": # Direct alias self.aliasPattern = self.direct_alias_pattern self.sep = self.direct_sep else: self.aliasPattern = self.user_alias_pattern self.sep = self.user_sep self.sections = self.fulltext.split(self.sep) if id: return self._addAlias(id) c.mailnames = self.sections[1].strip().splitlines() c.post = request.POST if c.post: aliasToDelete = c.post.get("delalias", "") aliasToAdd = c.post.get("newalias", "") if aliasToAdd: return self._addAlias(aliasToAdd) else: return self._delAlias(aliasToDelete) else: c.mailnames.sort() return render("addalias.html")
def full_thread(self, id=None): msgnum = id if msgnum is None: abort(400, "Sorry, a message ID is required.") c.listname = session.get("listname", "") c.url = request.remote_addr c.from_developer = request.remote_addr == h.get_sa_home_ip() kwargs = {"body": {"query": {"match": {"msg_num": msgnum}}}} resp = es_client.search("email", doc_type="mail", **kwargs) recs = extract_records(resp, translate_to_db=False) if not recs: abort(404, "No message with id=%s exists" % msgnum) subj = recs[0]["subject"] pat = re.compile(r"^re: *", re.I) subj = pat.sub("", subj) kwargs = {"body": {"query": {"match_phrase" : {"subject" : subj}}}, "sort": ["posted:asc"]} resp = es_client.search("email", doc_type="mail", **kwargs) c.results = extract_records(resp, translate_to_db=True) c.query_statement = kwargs return render("/full_thread.html") modelSession = model.meta.Session c.error_message = "" c.listname = session.get("listname", "") c.url = request.remote_addr c.from_developer = request.remote_addr == h.get_sa_home_ip() query = modelSession.query(Archive) query = query.filter_by(imsg=id) try: msg = self._query_first(query) except NoResultFound: abort(404, "No message with id=%s exists" % id) try: msgTime = msg.tposted except AttributeError, e: # No message match the subject log.warn("Full thread failed for id=%s" % id) c.results = [] return render("/archive_results.html")
def prove_it(wrong=False): f1 = random.randint(1, 8) f2 = random.randint(1, 8) log.warn("WRONG: %s" % wrong) c.wrong = wrong c.question = "How much is %s + %s?" % (f1, f2) c.expected = f1 + f2 c.url = url return render("/human.html")
def index(self, id=None): c.section = None if id: sectionDict = {"vfp": "v", "python": "p", "dabo": "b", "osx": "x", "cb": "c", "fox": "f", "taskpane": "t", "reportlistener": "r"} nameDict = {"vfp": "Visual FoxPro", "python": "Python", "dabo": "Dabo", "osx": "OS X", "cb": "Codebook", "fox": "FoxPro 2.x", "taskpane": "Taskpane", "reportlistener": "ReportListener"} c.section = unicode(sectionDict.get(id, "o")) c.sectionName = nameDict.get(id, "Other") q = meta.Session.query(model.Download) q = q.filter_by(ctype=c.section) q = q.filter_by(lpublish=1) q = q.order_by(desc("dlastupd")) c.downloads = self._query_all(q) return render("dls.html")
def index(self): params = request.params action = params.get("action", "no action") c.src = params.get("src", "no source") c.campaign = params.get("campaign", "no campaign") c.comment = params.get("comment", "Cool!") if action != "ok": return render("/feedback.html") modelSession = model.meta.Session fb = Feedback() fb.src = c.src fb.campaign = c.campaign fb.comment = c.comment modelSession.save(fb) modelSession.commit() return "<h3>Thanks for your feedback!</h3> Comment Length: %s" % len(c.comment)
def index(self, id=None): which = id or "asciipaper" if self._need_refresh("last_rate_check", 15): self._update_exchange_rate() c.bcrate_link = ACCT_URL.get(which, ACCT_URL["asciipaper"]) url = ACCT_URL.get(which, ACCT_URL["asciipaper"]) if self._need_refresh("account_check", 2): resp = requests.get(url) coin_json = resp.json() # Store in session session["workers"] = coin_json["workers"] session["confirmed_nmc_reward"] = float(coin_json["confirmed_nmc_reward"]) session["confirmed_reward"] = float(coin_json["confirmed_reward"]) session["estimated_reward"] = float(coin_json["estimated_reward"]) session["unconfirmed_nmc_reward"] = float(coin_json["unconfirmed_nmc_reward"]) session["unconfirmed_reward"] = float(coin_json["unconfirmed_reward"]) session["hashrate"] = float(coin_json["hashrate"]) c.workers = session.get("workers") c.confirmed_nmc_reward = float(session.get("confirmed_nmc_reward")) c.confirmed_reward = float(session.get("confirmed_reward")) c.estimated_reward = float(session.get("estimated_reward")) c.unconfirmed_nmc_reward = float(session.get("unconfirmed_nmc_reward")) c.unconfirmed_reward = float(session.get("unconfirmed_reward")) c.hashrate = float(session.get("hashrate")) btc_rate = session.get("btc_rate", 0) try: c.btc_rate = float(btc_rate) except ValueError: c.btc_rate = -0.0 bch_rate = session.get("bch_rate", 0) try: c.bch_rate = float(bch_rate) except ValueError: c.bch_rate = -0.0 c.btc_value = c.btc_rate * c.confirmed_reward c.bcrate_link = BITCOIN_RATE_URL try: session["my_value"] = ((c.btc_rate * BITCOIN_STASH) + (c.bch_rate * BITCOIN_STASH)) except ValueError: session["my_value"] = -42.00 c.my_value = session["my_value"] session.save() return render("/bitcoin.html")
def index(self, key, id): t = datetime.date.today() kv = t.year + t.month + t.day kv2 = kv - 2000 if not int(key) in (kv, kv2): abort(403) pth = "/home/ed/pylons/leafe.com/leafecom/lib/xpw.db" db = sqlite3.connect(pth) crs = db.cursor() search = "%%%s%%" % id sql = """ select pkid, site, user, pw, email, misc from pw where (site like ?) or (misc like ?) """ crs.execute(sql, (search, search)) c.data = crs.fetchall() return render("/vault.html")
def full_thread(self, id=None): if id is None: abort(400, "Sorry, a message ID is required.") modelSession = model.meta.Session c.error_message = "" c.listname = session.get("listname", "") c.url = request.remote_addr c.from_developer = request.remote_addr == h.get_sa_home_ip() query = modelSession.query(Archive) query = query.filter_by(imsg=id) try: msg = self._query_first(query) except NoResultFound: abort(404, "No message with id=%s exists" % id) try: msgTime = msg.tposted except AttributeError, e: # No message match the subject log.warn("Full thread failed for id=%s" % id) c.results = [] return render("/archive_results.html")
def upload(self): c.filename = "" return render ("upload.html")
def index(self): return render("pyexif.html")
def search(self, id=None): c.listname = id c.searchOK = True c.properListName = self._properListName(id) return render("/archives.html")
def index(self): if request.params: return str(request.params) c.listname = c.properListName = "" c.searchOK = True return render("/archives.html")
def index(self): return render("/oauthtest.html")
def test(self): return render("/oauthtest.html")
# modelSession.rollback() # raise session["elapsed"] = c.elapsed = "%.4f" % (time.time() - startTime) c.numResults = len(allrecs) page = int(request.params.get("page", "1")) session["total_pages"] = c.total_pages = int(math.ceil(float(c.numResults) / batchSize)) page = min(page, c.total_pages) session.save() # Get the slice recStart = (batchSize * (page-1)) recEnd = (batchSize * page) - 1 c.page = page c.results = allrecs[recStart:recEnd] return render("/archive_results.html") def _properListName(self, val): return {"profox": "ProFox", "prolinux": "ProLinux", "propython": "ProPython", "valentina": "Valentina", "codebook": "Codebook", "dabo-dev": "Dabo-Dev", "dabo-users": "Dabo-Users"}.get(val, "") def _listAbbreviation(self, val): return {"profox": u"p", "prolinux": u"l", "propython": u"y", "valentina": u"v", "codebook": u"c", "dabo-dev": u"d", "dabo-users": u"u"}.get(val, "") def _cleanSpaces(self, strVal): # Go along the string, and if we are between double quotes, replace any
def index(self, id=None): if id == "resume": return render("/resume.html") else: return render("/consulting.html")
def index(self): return render("/oregon.html")
def index(self): c.reccount = meta.Session.query(MedData).count() return render("medical_entry.html")
def upload_file(self): post = request.POST log.error("%s" % str(post.keys())) newfile = post.get("newfile") if (newfile is None) or not newfile.filename: abort(400, "No file specified") target_file = os.path.join("/var/www/uploads", newfile.filename.replace(os.sep, "_")) file_obj = file(target_file, "wb") shutil.copyfileobj(newfile.file, file_obj) newfile.file.close() file_obj.close() file_size = os.stat(target_file)[stat.ST_SIZE] kbytes = file_size / 1024.0 if kbytes > 1000: fsize = "%.1fMB" % (kbytes / 1024.0) else: fsize = "%.1fK" % kbytes # Don't use the CDN; use the generic download URL that will redirect. cdnBase = "http://c118811.r11.cf0.rackcdn.com" dlBase = "http://leafe.com/download" fldr = {"c": "cb", "d": "dabo"}.get(post["file_section"], "") cfile = os.path.join(dlBase, fldr, newfile.filename) dl = model.Download() dl.ctype = post["file_section"] dl.ctitle = post["file_title"] dl.mdesc = post["file_descrip"] dl.cfile = cfile dl.ccosttype = post["file_license"] dl.ncost = decimal.Decimal(post["file_cost"]) dl.csize = fsize dl.cauthor = post["file_author"] dl.cauthoremail = post["file_email"] dl.dlastupd = datetime.date.today() dl.lpublish = False @h.retry_lost def _add_dl_model(): model.meta.Session.add(dl) model.meta.Session.commit() _add_dl_model() body = """Originating IP = %s Section = %s Title = %s File = %s License = %s Cost = %s Size = %s Author = %s Email = %s Description: %s """ % (request.remote_addr, dl.ctype, dl.ctitle, dl.cfile, dl.ccosttype, dl.ncost, dl.csize, dl.cauthor, dl.cauthoremail, dl.mdesc) msg = """From: File Uploads <*****@*****.**> X-Mailer: pylons script To: Ed Leafe <*****@*****.**> Subject: New Uploaded File Date: %s %s """ % (time.strftime("%c"), body) smtp = smtplib.SMTP("localhost") smtp.sendmail("*****@*****.**", "*****@*****.**", msg) c.filename = newfile.filename c.filesize = fsize c.email = dl.cauthoremail return render("upload.html")
def index(self): return render("lists.html")
def index(self): return render("profox_faq.html")
def index(self): return render("/dan.html")