def main(): # Arguments: form = cgi.FieldStorage() sn = cgi.escape(form.getvalue('serial_num')) # This is coming from a form. cardid = cgi.escape(form.getvalue('card_id')) person_id = base.cleanCGInumber(form.getvalue('person_id')) db = settings.get_db() note = cgi.escape(form.getvalue('note')) if form.getvalue('note') else False # base.begin() # print person_id # print note # base.bottom() if not person_id: base.error(db, "You must select a tester to be associated with this note.") else: if not note: base.error(db, "You left the note field empty. You're not allowed to make an empty note.") else: # Begin: base.begin() base.header_redirect("module.py?db={0}&card_id={1}#notes".format(db, cardid)) base.top(db) # Add note: result = add_note(db, sn, note, person_id) if result: print "added note:<br>" print note # base.header_redirect_module_notes(card_id, serial_num) base.bottom()
def ReComputeFlowWay(self, way): computed = list() computed_addr = way[0][1] for b, s, e in way: if computed_addr < e: computed_addr = e computed_flow = self.ComputeFlow(s, e) if len(computed_flow) == 1: computed.append((b, s, e)) # if jump to prev address, len(computed_flow) is more than 1 elif computed_flow[1][0] < s: computed.append((b, s, e)) else: print computed_flow error("[-] Need to remake flow way") elif computed_addr == e: prev = computed.pop() if prev[1] <= s: computed.append(prev) else: computed_flow = self.ComputeFlow(s, e) if len(computed_flow) == 1: computed.append((b, s, e)) # if jump to prev address, len(computed_flow) is more than 1 elif computed_flow[1][0] < s: computed.append((b, s, e)) else: print computed_flow error("[-] Need to remake flow way") else: # error("[-] It is not sorted flow way") pass return computed
def get(self, *args): if self.request.host == "instagrampc.appspot.com" or self.request.host == "www.instagram.jp": return self.redirect("http://www.i4pc.jp/", permanent=True) session = get_current_session() instagram = Instagram() max_id = self.request.get("max_id") prev_max_id = max_id first_page = True if max_id: first_page = False if session.has_key("access_token"): instagram.set_access_token(access_token=session["access_token"]) login = True user = session["user"] else: login = False user = None if self.request.path == "/popular" or login == False: path = base.set_template("popular") try: feed = instagram.media_popular(count=50, max_id=max_id) except InstagramAPIError, e: return base.error(self, 500, e.error_message.capitalize()) except:
def main(): # Arguments: form = cgi.FieldStorage() person_id = base.cleanCGInumber(form.getvalue("person_id")) test_type = base.cleanCGInumber(form.getvalue("test_type")) card_id = base.cleanCGInumber(form.getvalue("card_id")) success = (False, True)[bool(form.getvalue("success"))] db = settings.get_db() ## Comments: comments = form.getvalue("comments") if comments: comments = cgi.escape(comments) if person_id != 0: # Basic: base.begin() base.header_redirect("module.py?db={0}&card_id={1}".format(db, card_id)) base.top(db) # Add the test to the DB: test_id = add_test_basic(db, person_id, test_type, card_id, success, comments) ## Attachments: for i in range(1, 4): afile = form['attach{0}'.format(i)] if (afile.filename): adesc= form.getvalue("attachdesc{0}".format(i)) if adesc: adesc = cgi.escape(adesc) acomment= form.getvalue("attachcomment{0}".format(i)) if acomment: acomment = cgi.escape(acomment) add_test_attachment(db, test_id, afile, adesc, acomment) base.bottom() else: base.error(db, "You must select a tester from the available list.") else: base.error(db, "You must input comments before the test can be added.")
def get(self, user_id, feed=None): if self.request.host == "instagrampc.appspot.com" or self.request.host == "www.instagram.jp": return self.redirect("http://www.i4pc.jp" + self.request.path, permanent=True) instagram = Instagram() session = get_current_session() if not session.has_key("access_token"): session["redirect_to"] = self.request.path return self.redirect("/login") else: access_token = session["access_token"] user = session["user"] login = True instagram.set_access_token(access_token=access_token) try: user_searched = instagram.user_find_by_username(user_id) except InstagramAPIError, e: return base.error(self, 500, e.error_message.capitalize())
def get(self, media_id): if self.request.host == 'instagrampc.appspot.com' or self.request.host == 'www.instagram.jp': return self.redirect('http://www.i4pc.jp' + self.request.path, permanent=True ) instagram = Instagram() session = get_current_session() if session.has_key('access_token'): instagram.set_access_token( access_token = session['access_token'] ) login = True user = session['user'] else: login = False user = None try: media = instagram.media(media_id) except InstagramAPIError, e: return base.error(self, 500, e.error_message.capitalize())
def main(): # Arguments: form = cgi.FieldStorage() sn = form.getvalue("serial_number") db = settings.get_db() ## KLUDGE for special ease-of-access for "hf_qie" DBs: if "hf_qie" in db: if len(sn) == 3: sn = "3040000000000500" + sn if sn: card_id = module.fetch_cardid_from_sn(db, sn) if card_id: base.error(db, "Finding the module ...", redirect="module.py?db={0}&card_id={1}".format(db, card_id), redirect_time=0) else: base.error(db, "There is no module in this database with a serial number matching \"{0}\".".format(sn)) else: base.error(db, "What did you expect to happen?") return True
def newsFeed(firstname, email): base.newsFeedStart() posts = model.getPosts(firstname, email) for post in posts: base.newsFeedPost(post) base.newsFeedEnd() if caption != None: media = fieldStorage["media"] model.savePost(email, caption, media) if firstname != None: base.navbar(firstname, email) newsFeed(firstname, email) else: password = fieldStorage.getvalue("password") result = model.login(email, password) if isinstance(result, model.User): base.navbar(result.firstname, result.email) newsFeed(result.firstname, result.email) else: base.error(email, "Invalid Credentials !") base.footer() # print(f''' # Email : {email} # Password : {password} # ''')
if not session.has_key("access_token"): session["redirect_to"] = self.request.path return self.redirect("/login") else: access_token = session["access_token"] user = session["user"] login = True instagram.set_access_token(access_token=access_token) try: user_searched = instagram.user_find_by_username(user_id) except InstagramAPIError, e: return base.error(self, 500, e.error_message.capitalize()) except: return base.error(self) found = None if user_searched: user_id = user_searched["id"] found = True max_id = self.request.get("max_id") prev_max_id = max_id if not found and re.match(r"^\d+$", user_id): try: user_found = instagram.user(user_id) except InstagramAPIError, e: return base.error(self, 500, e.error_message.capitalize()) except:
firstname = fieldStorage.getvalue("firstname") lastname = fieldStorage.getvalue("lastname") email = fieldStorage.getvalue("email") password = fieldStorage.getvalue("password") birthday = fieldStorage.getvalue("birthday") gender = fieldStorage.getvalue("gender") # print(f''' # Firstname : {firstname} # Lastname : {lastname} # Email : {email} # Password : {password} # Birthday : {birthday} # Gender : {gender} # ''') try: base.header() result = model.register(firstname, lastname, email, password, birthday, gender) if result == 1: profileCreated = model.createProfile(email) if profileCreated: base.navbar(firstname, email) base.newsFeedStart() base.newsFeedPost() base.newsFeedEnd() except pymysql.IntegrityError: base.error(email, "Email Id Already Exists !") finally: base.footer()