NCast Presentation Recorder Reference Manual
To run this program under Windows you may use a command line, such as:
C:> "C:\Program Files\Python24\python.exe" ncfiles.py 192.168.0.5
A simpler alternative is to create a shortcut to "ncfiles.py" and then using the
Properties tab for the shortcut enter the required arguments:
"C:\Documents and Settings\owner\My Documents\Python\ncfiles.py" 192.168.0.5
Please send comments or questions to "[email protected]".
Copyright (2005) NCast Corporation
All rights reserved
"""
import sys
import os, os.path
import time
import getopt
import string
import urllib
import urllib2
import socket
def Download(host, user, pswd, realm, remove):
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(realm, host, user, pswd)
opener = urllib2.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib2.install_opener(opener)
# Get list of files to download
url = "http://" + host + "/backup/list.cgi"
try:
filelist = urllib2.urlopen(url)
except urllib2.URLError, msg:
print "ncfiles: Urllib2 error (%s)" % msg
return False
except socket.error, (errno, strerror):
print "ncfiles: Socket error (%s) for host %s (%s)" % (errno, host, strer-
ror)
return False
# Process the list of files to download
files = []
for line in filelist.read().split("\n"):
file = line.strip(' \n\r')
if file == "":
break
files.append(file)
NCast Corporation
Revision 1.1
Page 89