Advertisement
Grav24

Untitled

Jan 3rd, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.32 KB | None | 0 0
  1. 2017-01-03 07:04:24|   1.1|  1.1|INFORM|FME 2016.1.2.1 (20160929 - Build 16674 - WIN32)
  2. 2017-01-03 07:04:24|   1.1|  0.0|INFORM|FME_HOME is 'C:\apps\FME16\'
  3. 2017-01-03 07:04:24|   1.1|  0.0|INFORM|FME Desktop Professional Edition (floating), FME Database Edition (node locked-crc)
  4. 2017-01-03 07:04:24|   1.1|  0.0|INFORM|Serial Number: 0
  5. 2017-01-03 07:04:24|   1.1|  0.0|INFORM|Temporary License: 24 days left.
  6. 2017-01-03 07:04:24|   1.1|  0.0|INFORM|Machine host name is: DT3011
  7. 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
  8. 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}'
  9. 2017-01-03 07:04:24|   1.1|  0.0|INFORM|Using FME's provided Python interpreter from `C:\apps\FME16\fmepython27\python27.dll'
  10. 2017-01-03 07:04:24|   1.1|  0.0|INFORM|Python version 2.7 loaded successfully
  11. 2017-01-03 07:04:24|   1.1|  0.0|INFORM|FME_BEGIN_PYTHON: evaluating python script from string...
  12. 2017-01-03 07:04:27|   2.3|  1.1|ERROR |Python Exception <KeyError>: 'success'
  13. 2017-01-03 07:04:27|   2.3|  0.0|ERROR |Error executing string `def getToken(adminUser, pw):
  14.        data = {'username': adminUser,
  15.            'password': pw,
  16.            'referer' : 'https://www.arcgis.com',
  17.            'f': 'json'}
  18.        url  = 'https://arcgis.com/sharing/rest/generateToken'
  19.        jres = requests.post(url, data=data, verify=False).json()
  20.        return jres['token'],jres['ssl']
  21.  
  22. #generates account information
  23. def GetAccount(pref, tokenfun):
  24.    URL= pref+'www.arcgis.com/sharing/rest/portals/self?f=json&token=' + tokenfun
  25.    response = requests.get(URL, verify=False)
  26.    jres = json.loads(response.text)
  27.    return jres['urlKey']
  28.  
  29.  
  30. import requests, json
  31.  
  32. #Enter Username and Password
  33. user= "MoriJLumos2" #raw_input('What is the ArcGIS Online Username?')
  34. pw = "<mypass>" #raw_input('What is the ArcGIS Online Password?')
  35.  
  36. #get account information
  37. token= getToken(user, pw)
  38. if token[1] == False:
  39.           pref='http://'
  40. else:
  41.           pref='https://'
  42. #Create Portal URL
  43. t=GetAccount(pref,token[0])
  44. portalUrl=pref+t
  45.  
  46.  
  47. restURL='https://services2.arcgis.com/idZndEogp4LoOmcv/arcgis/rest/admin/services/IRU_Underground_Fiber/FeatureServer' #modify URL
  48. defCapabilities= '{"hasStaticData":false,"capabilities":"Query,Editing,Create,Update,Delete,Extract"}' #editing enabled (uncomment this before updating a service)
  49. #defCapabilities= '{"capabilities":"Query"}' #editing disabled (uncomment this after updating a service)
  50. data = {'updateDefinition': defCapabilities,
  51.            'token':token[0],
  52.            'f': 'json'}
  53.  
  54. #Send Request
  55. res =requests.post(restURL, data = data, verify=False).json()
  56. print res
  57. if res['success']==True:
  58.    print 'Service successfully Added'
  59. else:
  60.    print 'Service NOT ADDED''
  61. 2017-01-03 07:04:27|   2.3|  0.0|ERROR |FME_BEGIN_PYTHON failed to execute provided script
  62. 2017-01-03 07:04:27|   2.3|  0.0|INFORM|FME Session Duration: 3.4 seconds. (CPU: 2.1s user, 0.2s system)
  63. 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