configuration-files

Which design patterns can be applied to the configuration settings problem?

£可爱£侵袭症+ 提交于 2019-11-27 06:03:45
In large and complex software products managing configurable settings becomes a major pain. Two approaches I've seen to the problem are: have each component in the system load its own configuration from config files or registry settings. have a settings loader class that loads all the configurable system settings and have each component query the settings loader for its settings. These approaches both feel wrong to me. Are there any design patterns that could be used to simplify the problem? Maybe something that would take advantage of the dependency injection technique. I prefer to create an

Read all the contents in ini file into dictionary with Python

只愿长相守 提交于 2019-11-27 04:19:41
问题 Normally, I code as follows for getting a particular item in a variable as follows try: config = ConfigParser.ConfigParser() config.read(self.iniPathName) except ConfigParser.MissingSectionHeaderError, e: raise WrongIniFormatError(`e`) try: self.makeDB = config.get("DB","makeDB") except ConfigParser.NoOptionError: self.makeDB = 0 Is there any way to read all the contents in a python dictionary? For example [A] x=1 y=2 z=3 [B] x=1 y=2 z=3 is written into val["A"]["x"] = 1 ... val["B"]["z"] = 3

SSIS how to set connection string dynamically from a config file

被刻印的时光 ゝ 提交于 2019-11-27 03:49:26
I am using SQL Server Integration Services (SSIS) in SQL Server Business Intelligent Development Studio. I need to do a task that is as follows. I have to read from a source database and put it into a destination flat file. But at the same time the source database should be configurable. That means in the OLEDB Connection Manager, the connection string should change dynamically. This connection string should be taken from a configuration/XML/flat file. I read that I can use variables and expressions to change the connection string dynamically. But how do I read the connection string value from

Reading Java Properties file without escaping values

烂漫一生 提交于 2019-11-27 03:48:51
问题 My application needs to use a .properties file for configuration. In the properties files, users are allow to specify paths. Problem Properties files need values to be escaped, eg dir = c:\\mydir Needed I need some way to accept a properties file where the values are not escaped, so that the users can specify: dir = c:\mydir 回答1: Why not simply extend the properties class to incorporate stripping of double forward slashes. A good feature of this will be that through the rest of your program

Java - encrypt / decrypt user name and password from a configuration file

牧云@^-^@ 提交于 2019-11-27 03:42:16
We are busy developing a Java web service for a client. There are two possible choices: Store the encrypted user name / password on the web service client. Read from a config. file on the client side, decrypt and send. Store the encrypted user name / password on the web server. Read from a config. file on the web server, decrypt and use in the web service. The user name / password is used by the web service to access a third-party application. The client already has classes that provide this functionality but this approach involves sending the user name / password in the clear (albeit within

Reading settings from separate config file

こ雲淡風輕ζ 提交于 2019-11-27 02:54:42
问题 My asp.net app has is using a web.config for common configuration. I also have a section that maps some data objects to connection strings, and that section is going to be couple thousand of lines. I want to move that section to another config file "dataMappings.config", so I don't bulk up web.config - is there a standard mechanism of accessing that config file? Thank you, Andrey 回答1: In each section, you can define configSource , which can point to an external file path. Here's a simple

Python's ConfigParser unique keys per section

我怕爱的太早我们不能终老 提交于 2019-11-27 02:51:44
问题 I read the part of the docs and saw that the ConfigParser returns a list of key/value pairs for the options within a section. I figured that keys did not need to be unique within a section, otherwise the parser would just return a mapping. I designed my config file schema around this assumption, then sadly realized that this is not the case: >>> from ConfigParser import ConfigParser >>> from StringIO import StringIO >>> fh = StringIO(""" ... [Some Section] ... spam: eggs ... spam: ham ... """

WCF service configuration file question regarding <baseAddresses>

▼魔方 西西 提交于 2019-11-27 01:44:47
From what I've seen the tag is ignored when hosting a WCF service in IIS. I understand that when self-hosting this is required but is this harmful or even used when operating under IIS? ex. <system.serviceModel> <service blah blah blah> <host> <baseAddresses> <add baseAddress="http://localhost/blah" /> </baseAddresses> </host> </service> </system.serviceModel> From what I've seen you can take a config file describing a service from one machine and use that on a completely different machine and it works fine. It looks as if IIS completely ignores this section. Thanks, kyle As you have guessed,

Preserve case in ConfigParser?

吃可爱长大的小学妹 提交于 2019-11-27 00:59:11
问题 I have tried to use Python's ConfigParser module to save settings. For my app it's important that I preserve the case of each name in my sections. The docs mention that passing str() to ConfigParser.optionxform() would accomplish this, but it doesn't work for me. The names are all lowercase. Am I missing something? <~/.myrc contents> [rules] Monkey = foo Ferret = baz Python pseudocode of what I get: import ConfigParser,os def get_config(): config = ConfigParser.ConfigParser() config

Mercurial: How to ignore changes to a tracked file

社会主义新天地 提交于 2019-11-27 00:55:25
I have a file with database settings in my project which I have set to some defaults. The file is tracked by Mercurial and checked in. Since this file will be edited with different values various developer machines, is there a way I can tell Mercurial to ignore new changes to this file? I tried adding the file to the .hgignore file, but since the file is tracked it isn't ignored. This is alright and good in other situations, but I am wondering if there is something I can do here? Using a file template is definitely the best solution. For example, if you have a database.ini file, commit a