コード例 #1
0
    def __init__(self, config_file=None):
        self.config_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), seperator[1], 'environment')
        self.default_config_file = os.path.join(self.config_dir, 'default', 'env.properties')
        self.custom_config_file = os.path.join(self.config_dir, 'custom', 'env.properties')
        self.config = self.read_config_file(self.default_config_file)
                    
        if not os.path.exists(os.path.dirname(self.custom_config_file)):
            try:
                os.makedirs(os.path.dirname(self.custom_config_file))
                f = Filer()
                f.createFile(self.custom_config_file)
            except Exception as e:
                print "Error Detected: {0}".format(e)
                return False
                
        elif not os.path.isfile(self.custom_config_file):
            try:
                f = Filer()
                f.createFile(self.custom_config_file)
            except Exception as e:
                print "Error Detected: {0}".format(e)
                return False
 
        #                                  SectionName          Option        DefaultValueIfNotSet
        self.default_config_dictionary = {  'Authentication'    :   {'username'    : 'daffy',
                                                                     'password'    : 'duck'},
                                            'SMTP'              :   {'hostname'    : 'localhost',
                                                                     'port'        : '25',
                                                                     'debug'       : True,
                                                                     'mail_domain' : 'mydomain' },
                                            'Notification'      :   {'author'      : 'me@mydomain',
                                                                     'alpha'       : 'me', 
                                                                     'beta'        : '',
                                                                     'release'     : ''},
      }
コード例 #2
0
    def __init__(self, config_file=None):
        self.config_dir = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), seperator[1],
            'environment')
        self.default_config_file = os.path.join(self.config_dir, 'default',
                                                'env.properties')
        self.custom_config_file = os.path.join(self.config_dir, 'custom',
                                               'env.properties')
        self.config = self.read_config_file(self.default_config_file)

        if not os.path.exists(os.path.dirname(self.custom_config_file)):
            try:
                os.makedirs(os.path.dirname(self.custom_config_file))
                f = Filer()
                f.createFile(self.custom_config_file)
            except Exception as e:
                print "Error Detected: {0}".format(e)
                return False

        elif not os.path.isfile(self.custom_config_file):
            try:
                f = Filer()
                f.createFile(self.custom_config_file)
            except Exception as e:
                print "Error Detected: {0}".format(e)
                return False

        #                                  SectionName          Option        DefaultValueIfNotSet
        self.default_config_dictionary = {
            'Authentication': {
                'username': '******',
                'password': '******'
            },
            'SMTP': {
                'hostname': 'localhost',
                'port': '25',
                'debug': True,
                'mail_domain': 'mydomain'
            },
            'Notification': {
                'author': 'me@mydomain',
                'alpha': 'me',
                'beta': '',
                'release': ''
            },
        }