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
| # -*- coding: cp1252 -*-
from Tkinter import *
import os
import paramiko
import tkMessageBox
os.chdir("C:/prog")
fenetre = Tk()
fenetre.geometry("800x600+300+0")
menu1 = 0
numero = 0
numero1 = 0
txt1 = Label(fenetre, text="Telephonie")
txt1.pack()
txt2 = Label(fenetre, text="Indiquer le numero de votre nouveau contact:")
txt2.place(x=45, y=40)
def verification():
if Motdepasse.get() <= 1:
# si le numero et inferieur ou egale a 1
tkMessageBox.showinfo("Erreur", "Le numéro de telephone est invalide")
print("if",Motdepasse.get())
elif Motdepasse.get() >= 8:
print("elif",Motdepasse.get())
else:
# sinon le numero est ok on l enregistre sur asterisk
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('192.168.1.15', username='root', password='azerty')
stdin, stdout, stderr = client.exec_command("mkdir test")
stdin, stdout, stderr = client.exec_command("ls")
for line in stdout.read().splitlines():
print (line)
stdin, stdout, stderr = client.exec_command("rm -r test")
client.close()
tkMessageBox.showinfo("Erreur", "Ajout au carnet d adresse effectué pour le numero")
print("else",Motdepasse.get())
# Création d'un widget Entry (champ de saisie)
Motdepasse= StringVar()
Champ = Entry(fenetre, textvariable= Motdepasse, bg ='bisque', fg='maroon').place(x=45, y=120)
bouton1=Button(fenetre, text="Ajouter", command=verification).place(x=125, y=115)
Resultat = StringVar()
Label(fenetre,textvariable=Resultat).pack(padx=30,pady=10)
fenetre.mainloop() |
Partager