POST
|
Hello Owen, Have you been able to add this functionality yet? Hoping to generate QR codes for specific places in the story map. If you haven't been able to implement this, do you have a timeframe for when you will? Thanks, Mary
... View more
07-19-2021
08:24 AM
|
0
|
3
|
1354
|
POST
|
I can't get AGO Assistant to work. I used it two years ago and it was great. Anyone used it lately?
... View more
06-17-2021
12:09 PM
|
0
|
1
|
1063
|
POST
|
I think the problem I am having is related so I'll ask for help here. I have a number of batch processes that run python scripts via task scheduler. They run great and then all the sudden a few weeks into them running flawlessly my scripts fail. Turns out my user name is getting signed out of ArcPro. I have learn that automatic sign in is only good for 14 days and then you are no longer signed it. If I manually open ArcPro and sing in my scripts go back to working fine. I tired adding arcpy.SingInToPortal to my scripts but it doesn't seem to sign me in to ArcPro and therefor does not fix the problem. If I remember correctly, arcmap with 2.7 had a way to check out a licence. So I tested checking out an extension in 3.x for Arcpro. Extension check out fine but did not sign me in. Any help would be greatly appreciated. I don't want to have to manually start ArcPro and sign in every 13 days. Buy the way, I called Technical support to ask how to "sign in" via my python script and I have not gotten an answer back yet. PLEASE HELP
... View more
04-09-2020
01:41 PM
|
0
|
3
|
2812
|
POST
|
I think the problem I am having is related so I'll ask for help here. I have a number of batch processes that run python scripts via task scheduler. They run great and then all the sudden a few weeks into them running flawlessly my scripts fail. Turns out my user name is getting signed out of ArcPro. I have learn that automatic sign in is only good for 14 days and then you are no longer signed it. If I manually open ArcPro and sing in my scripts go back to working fine. I tired adding arcpy.SingInToPortal to my scripts but it doesn't seem to sign me in to ArcPro and therefor does not fix the problem. If I remember correctly, arcmap with 2.7 had a way to check out a licence. So I tested checking out an extension in 3.x for Arcpro. Extension check out fine but did not sign me in. Any help would be greatly appreciated. I don't want to have to manually start ArcPro and sign in every 13 days. Buy the way, I called Technical support to ask how to "sign in" via my python script and I have not gotten an answer back yet. PLEASE HELP
... View more
04-09-2020
01:34 PM
|
1
|
1
|
3044
|
POST
|
Jake Skinner Thanks you for the alternative. I'm converting a script I had working in 2.7. With requests I'm able to generate a token but getting an error message when i try to query the service to see when a point was added. The error is : TypeError: the JSON object must be str, bytes or bytearray, not 'dict' Here is the bit of code giving me problems. Any thoughts? Thank you! # Query service and check if created_date time
params = {'f': 'pjson', 'where': "1=1", 'outfields': 'OBJECTID_1, AssetID, Status, Location, Notes ', 'returnGeometry': 'false', 'token' : token}
req = requests.post(tokenURL, data=params, verify=False)
response =json.loads(req.content)
data = json.loads(response)
for feat in data['features']:
Status = feat['attributes']['Status']
if Status == 6:
oidList.append(feat['attributes'][uniqueID])
AssetID.append(str(feat['attributes']['AssetID']))
Location.append(str(feat['attributes']['Location']))
Notes.append(str(feat['attributes']['Notes']))
... View more
12-26-2019
10:01 AM
|
0
|
1
|
13342
|
DOC
|
This is a great python script and I automated it for several of my feature services! My co-worked asked me to write a script to email when the status of a field becomes a certain value. I thought not problem it should be easy to modify this script to do just that. Ha! Apparently not. I just cant get this code to work. I finally have it running and returning "finished with exit code 0" but it says "No data with Status defined found" when I know there are records meeting the criteria. Any help would be much appreciated as I very new to python. import urllib2, json, smtplib, urllib, sys
from smtplib import SMTP_SSL
#Variables for your ArcGIS online account
username = 'xxx' #AGOL UserName
password = 'xxx' #AGOL password
# Feature Service URL
URL ='https://services.arcgis.com/yygmGNIVQrHqSELP/ArcGIS/rest/services/Hydrants_Survey_2019/FeatureServer/0/query'
uniqueID = 'OBJECTID_1' # i.e. OBJECTID
myBasin = 'BasinArea'
#CurrentStatus = "Status"
fromEmail = 'xx.org' # Email sender
toEmailCC = 'xx.org' # Email receiver
toEmail = 'xxslocity.org' # Email receiver
smtpServer = 'smtp.office365.com' # SMPT Server Name
portNumber = 587 # SMTP Server port
#email password and user
office365_user = 'xx.org'
office365_pwd= 'xx!'
# Create empty list for uniqueIDs, etc.
oidList = []
BasinArea = []
# Generate AGOL token
try:
print('Generating Token')
tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'http://www.arcgis.com'}
req = urllib2.Request(tokenURL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
token = data['token']
except:
token = ''
print("Token: " + str(token))
#params = {'f': 'pjson', 'where': "1=1",'outfields' : '{0}, {1}'.format(uniqueID, BasinArea), 'returnGeometry' : 'false', 'token' : token}
params = {'f': 'pjson', 'where': "1=1",'outfields' : 'OBJECTID_1, BasinArea', 'returnGeometry' : 'false', 'token' : token}
req = urllib2.Request(URL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
for feat in data['features']:
BasinName = feat['attributes'][myBasin]
BasinName = 'Reservoir Canyon1'
if BasinArea == BasinName:
oidList.append(feat['attributes'][uniqueID])
BasinArea.append(str(feat['attributes']['BasinArea']))
# Email Info
FROM = fromEmail
TO = [toEmail, toEmailCC]
SUBJECT = 'Hydrants Status Update'
TEXT ="Hydrant Status update(s) to the online map with the following: " + " " + str(BasinArea) + " " + "were added to the DPW GIS layer"
message = """ 'Subject: New GIS Feature Added'.format(SUBJECT, TEXT)
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# If features with Status defined exist, send email
if len(oidList) > 0:
smtpObj = smtplib.SMTP(host=smtpServer,port=portNumber)
smtpObj.ehlo()
smtpObj.starttls()
smtpObj.ehlo
smtpObj.login(office365_user, office365_pwd)
smtpObj.sendmail(FROM, TO, message)
print "Successfully sent email"
smtpObj.close()
else:
print "No data with Status defined found"
... View more
01-23-2019
12:06 PM
|
0
|
0
|
19732
|
DOC
|
Oh my, you were right it was not generating a token because i miss typed my user name. Silly me. I finally got it to work for Office 360 by adding my username and password with these additional lines of code in the middle. Jake, thank you for all the help and sharing this code! if len(oidList) > 0:
smtpObj = smtplib.SMTP(host=smtpServer,port=portNumber)
smtpObj.ehlo()
smtpObj.starttls()
smtpObj.ehlo
smtpObj.login(office365_user, office365_pwd)
smtpObj.sendmail(FROM, TO, message)
print "Successfully sent email"
smtpObj.close()
... View more
12-18-2018
01:41 PM
|
0
|
0
|
19732
|
DOC
|
Thanks Jake, I sent you an invitation to our "Homeless Camp" Group.
... View more
12-18-2018
11:46 AM
|
0
|
0
|
19732
|
DOC
|
Great post. Unfortunately I'm stuck with this error message Traceback (most recent call last): File "X:/...", line 43, in <module> for feat in data['features']: KeyError: 'features' Process finished with exit code 1 I believe I have the service defined correctly : URL ='https://services.arcgis.com/yygmGNIVQrHqSELP/arcgis/rest/services/HomelessCamp2019/FeatureServer/0/query' And the uniqueId in my case is OBJECTID_12 I have also tried both the time stamp field name as I see it : created_date and CreationDate. Thank you in advance for your help! Code: import urllib2, json, datetime, time, smtplib, urllib, sys
from datetime import timedelta
from smtplib import SMTP_SSL
#Varialbes
username = 'xxxxxx' #AGOL UserName
password = 'xxxxxx' #AGOL password
# Feature Service URL
URL ='https://services.arcgis.com/yygmGNIVQrHqSELP/arcgis/rest/services/HomelessCamp2019/FeatureServer/0/query'
uniqueID = 'OBJECTID_12' # i.e. OBJECTID
dateField = 'created_date' # Date field to query
hoursValue = 24 # Number of hours to check when a feature was added
fromEmail = 'xxxx@slocity.org' # Email sender
toEmail = 'xxxx@slocity.org' # Email receiver
smtpServer = 'smtp.office365.com ' # SMPT Server Name
portNumber = 587 # SMTP Server port
office365_user = 'xxxx@slocity.org'
office365_pwd= "xxxxx"
# Create empty list for uniqueIDs
oidList = []
# Generate AGOL token
try:
print('Generating Token')
tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'http://www.arcgis.com'}
req = urllib2.Request(tokenURL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
token = data['token']
except:
token = ''
# Query service and check if created_date time is within the last hour
params = {'f': 'pjson', 'where': "1=1", 'outfields' : '{0}, {1}'.format(uniqueID, dateField), 'returnGeometry' : 'false', 'token' : token}
req = urllib2.Request(URL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
for feat in data['features']:
createDate = feat['attributes'][dateField]
createDate = int(str(createDate)[0:-3])
t = datetime.datetime.now() - timedelta(hours=hoursValue)
t = time.mktime(t.timetuple())
if createDate > t:
oidList.append(feat['attributes'][uniqueID])
print(oidList)
# Email Info
FROM = fromEmail
TO = [toEmail]
SUBJECT = 'New Features Added to Homeless Camps Map'
TEXT = "Features with {0}s {1} were added.".format(uniqueID, oidList)
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# If new features exist, send email
if len(oidList) > 0:
try:
smtpObj = smtplib.SMTP(host=smtpServer, port=portNumber)
smtpObj.ehlo()
smtpObj.login(office365_user,office365_pwd)
smtpObj.sendmail(FROM, TO, message)
print "Successfully sent email"
smtpObj.quit()
except:
sys.exit("email failed:")
... View more
12-18-2018
09:51 AM
|
0
|
0
|
19732
|
POST
|
I am trying to use the JavaScript sample "Show Find Task results in DataGrid". I need to query the data. I published a feature service in ArcGIS online but I don't see any sample (JavaScript) that allow this type of query via a feature service. I would prefer an off-the-shelf solution over writing my own JavaScript from scratch. Basically if I can't query/find info, the ArcGIS online option won't work for me and it will be back to trying to talk my employee into purchasing a server. We do have an ArcGIS group subscription/account.
... View more
06-14-2012
11:27 AM
|
0
|
0
|
265
|
POST
|
I'm trying to utilize the JavaScript code samples with the feature service I created in ArcGIS online. I need a map service. When you publish a service to ArcOnline is there a way to create both a "map service" and a "feature service". The only think I can see is the "feature service". What is the map service definition (it does not see to point to a "map service")?
... View more
06-14-2012
10:08 AM
|
0
|
2
|
499
|
POST
|
When you publish a map service to ArcOnline is there a way to create both a "map service" and a "feature service". The only think I can see is the "feature service".
... View more
06-14-2012
06:48 AM
|
0
|
0
|
356
|
Title | Kudos | Posted |
---|---|---|
1 | 04-09-2020 01:34 PM |
Online Status |
Offline
|
Date Last Visited |
3 weeks ago
|