def get(self): self.response.headers["Content-Type"] = "text/html" self.response.out.write("<html><body>") logging.info("Starting") query = log_db.all().ancestor(log_db_key("log_database")) # while len(query.fetch(1)) > 0: for a in range(20): logging.info("round " + str(a)) entries = query.fetch(500) for entry in entries: self.response.out.write("<p>User Key: <i>" + str(entry.user.key()) + "</i></p>") self.response.out.write("<p>Log time-stamp: <i>" + str(entry.log_time_stamp) + "</i></p>") self.response.out.write("<p>Activity time-stamp: <i>" + str(entry.activity_time_stamp) + "</i></p>") self.response.out.write("<p>Content of log: <i>" + str(entry.content) + "</i></p><hr>") db.delete(entry) self.response.out.write("<p><i>~~~deleted</i></p><hr>") self.response.out.write("</body></html>")
def process(self, received_csv): "processes the csv into the log files" # self.response.out.write(csv) list_of_entities = [] metadata = received_csv.next() user_key = self.get_user_key_from_database(metadata[1], metadata[0]) log_ts = datetime.strptime(metadata[2], '%Y-%m-%d %H:%M:%S') logging.info('user_key: ' + str(user_key)) logging.info('log_ts: ' + str(log_ts)) if user_key is not None: self.response.out.write("<p>User Key: <i>" + str(user_key) + "</i></p>") self.response.out.write("<p>Log time-stamp: <i>" + str(log_ts) + "</i></p>") row = received_csv.next() while (True): row = received_csv.next() if (len(row) == 3): logging.info(row) activity_ts = datetime.strptime(row[0], '%Y-%m-%d %H:%M:%S') logging.info('activity_ts: ' + str(activity_ts)) logging.info('tag: ' + str(row[1])) logging.info('content: ' + str(row[2])) list_of_entities.append( log_db( parent=log_db_key('log_database'), user=user_key, log_time_stamp=log_ts, activity_time_stamp=activity_ts, tag = row[1], content=row[2] ) ) self.response.out.write("<p>Activity time-stamp: <i>" + str(activity_ts) + "</i></p>") self.response.out.write("<p>Content of log: <i>" + str(row[1]) + "</i></p><hr>") else: break db.put(list_of_entities) else: self.response.out.write("<p><i>Error: User not found</i></p>")