私は、pythonのConfigParserオブジェクトを使用してphp.iniファイルにオプション(xdebug.profiler_enable)を設定しようとしています。ここでのコードは次のとおりです。SafeConfigParserを使用して設定ファイルの設定オプション
[xdebug]
;XDEBUG SETTINGS
;turn on the profiler?
xdebug.profiler_enable=0
xdebug.profiler_append=1
xdebug.profiler_enable_trigger=0
xdebug.trace_output_name="%R"
xdebug.profiler_output_dir="/home/made_up_user/www/cachegrind/"
を変更しようとしているphp.iniファイルイムで セクションのPython
import sys
import ConfigParser
if __name__ == '__main__':
phpIniLocation = "/home/made_up_user/Desktop/phpinicopy.ini";
phpIni = ConfigParser.RawConfigParser();
phpIni.read(phpIniLocation);
xdebugSetting = phpIni.getboolean("xdebug", "xdebug.profiler_enable");
if xdebugSetting:
phpIni.set("xdebug", "xdebug.profiler_enable", "0");
else:
phpIni.set("xdebug", "xdebug.profiler_enable", "1");
環境: のUbuntu 9.04、のpython 2.6 すべてが正常に動作しているようです。 xdebugSetting変数はオプションのブール値を正しく返します。セクションを解析して各オプションに正しい値を取得できます。setメソッドは例外をスローしませんが、ファイルをチェックするとオプションは変更されません。 RawConfigParser、ConfigParser、およびSafeConfigParserをすべて同じ結果で使用しました。スクリプトはroot権限で実行されます。私は行方不明のものがありますか?どのように設定されたメソッドを動作させるのですか?
設定パーサーが設定ファイルを更新すると思いますか?あなたはそれをどこで読んだのですか? –