shsmi_sysdb_nex/sys_config.py

79 lines
2.3 KiB
Python
Raw Normal View History

2023-05-27 15:47:41 +08:00
# coding=utf-8
import os
import sys
import ConfigParser
from imp import reload
reload(sys)
sys.setdefaultencoding('utf8')
class BaseConfig(object):
def __init__(self, file):
config_path = os.path.split(os.path.realpath(__file__))[0] + '/' + file
self.__config = ConfigParser.ConfigParser()
self.__config.read(config_path)
def _get_config(self, section, key):
"""从配置文件读取参数 字符串类型"""
try:
return self.__config.get(section, key)
except ConfigParser.Error:
return ""
def _get_config_int(self, section, key):
"""从配置文件读取参数 int类型"""
try:
return self.__config.getint(section, key)
except ConfigParser.Error:
return 0
def _get_config_float(self, section, key):
"""从配置文件读取参数 float类型"""
try:
return self.__config.getfloat(section, key)
except ConfigParser.Error:
return 0.0
class SysConfig(BaseConfig):
def __init__(self):
super(SysConfig, self).__init__('SdeSyncSetting.config')
# 公共成员变量
self.is_debug = True
self.changed_layers_only = 0
self.last_sync_datetime = None
self.curr_sync_datetime = None
self.pathname = None
self.logfile_name = None
def eps_path(self):
return self._get_config('System', 'eps_path')
def python_path(self):
return self._get_config('System', 'python_path')
def template_name(self):
return self._get_config('System', 'template_name')
def sde_scheme(self):
return self._get_config('System', 'sde_scheme')
def eps_show_window(self):
return self._get_config('System', 'eps_show')
def eps_vbs(self):
return self._get_config('System', 'eps_vbs')
def sync_type(self):
return self._get_config('System', 'sync_type')
def updateregion(self):
return self._get_config('UpdateRegion', 'layer_name') # "UpdateRegion_A"
def updatetime_field(self):
return self._get_config('UpdateRegion', 'updatetime_field') # u'UpdateTime'
def updatetime_field_history(self):
return self._get_config('UpdateRegion', 'updatetime_field_history') # u'DeleteTime'