質問

I have a piece of code using I which I would like to update repo configuration using REST API provided by Аrtifactory( language : python ) here is the code of the functions:


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

So after I execute my code , it goes through fine and I receive a response stating that the configuration has been updated. But when I print values of test above, it shows the old config values for the repo. When I check from frontend, I see the same set of values. Can someone please help me to find what I am missing here. May be my syntax for post request is messed up!!!

役に立ちましたか?

解決

Seems like this is a bug in Artifactory which was discovered after I reported this issue to them. Bug can be tracked here: AF bug

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top