def updateWebmapService(self, webmapId, oldUrl, newUrl, folderID=None):
        try:
            params = urllib.urlencode({'token' : self.user.token,
                                       'f' : 'json'})
            print 'Getting Info for: ' + webmapId
            #Get the item data
            reqUrl = self.user.portalUrl + '/sharing/content/items/' + webmapId + '/data?' + params
            itemDataReq = urllib.urlopen(reqUrl).read()
            itemString = str(itemDataReq)

            #See if it needs to be updated
            if itemString.find(oldUrl) > -1:
                #Update the map
                newString = itemString.replace(oldUrl, newUrl)
                #Get the item's info for the addItem parameters
                itemInfoReq = urllib.urlopen(self.user.portalUrl + '/sharing/content/items/' + webmapId + '?' + params)
                itemInfo = json.loads(itemInfoReq.read(), object_hook=self.__decode_dict__)
                print 'Updating ' + itemInfo['title']

                #Set up the addItem parameters
                outParamObj = {
                    'extent' : ', '.join([str(itemInfo['extent'][0][0]), str(itemInfo['extent'][0][1]), str(itemInfo['extent'][1][0]), str(itemInfo['extent'][1][1])]),
                    'type' : itemInfo['type'],
                    'item' : itemInfo['item'],
                    'title' : itemInfo['title'],
                    'overwrite' : 'true',
                    'tags' : ','.join(itemInfo['tags']),
                    'text' : newString
                }
                # Get the item folder.
                if itemInfo['ownerFolder']:
                    folderID = itemInfo['ownerFolder']
                else:
                    folderID = ''
                #Post back the changes overwriting the old map
                modRequest = urllib.urlopen(self.user.portalUrl + '/sharing/content/users/' + self.user.username + '/' + folderID + '/addItem?' + params , urllib.urlencode(outParamObj))
                #Evaluate the results to make sure it happened
                modResponse = json.loads(modRequest.read())
                if modResponse.has_key('error'):
                    raise AGOPostError(webmapId, modResponse['error']['message'])
                else:
                    print "Successfully updated the urls"
            else:
                print 'Didn\'t find any services for ' + oldUrl
        except __HOLE__ as e:
            print 'Error - no web maps specified'
        except AGOPostError as e:
            print 'Error updating web map ' + e.webmap + ": " + e.msg
dataset/ETHPy150Open Esri/ago-tools/agoTools/utilities.py/Utilities.updateWebmapService