Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import messagebox
- from tkinter import *
- from getpass import *
- from socket import *
- import paramiko
- import sys
- import time
- import socket
- import platform
- from subprocess import Popen, PIPE,call
- import os
- try:
- import Tkinter as Tk
- except:
- import tkinter as Tk
- import os
- #from foo import *
- class LoginFrame(Frame):
- def __init__(self, master):
- super().__init__(master)
- self.label_ipa = Label(self, text="IP Address",font=("Times New Roman",14), fg="blue")
- self.label_username = Label(self, text="Username",font=("Times New Roman", 14), height=4, fg="blue")
- self.label_password = Label(self, text="Password",font=("Times New Roman", 14), height=4, fg="blue")
- self.entry_ipa = Entry(self,justify=CENTER)#.grid(row-0,column=1)
- self.entry_username = Entry(self,justify=CENTER)#.grid(row=0,column=1,pady=4)
- self.entry_password = Entry(self, show="*",justify=CENTER)
- self.label_ipa.grid(row=0,sticky=E)
- self.label_username.grid(row=1, sticky=E)
- self.label_password.grid(row=2, sticky=E)
- self.entry_ipa.grid(row=0,column=1)
- self.entry_username.grid(row=1, column=1)
- self.entry_password.grid(row=2, column=1)
- self.disct = Button(self, text="Close Session",command=self._disc_,font=("Times New Roman", 14), width=10,height=2, fg="red")
- self.logbtn = Button(self, text="Connecting", command=self._login_,font=("Times New Roman", 14), width=10,height=2, fg="green")
- self.logbtn.grid(row=3,column=0)
- self.disct.grid(row=3,column=2)
- self.pack()
- def _login_(self):
- ipa = self.entry_ipa.get()
- username = self.entry_username.get()
- password = self.entry_password.get()
- if not ipa:
- tk.messagebox.showerror("Error MessageBox","please Enter the IP Address",icon="warning")
- return False
- if not username:
- tk.messagebox.showerror("Error MessageBox","please Enter Your Username",icon="warning")
- return False
- if not password:
- tk.messagebox.showerror("Error MessageBox","please Enter Your Password",icon="warning")
- return False
- cl1=paramiko.SSHClient()
- cl1.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- cl1.connect(ipa,username=username,password=password)
- if(ipa==ipa and username==username and password==password):
- tk.messagebox.showinfo("OPEN THE Session","SSH connection to %s established" %ipa)
- else:
- #client_key
- tk.messagebox.showerror("Error MessageBox","please try again",icon="warning")
- window = Toplevel(root)
- window.title("Command Action")
- window.geometry("400x350+400+350")
- b1=Button(window,text="check Memory",bg="red",command=self._login_).place(x=0,y=0)
- b2=Button(window,text="Free disk Space",bg="red").place(x=100,y=0)
- b3=Button(window,text="Imprt XML FILE",bg="red").place(x=220,y=0)
- text=Text(window,height=10,width=50).place(x=0,y=50)
- stdin, stdout, stderr=cl1.exec_command("free -g")
- #print(stdout.read())
- text.insert(stdout.read())
- def _disc_(self):
- MsgBox = tk.messagebox.askquestion ('Exit Application','Are you sure you want Dissconnecting ',icon = 'warning')
- if MsgBox == "yes":
- root.destroy()
- else:
- tk.messagebox.showinfo('Return','You will now return to the
- application screen')
- root = tk.Tk()
- root.geometry('400x400+50+50')
- root.title('Connecting to Server')
- lf = LoginFrame(root)
- root.mainloop()
Add Comment
Please, Sign In to add comment