-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_conf.py
More file actions
36 lines (35 loc) · 1.11 KB
/
Copy pathread_conf.py
File metadata and controls
36 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*-coding:utf-8-*-
# @Author : gzq
# @date : 2018/2/28 0028 14:22
# @file : read_conf.py
import ConfigParser
import os
import sys
#部署服务和端口配置文件 server.conf
serverConf = "server.conf"
def readConf(type):
import ConfigParser
cf = ConfigParser.ConfigParser()
cf.read(serverConf)
serverNameDict = {}
portDict = {}
for serverName in cf.sections():
#print 'serverName:%s' % serverName
for optins in cf.options(serverName):
# 取服务名下的对应的配置和参数
port = cf.get(serverName, optins)
portDict[optins] = port
serverNameDict[serverName] = portDict
portDict={}
return serverNameDict
if __name__ == "__main__":
# if not os.path.exists(os.path.join(os.getcwd(),serverConf)):
# print "serverconf is not exists,check serverconf"
# print """ %s like this:
# [servername]
# http_port = 8810
# ajp_port = 8820
# shutdown_port = 8830""" % serverConf
# sys.exit()
print readConf(type)