It can be found here: http://ideas.arcgis.com/ideaView?id=087E00000004SmHIAU
Thanks everyone.
# Get a list of fields that are not BLOB, OBJECTID, RASTER, GEOMETRY or GUID
fields = [field.name for field in arcpy.ListFields(service_table) \
if not(field.type.upper() in ['BLOB', 'OID', 'RASTER','GEOMETRY','GUID'])
# create a row list with default values
row = [""]* len(fields)
from arcpy import env
env.randomGenerator = "4 MERSENNE_TWISTER"
from arcpy import env
env.randomGenerator = arcpy.CreateRandomValueGenerator(4, "MERSENNE_TWISTER")
import arcpy
arcpy.env.randomGenerator = "4 MERSENNE_TWISTER"
result = arcpy.CalculateValue_management("arcgis.rand('normal 0.0 10.0')")
randomValue = float(result.getOutput(0))
print randomValue
import arcpy
import smtplib
import os
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
def send_mail(send_from, send_to,
subject, text,
f="",server="THE SERVER URL"):
assert type(send_to)==list
# Provide the name of your email server below
#
msg = MIMEMultipart()
msg['From'] = send_from
msg['To'] = COMMASPACE.join(send_to)
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = subject
msg.attach( MIMEText(text) )
if os.path.isfile(f):
part = MIMEBase('application', "zip")
part.set_payload( open(f,"rb").read() )
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
msg.attach(part)
smtp = smtplib.SMTP(server)
smtp.sendmail(send_from, send_to, msg.as_string())
smtp.quit()
def trace():
import traceback
import inspect
import sys
'''
trace finds the line, the filename and error message and returns it
to the user
'''
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# script name + line number
line = tbinfo.split(", ")[1]
filename = inspect.getfile( inspect.currentframe() )
# Get Python syntax error
#
synerror = traceback.format_exc().splitlines()[-1]
return line, filename, synerror
def main(*argv):
try:
# User Inputs
#
server = argv[0]
subject = argv[1]
message = argv[2]
recievers = str(argv[3]).split(';')
# Email Function
#
send_mail(
"NOTIFICATION@DONOTREPLY.COM",
recievers,
subject,
message,
"",
server)
arcpy.SetParameterAsText(4,True)
except:
arcpy.AddError(arcpy.GetMessages(2))
arcpy.AddError(str(trace()))
arcpy.SetParameterAsText(4,False)
if __name__ == "__main__":
argv = tuple(arcpy.GetParameterAsText(i)
for i in range(arcpy.GetArgumentCount()))
main(*argv)
def cleanUpFiles(directory,extension): dir = directory files = os.listdir(dir) for f in files: if not os.path.isdir(f) and extension in f: os.remove(dir + os.sep + f)
sentence = "No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise please start a new thread in this forum instead."lineLength = 90count = 0currentLine =""lines = []for word in str(sentence).split(" "): wordLength = len(word + " ") if (count + 1) < lineLength: currentLine = currentLine + word + " " else: lines.append(currentLine.strip() + "\n") currentLine = word + " " count = 0 count += wordLengthlines.append(currentLine.strip() + "\n")
mxd = arcpy.mapping.MapDocument("CURRENT")elem = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","txtTestLength")[0]elem.text = ""for line in lines: elem.text += linearcpy.RefreshActiveView()
def decimalDegrees2DMS(value,type): """ Converts a Decimal Degree Value into Degrees Minute Seconds Notation. Pass value as double type = {Latitude or Longitude} as string returns a string as D:M:S:Direction created by: anothergisblog.blogspot.com """ degrees = int(value) submin = abs( (value - int(value) ) * 60) minutes = int(submin) subseconds = abs((submin-int(submin)) * 60) direction = "" if type == "Longitude": if degrees < 0: direction = "W" elif degrees > 0: direction = "E" else: direction = "" elif type == "Latitude": if degrees < 0: direction = "S" elif degrees > 0: direction = "N" else: direction = "" notation = str(degrees) + ":" + str(minutes) + ":" +\ str(subseconds)[0:5] + "" + direction return notation