I'm having a problem calling a function from outside my main python script. The main script creates a set of text file reports. The second python script (email_reports.py) defines the functions used to send out these reports via email. I have imported email_reports into the main script and called the emailing functions. The script executes successfully but data is missing from the resulting emails. Strangely, when I call the emailing functions from within the email_reports.py script, the resulting emails are complete. I don't understand why I'm getting different results from the same function... any insight would be greatly apprectiated.
Here's the code from email_reports.py :
import mailer, time
from time import strftime
today =strftime("%B %d, %Y")
opyear = strftime("%Y")
def EmailYTDRpt(dist):
strBody = " Road Construction Line Summary\n" +
" Blocks Completed for " +
opyear + " in " + dist + "\n\n\n" + open("T:\\Road_Con\\reports\\" + dist
+ "ytd_L.txt", "rb").read() + "\n\n\n" + " Road Construction Point Features\n"
+ " Blocks Completed in " + opyear + "\n\n\n" + open
("T:\\Road_Con\\reports\\" + dist + "ytd_P.txt", "rb").read()
message = mailer.Message()
message.From = "from@email.com"
message.To = "to@email.com" # email_list
message.Subject = dist + " RDCON BLOCKS COMPLETED IN " + opyear + " - " + today
message.Body = strBody
mailer1 = mailer.Mailer('10.5.2.61')
mailer1.send(message)
return "Sent"
And here's how I'm calling it from the main script...
import sys, string, os, arcgisscripting, time, shutil, mailer, email_reports from time import ctime, strptime, strftime #rest of script here... email_reports.EmailYTDRpt(dist)

New Topic/Question
Reply




MultiQuote



|