Python: Automatic Download Manager

A forum for general discussion of the Python programming language.

Python: Automatic Download Manager

Postby precyoz » Wed Jul 03, 2013 6:35 am

Is it possible to make an Automatic Download Manager in Python(with wxpython)? "Automatic" in such a way that, your files will automatically and continuously be downloaded when you turn on your PC and automatically stop the downloading when you shut down your PC. Anyway, the download manager should contain an ftp and HTTP site text control and a username and password that relates to what ftp or HTTP site you fill in, and a connect/download button to start the downloading.

Any help is greatly appreciated :)
precyoz
 
Posts: 18
Joined: Wed Jul 03, 2013 6:23 am

Re: Python: Automatic Download Manager

Postby Crimson King » Wed Jul 03, 2013 7:09 am

Hi, yes of course it's possible, Python is a general-purpose language so you can code many different things with it.

Never tried anything like that, but maybe you should check the standard library (a quick search gave me this result regarding ftp ftplib)

Try coding this and when you get some errors come back and post them, we'll be happy to help you out.
User avatar
Crimson King
 
Posts: 85
Joined: Fri Mar 08, 2013 2:42 pm
Location: Buenos Aires, Argentina

Re: Python: Automatic Download Manager

Postby micseydel » Wed Jul 03, 2013 8:48 am

The issue of the GUI (graphical user interface, wxpython) is separate from the point of your program. In order to accomplish this whole task, I recommend you write it without a GUI first, then add a GUI on after you've gotten the functionality set. If you've written the program properly before you add the GUI, having the GUI use the existing code should be easy. In order to accomplish this, you will "separate interface from implementation".

What that means is that your functions which the GUI would use will not include input() calls or print statements. Use parameter passing and function return values.

As Crimson King said, once you get started we can give you more help, but at this point you should just pick small parts of the program to work on at a time, get started, and then when you have issues ask as specific of questions as possible here. And we'll expect that you've read this, and you may be ignored if you appear to not have read it since your next post won't be your first.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1113
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Python: Automatic Download Manager

Postby precyoz » Sat Jul 13, 2013 1:37 pm

I have tried this code to download a file (a folder that has an updated file everyday) from an ftp site:

Code: Select all
import os
from ftplib import FTP

ftp = FTP("ftp://samoa.gsfc.nasa.gov/subscriptions/MODISA/XM/ljvillarin30/2282/","myuser", "mypass")
ftp.login()
ftp.retrlines("LIST")

ftp.cwd("folderOne")
ftp.cwd("subFolder")

listing = []
ftp.retrlines("LIST", listing.append)
words = listing[0].split(None, 8)
filename = words[-1].lstrip()

#download the file
local_filename = os.path.join(r"C:\example", file)
lf = open(local_filename, "wb")
ftp.retrbinary("RETR " + filename, lf.write, 8*1024)
lf.close()


But when i run the script, it says:

Traceback (most recent call last):
File "C:/Users/turtle/Desktop/OUTPUT/FTP-ex.py", line 4, in <module>
ftp = FTP("ftp://samoa.gsfc.nasa.gov/subscriptions/MODISA/XM/ljvillarin30/2282/", "myuser", "mypass")
File "C:\Python27\lib\ftplib.py", line 117, in __init__
self.connect(host)
File "C:\Python27\lib\ftplib.py", line 132, in connect
self.sock = socket.create_connection((self.host, self.port), self.timeout)
File "C:\Python27\lib\socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
gaierror: [Errno 11004] getaddrinfo failed


Can you tell me what should be the correct code?
Last edited by precyoz on Mon Jul 15, 2013 4:06 am, edited 2 times in total.
precyoz
 
Posts: 18
Joined: Wed Jul 03, 2013 6:23 am

Re: Python: Automatic Download Manager

Postby snippsat » Sat Jul 13, 2013 2:46 pm

Change your code to ftp = FTP("samoa.gsfc.nasa.gov/subscriptions/MODISA/XM/ljvillarin30/2282/", "myuser", "mypass")
The ftp:// is only used for a URl connetion,ftplib library expect the hostname of your FTP server.
User avatar
snippsat
 
Posts: 124
Joined: Thu Feb 21, 2013 12:04 am

Re: Python: Automatic Download Manager

Postby precyoz » Mon Jul 15, 2013 4:05 am

Thanks for your help. :)

I just made the ftp shorter.
Code: Select all
ftp = FTP("samoa.gsfc.nasa.gov", "myuser", "mypass")


But it's getting this error.
Code: Select all
Traceback (most recent call last):
  File "C:\Users\turtle\Desktop\OUTPUT\FTP-ex.py", line 4, in <module>
    ftp = FTP("samoa.gsfc.nasa.gov", "ljvillarin30", "skies-zen")
  File "C:\Python27\lib\ftplib.py", line 119, in __init__
    self.login(user, passwd, acct)
  File "C:\Python27\lib\ftplib.py", line 387, in login
    resp = self.sendcmd('USER ' + user)
  File "C:\Python27\lib\ftplib.py", line 244, in sendcmd
    return self.getresp()
  File "C:\Python27\lib\ftplib.py", line 219, in getresp
    raise error_perm, resp
error_perm: 530 Permission denied.


What was 530 Permission Denied means? :? Is it all about the passive/active mode issue? Or is it about the ftp/HTTP proxy? :?
precyoz
 
Posts: 18
Joined: Wed Jul 03, 2013 6:23 am

Re: Python: Automatic Download Manager

Postby precyoz » Thu Jul 18, 2013 6:55 am

Can anyone Help me about the "530 Permission Denied" error in my script?
precyoz
 
Posts: 18
Joined: Wed Jul 03, 2013 6:23 am


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 2 guests