|
DOC
|
@JakeSkinnerThe token printed! after the token I got this error: {'returnGeometry': 'false', 'outFields': '*', 'statisticType': 'count', 'where': '1=1', 'f': 'pjson'} {u'error': {u'message': u'Token Required', u'code': 499, u'details': []}} Traceback (most recent call last): File "C:\Users\user\Desktop\TestEmailSend.py", line 69, in <module> for feat in response['features']: KeyError: 'features'
... View more
05-15-2024
11:22 AM
|
0
|
0
|
5863
|
|
DOC
|
@JakeSkinnerI dont think we have that enabled. I have to sign in sometimes
... View more
05-15-2024
10:21 AM
|
0
|
0
|
5888
|
|
DOC
|
@JakeSkinner I removed Email and username and passwords etc I changed the AGOL section using the code you provided above import requests, json, datetime, time, smtplib
from datetime import timedelta
import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Disable warnings
requests.packages.urllib3.disable_warnings()
print('This file is from testemailsend.py')
# Variables
username = 'username' # AGOL Username or Portal username
password = 'password' # AGOL Password or Portal password
URL = 'https://gis.ashland.or.us/arcgis/rest/services/Hosted/wildlife_reporter/FeatureServer/0/query' # Feature Service URL
uniqueID = 'fid' # i.e. OBJECTID
dateField = 'created_date' # Date field to query
hoursValue = 24 # Number of hours to check when a feature was added 0.08285 is 5 min
fromEmail = 'gis@ashland.or.us' # Email sender
TO = ['MyEmail'] # Email receiver
smtpServer = '**' # SMTP Server Name
portNumber = ** # SMTP Server port
AGOL = True # True if service is hosted in AGOL, False if service is hosted in Portal
portalServer = 'ServerName' # Server name portal is installed on (not web adaptor)
# Create empty list for uniqueIDs
datesighted = []
name = []
phone = []
email = []
aggressive = []
numanimal = []
animaldoing = []
reaction = []
probtype = []
oidList = []
publicview = []
details = []
# Generate AGOL token
if AGOL == True:
try:
print('Generating Token')
tokenURL = 'https://gis.ashland.or.us/arcgis/sharing/rest/generateToken/'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'https://gis.ashland.or.us/portal'}
r = requests.post(tokenURL, data=params, verify=False)
response = json.loads(r.content)
token = data['token']
print(token)
except:
token = ''
else:
# Generate Portal token
tokenURL = 'https://gis.ashland.or.us/portal/arcgis/sharing/rest/generateToken/'.format(portalServer)
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'https://gis.ashland.or.us/portal'.format(portalServer)}
r = requests.post(tokenURL, data = params, verify=False)
response = json.loads(r.content)
token = response['token']
print(token)
# Query service and check if created_date time is within the last hour
params = {'f': 'pjson', 'where': "1=1", 'outFields' : '*', 'statisticType' : 'count', 'returnGeometry' : 'false'}
r = requests.post(URL, data=params, verify=False)
response = json.loads(r.content)
print(params)
print(response)
for feat in response['features']:
createDate = feat['attributes']['created_date']
createDate = int(str(createDate)[0:-3])
t = datetime.datetime.now() - timedelta(hours=hoursValue)
t = time.mktime(t.timetuple())
if createDate > t:
datesighted.append(str(feat['attributes']['datesighte']))
name = (str(feat['attributes']['name']))
phone = (str(feat['attributes']['phone']))
email = (str(feat['attributes']['email']))
animaldoing = (str(feat['attributes']['animaldoin'])).replace(u"\u2018", "'").replace(u"\u2019", "'")
numanimal = (str(feat['attributes']['numanimal']))
if isinstance(aggressive, list):
aggressive = ', '.join(aggressive)
aggressive = aggressive.encode('utf-8')
reaction = str(feat['attributes']['reaction']).replace(u"\u2018", "'").replace(u"\u2019", "'")
probtype = (str(feat['attributes']['probtype']))
oidList = (str(feat['attributes']['fid']))
details = (str(feat['attributes']['details'])).replace(u"\u2018", "'").replace(u"\u2019", "'")
publicview = (str(feat['attributes']['publicview']))
print(oidList)
mergelist = zip(probtype, details, publicview)
print(mergelist)
# Email Info
FROM = fromEmail
SUBJECT = 'New Wildlife Sighting Has been Reported'
Total= "Features with " + " " + str(publicview) + " " + " were added."
TotalAnimals = (Total.count("Yes"))
print(TotalAnimals)
#TEXT = "There were " + " " + str(TotalAnimals) + " " + " sighting(s) added the Cougar Map within the past hour."
#TEXT = '<a href="http://maps.google.com/maps?z=12&t=m&q=loc:'+str(p['latitude'])+'+'+str(p['longitude'])+'">Click Here</a>'
tom = datesighted[0]
chosen_number = int(tom)
s = chosen_number / 1000.0
print s
dFormat = "%Y-%m-%d %H:%M:%S.%f"
datesightedconvert = datetime.datetime.fromtimestamp(s).strftime('%Y-%m-%d %H:%M:%S')
# Create the body of the message (a plain-text and an HTML version).
#TotalSighted = "There were " + " " + str(TotalAnimals) + " " + " reports(s) added the Wildlife Map within the past 5 min."
TotalSighted = "A Report has been added the Wildlife Map within the past 5 min."
Sighted = "\nAnimal Sighted : " + str(probtype)
TheDateSighted = "\nDate Sighted : " + str(datesightedconvert) + " " + " \n"
reported = "\nReporter Name: " + str(name)
PhoneNumber = "\nReporter Phone Number: " + str(phone)
ReportedEmail = "\nReporter Phone Email: " + str(email)
Aggressiveness = "\nWas animal Aggressive?: " + str(aggressive)
ReportedReaction = "\nWhat was the animal Reaction?: " + str(reaction)
ReportedDetails = "\nMore Details about the sighting: " + str(details)
AnimalDoing = "\nWhat was the Animal(s) Doing?: " + str(animaldoing)
AnimalSeen = "\nHow Many were seen?: " + str(numanimal)
Link = "\n\nView more information on the Cougar Webmap: \nhttps://gis.ashland.or.us/cougar \n\n\n "
Text = TotalSighted + TheDateSighted + Sighted + reported + PhoneNumber + ReportedEmail + Aggressiveness + ReportedReaction + ReportedDetails + AnimalDoing + AnimalSeen + Link
print ''.join(Text)
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, Text)
# If new features exist, send email
if len(oidList) > 0:
smtpObj = smtplib.SMTP(host=smtpServer, port=portNumber)
smtpObj.sendmail(FROM, TO, message)
print("Successfully sent email")
smtpObj.quit()
... View more
05-15-2024
09:51 AM
|
0
|
0
|
5899
|
|
DOC
|
@JakeSkinner I added print (token) nothing happened.
... View more
05-15-2024
09:13 AM
|
0
|
0
|
5909
|
|
DOC
|
@JakeSkinner This file is from testemailsend.py Generating Token {'returnGeometry': 'false', 'outFields': '*', 'statisticType': 'count', 'where': '1=1', 'f': 'pjson'} {u'error': {u'message': u'Token Required', u'code': 499, u'details': []}} Traceback (most recent call last): File "C:\Users\user\Desktop\TestEmailSend.py", line 68, in <module> for feat in response['features']: KeyError: 'features'
... View more
05-15-2024
08:25 AM
|
0
|
0
|
5928
|
|
DOC
|
@JakeSkinner I now get this error Traceback (most recent call last): File "C:\Users\user\Desktop\TestEmailSend.py", line 68, in <module> for feat in response['features']: KeyError: 'features'
... View more
05-15-2024
08:19 AM
|
0
|
0
|
5941
|
|
DOC
|
@JakeSkinner Yes it is shared with organization only now.
... View more
05-15-2024
07:00 AM
|
0
|
0
|
5969
|
|
DOC
|
I am using enterprise portal and my script does not seem to work now. We have decided to lock down the service to only internal employees and now the script fails. I am using a variation of the script @JakeSkinner provided. I thought it worked but now that ii is locked down it is not. Any suggestions on why its not working?
... View more
05-14-2024
12:45 PM
|
0
|
0
|
6015
|
|
POST
|
https://community.esri.com/t5/arcmap-blog/arcmap-enters-mature-support-in-march-2024/ba-p/1299695 Have you tried pro? I am growing to love it more and more
... View more
05-02-2024
07:56 AM
|
0
|
0
|
874
|
|
POST
|
Have you though about making 3d models with Drone2map https://www.esri.com/en-us/arcgis/products/arcgis-drone2map/overview You could do volume calculations or construction time laps photos from above
... View more
04-11-2024
06:33 AM
|
2
|
2
|
1144
|
|
POST
|
I keep getting this error when I mark a pdf linked document as Authoritative and then go back to the Overview screen. Step 1 View details. step 2 click on settings step 3 Mark as authoritative step 4 go back to overview. Then the error pops up. Do I need to be worried by this?
... View more
04-09-2024
02:55 PM
|
1
|
2
|
1428
|
|
POST
|
I believe you could just add an if statement. // Check if specific question is answered with a specific answer if ($feature['specific_question'] == 'specific_answer') { // Display calculated text return 'Your calculated text goes here'; } else { // If the condition is not met, return an empty string return ''; } https://community.esri.com/t5/arcgis-online-documents/conditional-field-display-with-arcade-in-pop-ups/ta-p/920869 https://github.com/Esri/arcade-expressions/tree/master/dashboard_data
... View more
04-09-2024
06:44 AM
|
0
|
0
|
1010
|
|
POST
|
@MarekDworeckiAre you able to share the link to the site so we could try it? Or the code? What version for JavaScript?
... View more
04-09-2024
06:32 AM
|
0
|
1
|
999
|
|
POST
|
Did you recently update pro? What version of pro and enterprise are you using?
... View more
04-05-2024
03:15 PM
|
0
|
1
|
2769
|
|
POST
|
I believe if you change the symbology in the map using the category field then the filter would be different based on the filter turned on.
... View more
04-05-2024
03:12 PM
|
1
|
0
|
1039
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-28-2025 01:53 PM | |
| 1 | 08-24-2022 09:40 AM | |
| 1 | 07-19-2018 04:41 PM | |
| 1 | 04-05-2024 03:12 PM | |
| 1 | 07-04-2024 11:42 AM |