阿里云镜像点:
http://mirrors.aliyun.com/
1、备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
3、之后运行yum makecache生成缓存

1.企业贡献:
搜狐开源镜像站:http://mirrors.sohu.com/
网易开源镜像站:http://mirrors.163.com/

2.大学教学:
北京理工大学:
http://mirror.bit.edu.cn (IPv4 only)
http://mirror.bit6.edu.cn (IPv6 only)
北京交通大学:
http://mirror.bjtu.edu.cn (IPv4 only)
http://mirror6.bjtu.edu.cn (IPv6 only)
http://debian.bjtu.edu.cn (IPv4+IPv6)
兰州大学:http://mirror.lzu.edu.cn/
厦门大学:http://mirrors.xmu.edu.cn/
上海交通大学:
http://ftp.sjtu.edu.cn/ (IPv4 only)
http://ftp6.sjtu.edu.cn (IPv6 only)
清华大学:
http://mirrors.tuna.tsinghua.edu.cn/ (IPv4+IPv6)
http://mirrors.6.tuna.tsinghua.edu.cn/ (IPv6 only)
http://mirrors.4.tuna.tsinghua.edu.cn/ (IPv4 only)
天津大学:http://mirror.tju.edu.cn/
中国科学技术大学:
http://mirrors.ustc.edu.cn/ (IPv4+IPv6)
http://mirrors4.ustc.edu.cn/
http://mirrors6.ustc.edu.cn/
西南大学:http://linux.swu.edu.cn/swudownload/Distributions/
东北大学:
http://mirror.neu.edu.cn/ (IPv4 only)
http://mirror.neu6.edu.cn/ (IPv6 only)
电子科技大学:http://ubuntu.uestc.edu.cn/
青岛大学:http://mirror.qdu.edu.cn/

附录:中国大陆开源软件镜像服务站点列表
    网易开源镜像站: http://mirrors.163.com/
    搜狐开源镜像站: http://mirrors.sohu.com/
    北京交通大学开源镜像站: http://mirror.bjtu.edu.cn
    兰州大学开源软件镜像站: http://mirror.lzu.edu.cn/
    厦门大学开源软件镜像站: http://mirrors.xmu.edu.cn/
    上海交通大学开源软件镜像站: http://ftp.sjtu.edu.cn/
    清华大学开源软件镜像站: http://mirrors.tuna.tsinghua.edu.cn/
    天津大学开源软件镜像站: http://mirror.tju.edu.cn/
    中国科学技术大学开源软件镜像站: http://mirrors.ustc.edu.cn/
    东北大学开源软件镜像站: http://mirror.neu.edu.cn/
    东软信息学院开源软件镜像站: http://mirrors.neusoft.edu.cn/
    浙江大学开源软件镜像站: http://mirrors.zju.edu.cn
    北京理工大学开源软件镜像站: http://mirror.bit.edu.cn
    华中科技大学开源软件镜像站: http://mirrors.hust.edu.cn/
    中山大学开源软件镜像站: http://mirror.sysu.edu.cn/
    大连理工大学开源软件镜像站: http://mirror.dlut.edu.cn/
Python中的fileinput模块和tempfile模块
fileinput模块提供处理一个或多个文本文件的功能, 可以通过使用for..in来循环读取一个或多个文本文件内容.
import fileinput
import sys
import glob
import string

for line in fileinput.input("test.txt"):     #处理一个文本文件
    print line

for line in fileinput.input(glob.glob("samples/*.txt")):  #处理多个文本文件
    if fileinput.isfirstline():
       print "------ reading %s ------\n" % fileinput.filename()    #获取文件名称
    print str(fileinput.lineno()) + " " + string.upper(line)  #获取行号和内容, 注意这里的行号是继前面文件行号来处理的,而不是重新开始计算


tempfile模块提供给你一个快速创建一个命名唯一的临时文件

import tempfile
import os
tempf = tempfile.mktemp(dir="D:/")
print "tempfile", "=>", tempf
file = open(tempf, "w+b")
file.write("*" * 1000)
file.seek(0)
print len(file.read()), "bytes"
file.close()
try:
    os.remove(tempf)    #用完以后要注意删除临时文件
except OSError:
    pass

当然你还可以通过file = tempfile.TemporaryFile()直接为你创建一个临时文件,并且打开.

python简单的多进程管理服务器 不指定

kangyang , 2014/08/04 14:43 , Python , 评论(0) , 阅读(3037) , Via 本站原创

import multiprocessing
import time,os,math


def func(msg):
    output=os.popen("ssh %s hostname" %(msg)).read()
    print output


if __name__ =="__main__":
    flist=open('b').readlines()
    pool =multiprocessing.Pool(processes=7)
    for i in flist:
        msg=i.replace('\n','')
        pool.apply_async(func, (msg, ))
    pool.close()
    pool.join()
    print"Sub-process(es) done."

b文件是个IP列表
一个IP一行即可
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]