Created
February 15, 2009 07:23
-
-
Save daqing/64636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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