-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplayTools.py
53 lines (44 loc) · 1.47 KB
/
DisplayTools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
#!/usr/bin/env python
"""
@author: Quentin
"""
import mysql.connector
import os
import time
def DisplayOneTime(table):#Affiche une fois la table
try:
connection = mysql.connector.connect(host='192.168.0.105',database='heronDatabase',user='robot',password='HeronLeR0B0T')
sql_select_Query = "select * from "+table+";"
cursor = connection.cursor()
cursor.execute(sql_select_Query)
records = cursor.fetchall()
#{print("la longueur : ",len(records))
except AssertionError as error:
print(error)
print("Error reading data from MySQL table")
finally:
if (connection.is_connected()):
connection.close()
cursor.close()
try:
print("------",table,"-------")
phr=""
for row in records:
for elt in row:
phr=phr+str(elt)+"|"
print(phr)
phr=""
except:
print("Error during printing")
def Display(table,temp):#Affiche la table en boucle et actualise par défault toutes les 0.5 secondes (la période de rafraîchissement peut-être spécifiée en paramètre)
while(True):
os.system("clear")#On clear la console
DisplayOneTime(table)#Affichage console
time.sleep(temp)
def DisplayAVAILABLE(temps=0.5):
Display("AVAILABLE",temps)
def DisplayCOMMANDS(temps=0.5):
Display("COMMANDS",temps)
def DisplayDICTIONNARY(temps=0.5):
Display("DICTIONNARY",temps)