Аrtifactory( language : python ) が提供する REST API を使用してレポ構成を更新したい I を使用するコードがあります。関数のコードは次のとおりです。
def extractExtConfig(handle,repoUrl):
'''
Extract external repos configuration. We are specifically interested in :
1. If the repo is blackedout or not
2. Online/Offline`enter code here` status
'''
extRepos=simplejson.load(handle)
#print extRepos
#print isinstance(extRepos,dict)
#If repo is blackedout, we skip it
if extRepos['blackedOut']:
print 'blackedout'
#if repo is offline, we check if its accessibe
#if it's accessible, we make bring it online
if extRepos['offline']:
print extRepos['url']+' is offline'
try:
urllib2.urlopen(extRepos['url'])
except urllib2.URLError,e:
print str(e)
pass
except:
#print Exception
pass
else:
print 'Here we switch status'
print extRepos
#newData=simplejson.dump({'offline': 'false'})
extRepos['offline']='False'
newData=simplejson.dumps(extRepos)
print newData
print repoUrl
#test here
req=urllib2.Request(repoUrl,newData,{'Content-Type': 'application/json'})
handleNew=urllib2.urlopen(req)
response=handleNew.read()
print response
req2=urllib2.Request(repoUrl)
handlenew2=urllib2.urlopen(req2)
test=simplejson.load(handlenew2)
print test
#pass
else:
print extRepos['url']+' is onlne'
pass
したがって、コードを実行した後、問題なく実行され、構成が更新されたことを示す応答を受け取ります。しかし、上記のテストの値を出力すると、リポジトリの古い構成値が表示されます。フロントエンドから確認すると、同じ値のセットが表示されます。誰かが私がここで欠けているものを見つけるのを手伝ってくれませんか. 投稿リクエストの構文が台無しになっている可能性があります!!!