This repository has been archived by the owner on Mar 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 155
/
disable_sync_service_item.py
64 lines (53 loc) · 1.74 KB
/
disable_sync_service_item.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
This sample shows how to disable
sync on a feature service
CSV requires the following fields
- itemid - ID of AGOL item
"""
from __future__ import print_function
import arcrest
from arcrest.security import AGOLTokenSecurityHandler
from arcrest.security import PortalTokenSecurityHandler
import os, datetime
import csv
import arcresthelper
from arcresthelper import featureservicetools
from arcresthelper import common as Common
dateTimeFormat = '%Y-%m-%d %H:%M'
def trace():
"""
trace finds the line, the filename
and error message and returns it
to the user
"""
import traceback, inspect, sys
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
filename = inspect.getfile(inspect.currentframe())
# script name + line number
line = tbinfo.split(", ")[1]
# Get Python syntax error
#
synerror = traceback.format_exc().splitlines()[-1]
return line, filename, synerror
def main():
securityinfo = {}
securityinfo['security_type'] = 'Portal'
securityinfo['username'] = ""
securityinfo['password'] = ""
securityinfo['org_url'] = "http://www.arcgis.com"
try:
fst = featureservicetools.featureservicetools(securityinfo=securityinfo)
fs = fst.GetFeatureService(itemId='',returnURLOnly=False)
result = fst.disableSync(url=fs.url)
print (result)
except:
line, filename, synerror = trace()
print ("error on line: %s" % line)
print ("error in file name: %s" % filename)
print ("with error message: %s" % synerror)
finally:
print (datetime.datetime.now().strftime(dateTimeFormat))
print ("###############Script Completed#################")
if __name__ == "__main__":
main()