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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| # ACCES SECURISE ######
# Creation de la fenetre principale
fenetremdp = Tk()
fenetremdp.iconbitmap("rasp.xpm")
fenetremdp.title('Identification requise')
def Verification(**retour):
if Motdepasse.get() == 'rasp':
# le mot de passe est bon : on affiche une boite de dialogue puis on ferme la fenetre
tkMessageBox.showinfo('Resultat','Mot de passe correct.\nA vous de jouer !')
#fenetremdp.destroy()
#command = reponse()
#fenetremdp.destroy()
#quit()
else:
# le mot de passe est incorrect
tkMessageBox.showwarning('Resultat','Mot de passe incorrect.\nVeuillez recommencer !')
Motdepasse.set('')
return retour
#fenetremdp.destroy()
#quit()
# Creation d'un Label (texte 'Mot de passe')
Label1 = Label(fenetremdp, text = 'Mot de passe ')
Label1.pack(side = LEFT, padx = 5, pady = 5)
#fenetremdp.attributes('-fullscreen', 1)
#fenetremdp.overrideredirect(1)
# Creation d'un champ de saisie)
Motdepasse= StringVar()
Champ = Entry(fenetremdp, textvariable= Motdepasse, show='*', bg ='bisque', fg='maroon')
Champ.focus_set()
Champ.pack(side = LEFT, padx = 5, pady = 5)
# Creation bouton Valider)
Bouton = Button(fenetremdp, text ='Valider', command = Verification)
Bouton.pack(side = LEFT, padx = 5, pady = 5)
fenetremdp.mainloop()
quit()
fen = Tk()
fen.iconbitmap("rasp.xpm")
def fermer():
fen.destroy()
def ssh1():
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect('10.xx.xx.xx', username='userdown', password='downuser')
except paramiko.SSHException:
print "Connection Failed"
quit()
stdin,stdout,stderr = ssh.exec_command("sudo reboot")
for line in stdout.readlines():
print line.strip()
ssh.close()
def ssh2():
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect('10.xx.xx.xx', username='userdown', password='downuser')
except paramiko.SSHException:
print "Connection Failed"
quit()
stdin,stdout,stderr = ssh.exec_command("sudo reboot")
for line in stdout.readlines():
print line.strip()
ssh.close()
def ssh3():
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect('10.xx.xx.xx', username='userdown', password='downuser')
except paramiko.SSHException:
print "Connection Failed"
quit()
stdin,stdout,stderr = ssh.exec_command("sudo reboot")
for line in stdout.readlines():
print line.strip()
ssh.close()
def ssh4():
tkMessageBox.showinfo("Information", "Rasberry absent pour l' instant !")
def callback1():
if tkMessageBox.askyesno("Arret des raspberry", "etes vous sur?", icon='warning'):
#tkMessageBox.askquestion("Delete", "Are You Sure?", icon='warning')
command=ssh1()
else:
command=fermer()
def callback2():
if tkMessageBox.askyesno("Arret des raspberry", "etes vous sur?", icon='warning'):
#tkMessageBox.askquestion("Delete", "Are You Sure?", icon='warning')
command=ssh2()
else:
command=fermer()
def callback3():
if tkMessageBox.askyesno("Arret des raspberry", "etes vous sur?", icon='warning'):
#tkMessageBox.askquestion("Delete", "Are You Sure?", icon='warning')
command=ssh3()
else:
command=fermer()
labf1 = LabelFrame(fen, text="Arret Raspberry")
itm1 = Button(labf1,text="Rasp01",command=callback1, background="green")
itm2 = Button(labf1, text="Rasp02",command=callback2, background="green")
itm3 = Button(labf1, text="Rasp03",command=callback3, background="green")
itm4 = Button(labf1, text="Rasp04",command=ssh4, background="yellow")
itm5 = Button(labf1,text="Quit",command=fermer, background="red")
labf1.grid(row=0,column=0)
itm1.grid(row=0,column=1)
itm2.grid(row=0,column=2)
itm3.grid(row=0,column=3)
itm4.grid(row=0,column=4)
itm5.grid(row=0,column=6)
fen.mainloop() |
Partager