View Single Post
Old 10-04-2010, 06:48 PM   #4
TonytheBookworm
Addict
TonytheBookworm is on a distinguished road
 
TonytheBookworm's Avatar
 
Posts: 264
Karma: 62
Join Date: May 2010
Device: kindle 2, kindle 3, Kindle fire

I like how you implemented the the weekday check in your recipe. I have one question for you or anyone else that might know the answer.

Is there a command that can be used to abort the entire execution of a script?
Because there are several recipes I have made that I would like to include a date check so It doesn't download the feed on the weekends or only downloads it on tues and Thursdays or something like that.

so could someone please share with me the abort command ?


Nevermind, I figured it out. This will fix the issue I was wanting to be added to caibre for a weekend or weekday only feature.
Spoiler:

Code:
from datetime import date
from sys import exit

class MyLittleRecipe(BasicNewsRecipe):
   #################################################################################
   #Changelog: 
   # - added date check to terminate script in the event it is a weekend
   #################################################################################
    
    if date.today().weekday() > 4:
        print 'TERMINATED BECAUSE NOT A WEEKDAY'
        exit('terminated')

Last edited by TonytheBookworm; 10-04-2010 at 07:08 PM.
TonytheBookworm is offline   Reply With Quote