From 66cf345f326780bfcfda5246a528202bf1be30ce Mon Sep 17 00:00:00 2001 From: clamsawd Date: Mon, 9 Nov 2015 10:42:40 +0100 Subject: [PATCH] Check and test a previous configuration --- ip2e-config.py | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/ip2e-config.py b/ip2e-config.py index 848f1b7..f80f2e8 100755 --- a/ip2e-config.py +++ b/ip2e-config.py @@ -47,6 +47,40 @@ if not os.path.exists(".ip2e"): if os.path.exists(".ip2e"): os.chdir(".ip2e") +if os.path.isfile("ip2e-conf.py"): + ClearScreen() + print ("") + print ("ip2e-config v"+version) + print ("") + print ("Detected a previous configuration file") + print ("Do you want to overwrite or check the current configuration?") + print ("") + print ("(o) - overwrite (create new configuration)") + print ("(c) - check and test the current configuration") + print ("") + OverWriteOrCheck=input("[Default: check and test] Choose an option; ") + if OverWriteOrCheck == "o" or OverWriteOrCheck == "O": + print ("Create new configuration") + else: + exec(open("ip2e-conf.py").read()) + #Import smtplib + import smtplib + try: + server = smtplib.SMTP(SmtpFromEmail) + server.ehlo() + server.starttls() + server.ehlo() + server.login(FromEmailUser,FromEmailPass) + server.quit() + print ("") + print ("Test OK") + print ("") + except: + print ("") + print ("Failed to connect ("+SmtpFromEmail+")") + print ("") + exit(0) + #Set variables of 'ip2e-conf.py' ClearScreen() print ("") @@ -84,8 +118,11 @@ readfile.close() #Test connection with your configuration print ("") -TestConnection=input("Test connection with your configuration (y/n): ") -if TestConnection == "y": +TestConnection=input("[Default: y] Test connection with your configuration (y/n): ") +if TestConnection == "n": + print ("Exiting...") + exit(0) +else: exec(open("ip2e-conf.py").read()) #Import smtplib import smtplib @@ -103,6 +140,3 @@ if TestConnection == "y": print ("") print ("Failed to connect ("+SmtpFromEmail+")") print ("") -else: - print ("Exiting...") - exit(0)