I have a code here and I just want to ask if what are the missing codes or what should I add so that every time I'm going to run this code a GUI will already appear and not the IDE/console anymore.
Code:
from ftplib import FTP
import os, sys, os.path, operator
import wx
host_name = raw_input("Enter your FTP Site: ")
if "http://" in host_name:
host_name = host_name.replace("http://","")
host_name = host_name.replace("\n","")
user = raw_input("Enter username: ")
pwd = raw_input("Enter password: ")
try: ftph = FTP(host_name)
except:
print "Host could not be resolved."
raw_input()
sys.exit()
else: pass
try:
ftph.login(user,pwd)
except Exception:
if user == "anonymous" or user == "Anonymous" and pwd == "anonymous" or pwd == "Anonymous":
print "The server does not accept anonymous requests."
raw_input()
sys.exit()
else:
print "Invalid login combination."
raw_input()
sys.exit()
else:
print "Successfully connected!\n"
print ftph.getwelcome()
flag = 1
count = 0
path = ftph.pwd()
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
def handleDownload(block):
file.write(block)
print ".",
ddir='#localdirectory'
os.chdir(ddir)
ftp = FTP('#ftpsite')
print 'Logged in!'
ftp.login('', '')
directory = '#ftpdirectory'
print 'Changing to ' + directory
ftp.cwd(directory)
ftp.retrlines('LIST')
print 'Downloading files...'
filenames = []
ftp.retrlines('NLST', filenames.append)
print filenames
for filename in filenames:
local_filename = os.path.join('#localdirectory', filename)
file = open(local_filename, 'wb')
ftp.retrbinary('RETR '+ filename, file.write)
file.close()
ftp.close()