Subversion Repositories SmartDukaan

Rev

Rev 15176 | Rev 15178 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15176 Rev 15177
Line 7... Line 7...
7
from time import sleep
7
from time import sleep
8
 
8
 
9
parser = optparse.OptionParser()
9
parser = optparse.OptionParser()
10
parser.add_option("-l", "--logfile", dest="logfile",
10
parser.add_option("-l", "--logfile", dest="logfile",
11
                  type="string",
11
                  type="string",
12
                  help="Log all output to LOG_FILE",
12
                  help="Log all output to LOG_FILE"
13
                  )
13
                  )
14
parser.add_option("-i", "--pidfile", dest="pidfile",
14
parser.add_option("-i", "--pidfile", dest="pidfile",
15
                  type="string",
15
                  type="string",
16
                  help="Write the PID to pidfile")
16
                  help="Write the PID to pidfile")
17
(options, args) = parser.parse_args()
17
(options, args) = parser.parse_args()
18
 
18
 
19
class NotificationDaemon(Daemon):
19
class NotificationDaemon(Daemon):
20
    def __init__(self, logfile='/var/log/services/notification-job.log', pidfile='/var/run/notification-job.pid', mongoHost='localhost'):
20
    def __init__(self, logfile='/var/log/services/notification-job.log', pidfile='/var/run/notification-job.pid'):
21
        Daemon.__init__(self, pidfile, stdout=logfile, stderr=logfile)
21
        Daemon.__init__(self, pidfile, stdout=logfile, stderr=logfile)
22
        
22
        
23
    def run(self):
23
    def run(self):
24
        self.start()
24
        start()
25
 
25
 
26
def start():
26
def start():
27
    while True:
27
    while True:
28
        try:
28
        try:
29
            notificationBundles = list(get_mongo_connection().Catalog.Notifications.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())}}))
29
            notificationBundles = list(get_mongo_connection().Catalog.Notifications.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())}}))