Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2017-01-03 07:04:24| 1.1| 1.1|INFORM|FME 2016.1.2.1 (20160929 - Build 16674 - WIN32)
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|FME_HOME is 'C:\apps\FME16\'
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|FME Desktop Professional Edition (floating), FME Database Edition (node locked-crc)
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|Serial Number: 0
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|Temporary License: 24 days left.
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|Machine host name is: DT3011
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|START - ProcessID: 4368, peak process memory usage: 29364 kB, current process memory usage: 29364 kB
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|FME Configuration: Command line arguments are `C:\apps\FME16\fme.exe' `C:/Users/morij/Desktop/FinalWorkbenches\wb-xlate-1483445062964_3076' `LOG_STANDARDOUT' `YES' `LogCountServerName' `{46089640-82ee-4614-8f63-e906884bef63}'
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|Using FME's provided Python interpreter from `C:\apps\FME16\fmepython27\python27.dll'
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|Python version 2.7 loaded successfully
- 2017-01-03 07:04:24| 1.1| 0.0|INFORM|FME_BEGIN_PYTHON: evaluating python script from string...
- 2017-01-03 07:04:27| 2.3| 1.1|ERROR |Python Exception <KeyError>: 'success'
- 2017-01-03 07:04:27| 2.3| 0.0|ERROR |Error executing string `def getToken(adminUser, pw):
- data = {'username': adminUser,
- 'password': pw,
- 'referer' : 'https://www.arcgis.com',
- 'f': 'json'}
- url = 'https://arcgis.com/sharing/rest/generateToken'
- jres = requests.post(url, data=data, verify=False).json()
- return jres['token'],jres['ssl']
- #generates account information
- def GetAccount(pref, tokenfun):
- URL= pref+'www.arcgis.com/sharing/rest/portals/self?f=json&token=' + tokenfun
- response = requests.get(URL, verify=False)
- jres = json.loads(response.text)
- return jres['urlKey']
- import requests, json
- #Enter Username and Password
- user= "MoriJLumos2" #raw_input('What is the ArcGIS Online Username?')
- pw = "<mypass>" #raw_input('What is the ArcGIS Online Password?')
- #get account information
- token= getToken(user, pw)
- if token[1] == False:
- pref='http://'
- else:
- pref='https://'
- #Create Portal URL
- t=GetAccount(pref,token[0])
- portalUrl=pref+t
- restURL='https://services2.arcgis.com/idZndEogp4LoOmcv/arcgis/rest/admin/services/IRU_Underground_Fiber/FeatureServer' #modify URL
- defCapabilities= '{"hasStaticData":false,"capabilities":"Query,Editing,Create,Update,Delete,Extract"}' #editing enabled (uncomment this before updating a service)
- #defCapabilities= '{"capabilities":"Query"}' #editing disabled (uncomment this after updating a service)
- data = {'updateDefinition': defCapabilities,
- 'token':token[0],
- 'f': 'json'}
- #Send Request
- res =requests.post(restURL, data = data, verify=False).json()
- print res
- if res['success']==True:
- print 'Service successfully Added'
- else:
- print 'Service NOT ADDED''
- 2017-01-03 07:04:27| 2.3| 0.0|ERROR |FME_BEGIN_PYTHON failed to execute provided script
- 2017-01-03 07:04:27| 2.3| 0.0|INFORM|FME Session Duration: 3.4 seconds. (CPU: 2.1s user, 0.2s system)
- 2017-01-03 07:04:27| 2.3| 0.0|INFORM|END - ProcessID: 4368, peak process memory usage: 45992 kB, current process memory usage: 45992 kB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement