Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85425200
alertengine.in
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Sep 29, 03:23
Size
2 KB
Mime Type
text/x-python
Expires
Tue, Oct 1, 03:23 (2 d)
Engine
blob
Format
Raw Data
Handle
21177733
Attached To
R3600 invenio-infoscience
alertengine.in
View Options
#!@PYTHON@
## -*- mode: python; coding: utf-8; -*-
##
## $Id$
##
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
##
## CDS Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## CDS Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""Alert engine command line interface"""
__revision__ = "$Id$"
try:
import sys
import getopt
from invenio.config import version, supportemail
from invenio.alert_engine import run_alerts
from time import time
except ImportError, e:
print "Error: %s" % e
import sys
sys.exit(1)
import datetime
def usage():
print """Usage: alertengine [OPTION]
Run the alert engine.
-h, --help display this help and exit
-V, --version output version information and exit
-d --date="YEAR-MONTH-DAY" run the alertengine as if we were the
specified day, for test purposes (today)
Report bugs to <%s>""" % supportemail
def main():
date = datetime.date.today()
try:
opts, args = getopt.getopt(sys.argv[1:], "hVd:",
["help", "version", "date="])
except getopt.GetoptError:
usage()
sys.exit(2)
for o, a in opts:
if o in ("-h", "--help"):
usage()
sys.exit()
if o in ("-V", "--version"):
print __revision__
sys.exit(0)
if o in ("-d", "--date"):
year, month, day = map(int, a.split('-'))
date = datetime.date(year, month, day)
run_alerts(date)
if __name__ == "__main__":
t0 = time()
main()
t1 = time()
print 'Alert engine finished in %.2f seconds' % (t1 - t0)
Event Timeline
Log In to Comment