add linebreaks, fix quotes check

main
samerbam 1 year ago
parent 0cc80e81a0
commit 8c99664acf

File diff suppressed because one or more lines are too long

@ -52,7 +52,7 @@ class TodoDatabase:
def get_random_quote(self):
# print(time.time())
if ("quotes_last_updated" in self.database) or ("quotes" in self.database) or (time.time()-self.database["quotes_last_updated"] > 86400):
if ("quotes_last_updated" not in self.database) or ("quotes" not in self.database) or (time.time()-self.database["quotes_last_updated"] > 86400):
self._update_quotes()
quote = random.choice(self.database["quotes"])

@ -18,6 +18,7 @@ app = FastAPI()
auth = VerifyToken()
data = TodoDatabase()
printer = ThermalPrinter(data)
printer.print_default() #temp debug

@ -61,6 +61,7 @@ class ThermalPrinter():
self.p.text(datetime.today().strftime('%Y-%m-%d'))
self.p.set(align="left")
self.p.set(invert=False)
self.p.text("\n")
# pass #TODO: add other greetings?
def print_todos(self, todos=[{"time": "1:00pm to 2:00pm", "text": "Read a book"}]):
@ -71,6 +72,7 @@ class ThermalPrinter():
self.p.set(align="right")
self.p.textln(x[1])
self.p.set(align="left")
self.p.text("\n")
def print_sudoku(self):
self.p.close()
@ -83,8 +85,11 @@ class ThermalPrinter():
q = self.database.get_random_quote()
self.p.set(align="left")
self.p.text(q[0])
self.p.text("\n")
self.p.set(align="right")
self.p.text(q[1])
self.p.text("\n")
# pass #TODO: parse https://zenquotes.io/api/quotes (api limit is 5 req per 30 seconds)

Loading…
Cancel
Save