add linebreaks, fix quotes check

This commit is contained in:
samerbam 2023-08-22 22:47:20 -04:00
parent 0cc80e81a0
commit 8c99664acf
4 changed files with 8 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -52,7 +52,7 @@ class TodoDatabase:
def get_random_quote(self): def get_random_quote(self):
# print(time.time()) # 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() self._update_quotes()
quote = random.choice(self.database["quotes"]) quote = random.choice(self.database["quotes"])

View File

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

View File

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