Select to view content in your preferred language

Saving Processing Results to a text file

1765
14
09-02-2011 04:28 AM
ChristinaGnadinger
New Contributor II
I am hoping that this is a simple question.

I'm running python scripts through the Windows scheduled tasks and would like to come in the next morning to make sure the processes have ran completely, and without errors. Is there a command line I can insert into the python scripts that can output these result to a text file for me?

Thank you in advance for your help!
Christina
Tags (2)
0 Kudos
14 Replies
MalcolmParnell2
New Contributor
Here is a way you can do it; writes the text file and sends an email. The trickiest bit is getting it to work with your specific SMTP email server. If you have gmail it's easy as pie; if not - google around...

...

Let me know how you get on.


Thanks Stacey, that's a massive help.

I tried with my gmail account, but didn't have success.

The error I get is
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it


I suspect it may be something to do with our firewall blocking a port, although I really don't know. I'm pretty sure the "target machine" is actually ours, not smtp.gmail.com . This is somewhat out of my knowledge base! Google hasn't helped a great deal yet ...

Anyone with any suggestions? This really is a great way to report exceptions in batch processing, as everyone gets tired really quickly of checking log files, especially when they're (hopefully) mostly not containing any errors.

Mal
0 Kudos
StacyRendall1
Occasional Contributor III
Malcolm,

The actual email sending code was amalgamated from some examples I found on the net, I don't know much about it other than that it worked for me (and what I have picked up from mucking around with different email clients over the years)!

Some googling revealed that your problem may be to do with a firewall  - see  here. Do you have a firewall on your computer? Are Python and ArcGIS allowed to communicate through it? My firewall pops up a little message any time a new program tries to get through it, but it could be automatically blocked on yours.

If you are using a workplace computer it may be that your workplace has some kind of firewall that is blocking your connection to gmail (but if you can access gmail from your workplace, this probably isn't the case)... Your other option, if it is a workplace computer you are using, is that you might be able to try and get the SMTP server details for your work email - so it would instead be the sender - and do it that way. Depending on the type of security that server has, you might need to make some changes to the code.

Let me know how it goes!

p.s. Just found this - a list of potential causes, and solutions, for "No connection could be made because the target machine actively refused it." errors...
0 Kudos
MalcolmParnell2
New Contributor
Malcolm,

Some googling revealed that your problem may be to do with a firewall  -...

If you are using a workplace computer it may be that your workplace has some kind of firewall that is blocking your connection to gmail (but if you can access gmail from your workplace, this probably isn't the case)...


Stacy (and others),
Yes, it's a work computer related issue. I've tried this at home on my personal computer and it has worked perfectly. Now for the difficult bit - trying to get an answer from the work IT people!

Thanks again for your help and I'll be following your blog.

Mal
0 Kudos
MalcolmParnell2
New Contributor
Stacy (and others),
Yes, it's a work computer related issue. I've tried this at home on my personal computer and it has worked perfectly. Now for the difficult bit - trying to get an answer from the work IT people!

Thanks again for your help and I'll be following your blog.

Mal


A follow up: Looks like McAfee is configured to block outgoing connections to port 25 to prevent worms: Anti-virus Standard Protection:Prevent mass mailing worms from sending mail xxx.xxx.xx.xxx:25

Unfortunately for me at least, I think this is a show stopper. The chance of me being able to convince IT to open this up is, to quote local vernacular, Buckley's and none.
0 Kudos
StacyRendall1
Occasional Contributor III
Malcolm, as I said previously, you might be able to get the details for the SMTP server for your work email from IT, rather than using Gmail. Then you won't be making an outgoing connection - it will be just like sending a normal email...

Hell, you might even be able to get the details yourself by trawling around your email program (Outlook or whatever) - you need to find:

  • server name - i.e. smtp.comany.com

  • port - i.e. 587

  • security type - i.e. TLS or SSL

0 Kudos