1

I'm fairly new at Python in general, but I'm trying to create a small background application that will read an excel file and send me an e-mail every day on some condition. I was wondering what is the best way to go about this? Should I just use some sort of loop where it does the action every so many seconds, and then execute the script from the command line? Is there a way to make it into a standalone background app? Thanks for your answers.

6
  • which operating system are you using ? Commented Jun 18, 2015 at 6:33
  • 2
    Set up your script to run repeatedly using the Windows Task Scheduler. It can run any kind of program, including things like python.exe C:\path\to\the\script.py. Commented Jun 18, 2015 at 6:34
  • You have to use startup tasks to run the python script upon startup so you don't forget to start it upon system restarts. Commented Jun 18, 2015 at 6:34
  • You could use 'threading.Timer' in combination with from 'datetime import datetime' For more information see - stackoverflow.com/questions/11523918/… Commented Jun 18, 2015 at 6:40
  • Yes I'm using Windows, and I considered the task scheduler, but then I thought, what if others wanted to download this script? So I'm trying to figure out how to make it into a standalone app. @Alexander - thanks for the tip! I wouldn't have thought of that issue. Commented Jun 19, 2015 at 19:17

1 Answer 1

1

Take a look at http://apscheduler.readthedocs.org/en/3.0/

Here is an example from there site:

from datetime import datetime
import os

from apscheduler.schedulers.blocking import BlockingScheduler


def tick():
    print('Tick! The time is: %s' % datetime.now())


if __name__ == '__main__':
    scheduler = BlockingScheduler()
    scheduler.add_executor('processpool')
    scheduler.add_job(tick, 'interval', seconds=3)
    print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))

try:
    scheduler.start()
except (KeyboardInterrupt, SystemExit):
    pass

Edit: I assumed this was the main point of your question. Re -reading however, are you wanting to know the whole process? -

  1. How to read from excel file

  2. How to automate an email

  3. How to time/ schedule the function call

  4. How to package as a desktop app

That is a loaded question. Let me know if you want me to elaborate on those points too

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer! I actually looked into this library before, I just wasn't sure how to implement it. Well, I figured out the first two points (email and excel) but my question was more oriented towards the last two (schedule and package). Could you please elaborate on the last point?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.