Skip to content

Instantly share code, notes, and snippets.

@daqing
Created February 15, 2009 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daqing/64636 to your computer and use it in GitHub Desktop.
Save daqing/64636 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# vim: set fileencoding=utf-8
"""
download softwares
"""
import os, sys
p = os.path
if p.dirname(p.abspath(sys.argv[0])) != os.getcwd():
print "Usage: ./download.py"
sys.exit(1)
wget = os.popen('which wget').read() # 返回值里包含"\n"
if not len(wget):
print "* wget not found."
sys.exit(2)
wget = wget.replace('\n', '')
# urls to download softwares
urls = (
'http://www.python.org/ftp/python/3.0.1/Python-3.0.1.tar.bz2',
'http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz',
'http://sysoev.ru/nginx/nginx-0.6.35.tar.gz'
)
to_download = filter(lambda x: not os.path.exists(x.split('/')[-1:][0]), urls)
if len(to_download):
for cmd in map(lambda x: wget + ' ' + x, to_download):
os.system(cmd)
else:
print "* nothing to download."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment