3 Replies - 466 Views - Last Post: 27 August 2013 - 05:41 AM Rate Topic: -----

#1 precyoz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-April 13

FTP Downloading File Directories GUI

Posted 26 August 2013 - 05:19 AM

I have here a script that download all the files from the FTP directories. What I want is to turn/make it into a GUI. But I don't have any idea on how to do it. Can anyone help me about this?

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='C:\example\FTP'
os.chdir(ddir)
ftp = FTP('samoa.gsfc.nasa.gov')

ftp.login('', '')
directory = '/subscriptions/MODISA/XM/ljvillarin30/2282/'

print 'Changing to ' + directory
ftp.cwd(directory)
ftp.retrlines('LIST')

print 'Accessing files'

filenames = []
ftp.retrlines('NLST', filenames.append)

for filename in filenames:
    local_filename = os.path.join('C:\example\FTP', filename)
    file = open(local_filename, 'wb')
    ftp.retrbinary('RETR '+ filename, file.write)

    file.close()
    
ftp.close()



Is This A Good Question/Topic? 0
  • +

Replies To: FTP Downloading File Directories GUI

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8393
  • View blog
  • Posts: 31,213
  • Joined: 12-June 08

Re: FTP Downloading File Directories GUI

Posted 26 August 2013 - 06:40 AM

Have you started your research here?

http://wiki.python.o.../GuiProgramming
Was This Post Helpful? 0
  • +
  • -

#3 precyoz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-April 13

Re: FTP Downloading File Directories GUI

Posted 27 August 2013 - 05:10 AM

View Postmodi123_1, on 26 August 2013 - 06:40 AM, said:

Have you started your research here?

http://wiki.python.o.../GuiProgramming




I preferred to use WxPython but I can't find any samples anywhere. Do you know any samples related to my problem?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8393
  • View blog
  • Posts: 31,213
  • Joined: 12-June 08

Re: FTP Downloading File Directories GUI

Posted 27 August 2013 - 05:41 AM

Really? If I put that package name and "gui" in a search engine it returns a mess of content and tutorials.

Have you looked at this page?

http://wiki.wxpython...earn%20wxPython
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1