Skip to content

Commit e3432e3

Browse files
committed
增加hosts.txt文件不存在判断
1 parent fc7222b commit e3432e3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

check_ping.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/python
2+
#coding:utf-8
23
import multiprocessing
34
import re
4-
import sys
5+
import sys,os
56
import commands
67
import datetime
78
def pinger(ip):
@@ -21,6 +22,9 @@ def pinger(ip):
2122

2223

2324
if __name__ == "__main__":
25+
if not os.path.exists("hosts.txt") :
26+
print "\033[31mhosts.txt文件不存在,请重试\033[0m"
27+
sys.exit(1)
2428
now=datetime.datetime.now()
2529
file=open('hosts.txt','r')
2630
pool=multiprocessing.Pool(processes=4)

0 commit comments

Comments
 (0)