473,750 Members | 2,533 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 1000

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

Similar topics

5
2574
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
4490
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
7383
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
3736
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
6736
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
7576
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
1746
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
4101
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
16145
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
9001
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
8838
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
9583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9342
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
8263
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4716
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...
1
3323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.