473,700 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FTP Client

5 New Member
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.


Expand|Select|Wrap|Line Numbers
  1. from ftplib import FTP
  2. import os, sys, os.path, operator
  3. import wx
  4.  
  5. host_name = raw_input("Enter your FTP Site: ")
  6. if "http://" in host_name:
  7.     host_name = host_name.replace("http://","")
  8. host_name = host_name.replace("\n","")
  9. user = raw_input("Enter username: ")
  10. pwd = raw_input("Enter password: ")
  11.  
  12. try: ftph = FTP(host_name)
  13. except:
  14.     print "Host could not be resolved."
  15.     raw_input()
  16.     sys.exit()
  17. else: pass
  18. try:
  19.     ftph.login(user,pwd)
  20. except Exception:
  21.     if user == "anonymous" or user == "Anonymous" and pwd == "anonymous" or pwd == "Anonymous":
  22.         print "The server does not accept anonymous requests."
  23.         raw_input()
  24.         sys.exit()
  25.     else:
  26.         print "Invalid login combination."
  27.         raw_input()
  28.         sys.exit()
  29. else:
  30.     print "Successfully connected!\n"
  31. print ftph.getwelcome()
  32. flag = 1
  33. count = 0
  34. path = ftph.pwd()
  35. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
  36.  
  37. def handleDownload(block):
  38.     file.write(block)
  39.     print ".",
  40.  
  41. ddir='#localdirectory'
  42. os.chdir(ddir)
  43. ftp = FTP('#ftpsite')
  44. print 'Logged in!'
  45.  
  46. ftp.login('', '')
  47. directory = '#ftpdirectory'
  48.  
  49. print 'Changing to ' + directory
  50. ftp.cwd(directory)
  51. ftp.retrlines('LIST')
  52. print 'Downloading files...'
  53.  
  54. filenames = []
  55. ftp.retrlines('NLST', filenames.append)
  56. print filenames
  57.  
  58. for filename in filenames:
  59.     local_filename = os.path.join('#localdirectory', filename)
  60.     file = open(local_filename, 'wb')
  61.     ftp.retrbinary('RETR '+ filename, file.write)
  62.  
  63.     file.close()
  64.  
  65. ftp.close()
  66.  
Jan 2 '14 #1
0 997

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2570
by: Matt | last post by:
I think this is the basic concept in ASP server-side development. My boss told me web application is NOT client-server application. I argued with him because browser is the client, and the server code put in server. Then web application should be a client-server application. My understanding is that a web application is an application that runs on a browser. But client-server application is not necessary a web application. Please...
15
4481
by: Michael Rybak | last post by:
hi, everyone. I'm writing a 2-players game that should support network mode. I'm now testing it on 1 PC since I don't have 2. I directly use sockets, and both client and server do computations, the only data transfered is user mouse/kbd input. It works synchronously, but somehow, when I play in client window, both client and server have 17 fps, while when playing in server window, server has 44 fps while client ...
18
7379
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure client-side javascript. I forgot to bookmark it, and now I can't find it. Anyone?
6
3731
by: Ken Allen | last post by:
I am relatively new to .Net and C#, but I hav ebeen programing in other languages and done some COM work for a number of years. I am attempting to understand how to map an older program architecture into .Net -- not looking to do it at this time, just to understand how I would achieve it. In the old environment, we had two classes, a client and a server class, that managed a data object. The server object knew how to interface with the...
4
6730
by: rs | last post by:
how I the client tell the server that the socket is closed? or this there an even that informs the server that the clients socket is close? Oh, I am using vb.net 2003 Thanks
2
7571
by: J Huntley Palmer | last post by:
I am having a horrific time integrating uw-imap's c-client for imap support in php. The problem is a whole bunch of "Text relocation remains referenced against symbol" errors during linking. Any help appreciated! The ordeal is a follows I am using Solaris 10 with php5.1.1. GCC:
0
1742
by: khu84 | last post by:
Here is client server very simple code, seems to work with telnet but with with web client code gives blank output. Following is the server code:- <?php function createSocketServer($host='192.168.1.34',$port=2222) { $max_clients = 10;
2
4099
by: nsaffary | last post by:
hi I hava a client/server program that run correctly when i run it in one computer(local) but when I run client on a one computer and run server run on another, connection does not stablish.(I set server machine IP for client and server) please guide me? server : #include <winsock2.h> #include <iostream> #include <stdio.h> #include <string.h> #include <windows.h> #pragma comment(lib, "ws2_32");
2
16142
by: kashifjawed | last post by:
I'm developing a c# asynchronous socket application for tranfering file or large data from client to server and server to client as well in chunks. Application sometimes transfer file from client to server and sometimes not, because connection betwenn client and server closed Abrupt. I cannot understand why connection between client and server is closed while i cannot closed the connection until a single block tranfered to server. ...
0
8716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9060
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6557
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4650
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2021
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.