これを動作させるには奇妙な時間があります。ログの再帰的な辞書
私はいくつかのマシンの情報を含む辞書を持っています。パラメータに基づいて、機械が選択される。
私は選択した情報をログに書きたいと思います。しかし、再帰での私の試みは、私が行かなければならないところに私をもたらしてくれないようです。私はキーを取得しますが、値は失敗します。
これは私が明らかにログ上の点が届かない辞書
CSTU_CFG = {'A07': {
'password': 'CastAIP', # default cast password(too lazy to use LDAP)
'host':'JSIPVWCASTD01',
'port':'2280', # Ports are assumed to be 2280 but can be any
'location': 'C:Users/WDI/Documents/CSTU/DMPRST', # use os.path to convert
'gzips': 'GZIPS', # location for zip files (Backup)
'schematype':{'local', 'central', 'mngt'},
'logintv': 30,
'version': '0.9'
},
'A01': {
'machine': 'A01',
'password': 'CastAIP', # default cast password(too lazy to use LDAP)
'host':'JSIPVWCASTD01',
'port':'2280', # Ports are assumed to be 2280 but can be any
'location': 'C:Users/WDI/Documents/CSTU/DMPRST', # use os.path to convert
'gzips': 'GZIPS', # location for zip files (Backup)
'schematype':{'local', 'central', 'mngt'},
'logintv': 30,
'version': '0.9'
},
'A02': {
'machine': 'A02',
'password': 'CastAIP', # default cast password(too lazy to use LDAP)
'host':'JSIPVWCASTD01',
'port':'2280', # Ports are assumed to be 2280 but can be any
'location': 'C:Users/WDI/Documents/CSTU/DMPRST', # use os.path to convert
'gzips': 'GZIPS', # location for zip files (Backup)
'schematype':{'local', 'central', 'mngt'},
'logintv': 30,
'version': '0.9'
}
}
logname = 'CSTU_'+timestr+'_'+ schemaname + '.CLOG'
logging.basicConfig(filename=logname,filemode='a',format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s', datefmt='%H:%M:%S',level=logging.DEBUG)
logging.debug("Starting CSTU_DUMP")
# print the CSTU_CFG file into the log
for key,value in CSTU_CFG:
logging.debug(key + " => " + value)
です。私はいくつかの修正案を試しましたが、何も得られなかったり、さまざまなエラーが発生したりします。私は明らかにそれをハードコードすることができますが、それは意図ではありません。 ありがとう
ありがとうございました - 意味を成していたし、完全に働いています。ロギングには文字列が必要でしたので、キーと値を文字列として再作成する必要がありましたが、うまく機能しました。ありがとうございました ! (そして私は次回のさまざまなエラーを含みます。ありがとうございます) – WDickens
ようこそ。答えは受け入れられているか、またはアップヴォートとしてマークすることを検討してください。 –
方法を探しています。ありがとう – WDickens