python 自动下载 moudle
2014-04-29 21:02
225 查看
import sys,re,subprocess
import os from subprocess import CalledProcessError new_set = set() ls = set() def dls(): temp_set = set() a = subprocess.check_output("ls -R", shell=True) for line in a.split('\n'): str = re.sub(r'.py', r'', line) if str.find('.')<0 and str!='\n' : temp_set.add(str) print str return temp_set def dpip(new_set): ls = dls() for str in new_set-ls: str = str.replace('\n','') with open('daicy.py', 'w') as f: f.write('import '+str) try: a = subprocess.check_call('python daicy.py', shell=True) if a!=0: command = 'pip install '+str print command subprocess.call(command, shell=True) except CalledProcessError, e: print 'except:', e command = 'pip install '+str print command os.system(command) finally: pass a = subprocess.Popen('''find -name '*.py' | xargs grep -h -o -w -s "^import\s\+\([\_0-9a-zA-Z]\+\)\|^from\s\+\([\_0-9a-zA-Z]\+\)"''', shell=True,stdout=subprocess.PIPE) for line in a.stdout.readlines(): line = line.replace('\n','') new_set.add(re.sub(r'import\s+|from\s+', r'', line)) dpip(new_set)
相关文章推荐
- 我的第一个python爬虫程序(从百度贴吧自动下载图片)
- python自动下载人人所有好友的相册
- Python爬虫_自动下载图片
- python实现CSDN下载资源自动评分(selenium+requests)
- 运用shell,python自动下载linux系统运维
- python登录csdn并自动评论下载资源脚本
- Python小爬虫-自动下载三亿文库文档
- 迅雷下载最近经常异常崩溃,下个Python脚本自动监控重启之
- windos自动下载setuptools的Python脚本
- python 自动下载 voa MP3
- 用Python编写自动下载网络小说的脚本
- 用python自动下载妹子图
- 自动下载解压的python logging download os ,一份比较好的python下载解压代码
- Python脚本自动下载小说
- 使用Python自动下载妹子图的图片到本地
- Python简单网页爬虫——极客学院视频自动下载
- 利用python脚本自动下载ICML会议接受的文章
- Python实现115网盘自动下载的方法
- Python 玩具 —— 使用 os , reuqests 配合 you-get 自动下载网易公开课视频
- 遇到代理问题时自动下载MNIST数据集的Python代码