Exemplo n.º 1
0
from django_cron import cronScheduler, Job

from commits.models import Repository

class UpdateRepository(Job):
    run_every = 300

    def job(self):
        for repository in Repository.objects.all():
            repository.Update()
            print 'updated project: %s' % repository.name

cronScheduler.register(UpdateRepository)

Exemplo n.º 2
0
from django_cron import cronScheduler, Job
import models
from django.utils import timezone
import datetime
from mailer import send_job_reminder


class Send_Job_Reminders(Job):
    run_every = 60  # every minute, but the cron library does it every 10minutes so it gets executed between 10 and 11 minutes

    def job(self):
        now = datetime.datetime.now()
        end = now + datetime.timedelta(days=1)
        for job in models.Job.objects.filter(time__range=(now, end),
                                             reminder_sent__exact=False):
            participants = []
            emails = []
            for bohne in models.Boehnli.objects.filter(job_id=job.id):
                if bohne.loco is not None:
                    participants.append(str(bohne.loco))
                    emails.append(bohne.loco.email)
            send_job_reminder(emails, job, ", ".join(participants),
                              "http://meine.gartenkooperative.li")
            job.reminder_sent = True
            job.save()
            print("reminder sent for job " + str(job.id))


cronScheduler.register(Send_Job_Reminders)
Exemplo n.º 3
0

class MeetingRemainder(Job):
    """
        Cron Job that checks the lgr users mailbox and adds any approved senders' attachments to the db
    """

    # run every 43200 seconds (12 minutes)
    run_every = 60

    def job(self):
        # This will be executed every 1 minutes
        book_conference_room = BookConference.objects.all()
        meeting = MeetingAttendees.objects.filter(
            conference_room=book_conference_room.name_of_meeting)
        conference = BookConference.objects.filter(
            meeting_date=(datetime.date.today()))
        print datetime.date.today()
        email_subject = 'Remainder Mail'
        emailMessage = 'Today is the date for the meeting ' + str(
            book_onference_room.name_of_meeting) + '.'
        for each in User.objects.filter(is_active='True').exclude(
                username='******'):
            for each1 in meeting:
                if str(each1.attendees) == str(each.username):
                    Email().send_email(email_subject, message, [each.email],
                                       CONTENT_TYPE)


cronScheduler.register(MeetingRemainder)
Exemplo n.º 4
0
import sys
sys.path.append("../")
from django_cron import cronScheduler, Job

# This is a function I wrote to check a feedback email address
# and add it to our database. Replace with your own imports
#from MyMailFunctions import check_feedback_mailbox
from blog import sourcelink


class CheckNews(Job):
    """
	Cron Job that checks the lgr users mailbox and adds any 
	approved senders' attachments to the db
	"""

    # run every 300 seconds (5 minutes)
    run_every = 3

    def job(self):
        # This will be executed every 5 minutes
        sourcelink.test()


print '--cronScheduler.register is start.'
cronScheduler.register(CheckNews)
Exemplo n.º 5
0
from django_cron import cronScheduler, Job

from ioestu.endofday import *

class CheckMail(Job):
	"""
	Cron Job that checks the lgr users mailbox and adds any 
	approved senders' attachments to the db
	"""

	# run every 300 seconds (5 minutes)
	run_every = 300
		
	def job(self):
		backupDatabase()

cronScheduler.register(CheckMail)
Exemplo n.º 6
0
# This file works with our fork of django-cron.
# It's use is optional
# Use any means you like to run scheduled jobs.

from django_cron import cronScheduler
from django_cron import Job
from django_cron import DAY
from link_report.utils import update_sentry_404s
from link_report.link_report_settings import DISABLE_UPDATE_SENTRY_CRON


class RunUpdateSentry404s(Job):

    run_every = DAY
    unreliable = DAY * 3

    def job(self):
        update_sentry_404s()


if DISABLE_UPDATE_SENTRY_CRON:
    pass
else:
    cronScheduler.register(RunUpdateSentry404s)
Exemplo n.º 7
0
from django_cron import cronScheduler, Job, HOUR, DAY, WEEK, MONTH
from .models import Campaign


class DeleteMe(Job):
    run_every = HOUR / 60

    def job():
        obj = Campaign.objects.get(name='deletme')
        obj.delete()


cronScheduler.register(DeleteMe)
Exemplo n.º 8
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from django_cron import cronScheduler, Job
from datetime import datetime, timedelta
from django.contrib.auth.models import User
from tools.runapp import deleteJob
from tools.models import Job as toolJob

class deleteOldChemmmineR(Job):

    run_every = 4000

    def job(self):
        how_many_days = 60
        user = User.objects.get(username='******')
        oldJobs = toolJob.objects.filter(user=user,start_time__lte=datetime.now()-timedelta(days=how_many_days))

        for thisjob in oldJobs:
            deleteJob(thisjob.user, thisjob.id)

cronScheduler.register(deleteOldChemmmineR)
Exemplo n.º 9
0
from django_cron import cronScheduler, Job

# This is a function I wrote to check a feedback email address
# and add it to our database. Replace with your own imports

class TestJob(Job):
    run_every = 240
    def job(self):
        print '\nThe test cron job was called.\n'

cronScheduler.register(TestJob)
Exemplo n.º 10
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from django_cron import cronScheduler, Job
from datetime import datetime, timedelta
from django.contrib.auth.models import User
from tools.runapp import deleteJob
from tools.models import Job as toolJob


class deleteOldChemmmineR(Job):

    run_every = 4000

    def job(self):
        how_many_days = 60
        user = User.objects.get(username='******')
        oldJobs = toolJob.objects.filter(user=user,
                                         start_time__lte=datetime.now() -
                                         timedelta(days=how_many_days))

        for thisjob in oldJobs:
            deleteJob(thisjob.user, thisjob.id)


cronScheduler.register(deleteOldChemmmineR)
Exemplo n.º 11
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from django_cron import cronScheduler, Job
from runapp import deleteOrphanJobs


class deleteOrphans(Job):

    run_every = 4000

    def job(self):
        deleteOrphanJobs()


cronScheduler.register(deleteOrphans)
Exemplo n.º 12
0
# -*- coding: utf-8 -*-

from django_cron import cronScheduler, Job
from products.models import Product
from dargent.imageripper import ImageRipper
from dargent.settings import MEDIA_URL, MEDIA_ROOT
from products.models import ProductsWithDefaultImageManager

class CronAddImagesJob( Job ):
	run_every = 3600
	NUM_PRODUCTS = 10

	def job( self ):
		try:
			products = Product.products_with_default_image.all()[0: CronAddImagesJob.NUM_PRODUCTS]
			for product in products:
				if product.image == ProductsWithDefaultImageManager.DEFAULT_IMAGE:
					image_ripper = ImageRipper( directory = MEDIA_ROOT )
					image = image_ripper.rip_one_image( product.name.encode( 'utf-8' ) )
					if image != None:
						product.image = image
						product.save()
		except:
			pass
		
cronScheduler.register( CronAddImagesJob )
Exemplo n.º 13
0
'''
Created on 24/06/2011

@author: crispamares
'''
from django_cron import cronScheduler, Job

# This is a function I wrote to check a feedback email address and add it to our database. Replace with your own imports
from models import feed_stocks, is_bolsa_opened

class GetStocks(Job):
        """
                Cron Job that checks the lgr users mailbox and adds any approved senders' attachments to the db
        """

        # run every 60 seconds (1 minute)
        run_every = 45
        open
        def job(self):
                # This will be executed every 5 minutes
                if is_bolsa_opened(): 
                    feed_stocks()
                else:
                    print "Bolsa Cerrada"

cronScheduler.register(GetStocks)
Exemplo n.º 14
0
from django_cron import cronScheduler, Job
from shuttletxt.views import get_shuttles
import logging

class log_out(Job):
    
    run_every = 2 # seconds
            
    def job(self):
        logging.info('hit server')
        get_shuttles()

cronScheduler.register(log_out)
Exemplo n.º 15
0
from linkcheck.utils import check_links
from linkcheck.utils import find_all_links

from linkcheck.linkcheck_settings import EXTERNAL_RECHECK_INTERVAL
from linkcheck.linkcheck_settings import MAX_CHECKS_PER_RUN


class RunLinkCheckFind(Job):

        run_every = WEEK

        def job(self):
            find_all_links()

cronScheduler.register(RunLinkCheckFind)


class RunLinkCheckInternal(Job):

        run_every = WEEK

        def job(self):
            check_links(limit=MAX_CHECKS_PER_RUN, check_external=False)

cronScheduler.register(RunLinkCheckInternal)


class RunLinkCheckExternal(Job):

        run_every = WEEK
Exemplo n.º 16
0
from django_cron import cronScheduler, Job

class printMyMess(Job):
    # run every 60 seconds (1 minute)
    run_every = 60

    def job(self):
		print('Cron WORKING!!!!!!!!!!!!!!!!!!!!!!!!!!!')

cronScheduler.register(printMyMess)
Exemplo n.º 17
0
from django_cron import cronScheduler, Job
from reminders.views import send_reminder
from models import Reminder
from datetime import datetime
from django.contrib.auth.models import User


class sendMail(Job):
    run_every = 100

    def job(self):
        cron_test()


cronScheduler.register(sendMail)
Exemplo n.º 18
0
    # print '--class.checknews()'
    # run every 60 seconds (1 minutes)
    # run_every = 60*30     #30·ÖÖÓ¼ì²éÒ»´Î 
    run_every = 60*10      

    def job(self):
        # This will be executed every 5 minutes
        if debug: print '--checknews_cron.cron.py > job() is start'
        #sourcelink.test()
        sourcelink.dispatcher()
        #sourcelink.test()
        if debug: print '--checknews_cron.cron.py > job() is finished'


#print '--cronScheduler.register is start.'
cronScheduler.register(CheckNews)
#cronScheduler.execute()

'''
from dateutil.tz import tzlocal
localtimezone = tzlocal.get_localzone()
print '--localtimezone:',localtimezone
'''

#import time
#print '--',time.timezone
#print '--','Etc/GMT%+d' % (time.timezone / 3600)
#offsetHour = time.timezone / 3600
#return 'Etc/GMT%+d' % offsetHour
Exemplo n.º 19
0
'''
Created on 24/06/2011

@author: crispamares
'''
from django_cron import cronScheduler, Job

# This is a function I wrote to check a feedback email address and add it to our database. Replace with your own imports
from models import feed_news_papers

class GetNews(Job):
        run_every = 1800 #(30 minutes)
                
        def job(self):
                # This will be executed every 5 minutes
                feed_news_papers()

cronScheduler.register(GetNews)
Exemplo n.º 20
0
from django_cron import cronScheduler, Job
from models import MailPost, MailProfile
from datetime import datetime
from django.contrib.auth.models import User
from views import sendReport

class SendReminders(Job):
    run_every = 600

    def job(self):
        need_updates = MailProfile.objects.filter(next_reminder__lt=datetime.now())
        for mailprofile in need_updates:
            sendReport(mailprofile.user)
            mailprofile.refresh_next_reminder()

cronScheduler.register(SendReminders)
Exemplo n.º 21
0
from django_cron import cronScheduler, Job

class GetTurkResults(Job):

	run_every = 300

	def job(self):
		key = os.environ['AWS_ACCESS_KEY_ID']
		secret = os.environ['AWS_SECRET_ACCESS_KEY']
		conn = boto.connect_mturk(key, secret, host='mechanicalturk.sandbox.amazonaws.com')
		done_hits = conn.get_reviewable_hits()
		for done_hit in done_hits:
			assignment = conn.get_assignments(done_hit.HITId)[0]
			if assignment.AssignmentStatus == 'Submitted':
				conn.approve_assignment(assignment.AssignmentId)
				form_response = assignment.answers[0][0]
				scandalous = form_response.fields[0] == 'yes'
				print(scandalous)

cronScheduler.register(GetTurkResults)
Exemplo n.º 22
0
                    deviceToken = binascii.unhexlify(target_user_profile.device_id)
                    wrapper = APNSNotificationWrapper(settings.IPHONE_PEM_PATH, True)
                    message = APNSNotification()
                    message.token(deviceToken)
                    message.alert(noti.contents.encode('utf-8'))
                    message.badge(unread_count)
                    message.sound()
                    wrapper.append(message)
                    wrapper.notify()
                    
                except Exception as e:
                    print str(e)
            print '[Cron: iPhone_APNS_Worker] Finish APNS'
            

cronScheduler.register(iPhone_APNS_Worker)


class Send_Email_Worker(Job):
    run_every = 3
    def job(self):
        emails = EmailQueue.objects.filter(is_sent=False)
        if len(emails) is not 0:
            print '[Cron: Send_Email_Worker] Start Emailing'
            for email in emails:
                try:
                    receiver = email.target_email
                    from_user = '******'+settings.EMAIL_HOST_USER+'>'
                    msg = EmailMultiAlternatives(email.subject, '', from_user, [receiver])
                    msg.attach_alternative(email.contents, "text/html")
                    msg.send()
Exemplo n.º 23
0
    run_every = 43200

    def job(self):
        # This will be executed every 1 minutes
        programs = Project.objects.filter(approvalDate = (datetime.date.today()))
        owner_email = [ each for each in programs ]
        email_subject = 'approval mail'
        emailMessage = 'Today is the project approval due date for ' + str(each.name) + '.'
        for each in owner_email :
            message = emailMessage
            try:
                Email().send_email(email_subject, message,
                    [each.apexBodyOwner.userProfile.authUser.email],
                    CONTENT_TYPE)
            except Exception, e :
                errMessage = 'Email Sending failed \n %s' % (Exception)
        allprograms = Project.objects.filter(nextInvoiceDate = (datetime.date.today()))
        invoice_email = [ each for each in allprograms ]
        invoice_subject = 'invoice mail'
        invoicemail = 'Invoice date due for ' + str(each.name) + '.'
        for eachProgram in invoice_email:
            message = invoicemail
            try:
                Email().send_email(invoice_subject, message,
                    [each.apexBodyOwner.userProfile.authUser.email],
                    CONTENT_TYPE)
            except Exception, e :
                errMessage = 'Email Sending failed \n %s' % (Exception)

cronScheduler.register(ProjectMail)
Exemplo n.º 24
0
import location_mgr
from django_cron import cronScheduler as cron
from location_mgr.models import Tick
cron.register(Tick)
Exemplo n.º 25
0
Arquivo: cron.py Projeto: LinasKo/FFT
from django_cron import Job, cronScheduler

from .utils import cleanup_guests
from . import settings

class DeleteOldGuests(Job):
    """
        Cron Job that deletes expired Sessions
    """
    run_every = settings.GUEST_DELETE_FREQUENCY
    def job(self, *args, **kwargs):
        cleanup_guests()

cronScheduler.register(DeleteOldGuests)
Exemplo n.º 26
0
Arquivo: cron.py Projeto: mwotil/nuaza
    for req in requests:
	user = req.user
	products = products.filter(Q(product_name__icontains=req.product_name.split()))
        #Q(product_condition__icontains=req.product_condition) |
        #Q(product_pricing__icontains=req.product_pricing) |
        #Q(brand__icontains=word))
        results['user'] = products
    return results

def mail_alert():

	if product_alert():
		message_body = "Hi Consumer"
		try:
		    send_mail("Product Available Notification", message_body, ['*****@*****.**'], ['*****@*****.**'])
        	except BadHeaderError:
            		return HttpResponse('Invalid header found.')

class ProductAlert(Job):
        """
                Cron Job that checks user requests and alerts them if they are available in the stores
        """
	# Job will run hourly
	run_every = 300

        def job(self):
		mail_alert()

cronScheduler.register(ProductAlert)
Exemplo n.º 27
0
class UpdateTurnStatus(Job):
    """
        Actualiza el estado de los turnos
    """
    #ejecutarse cada 10 minutos
    run_every = 60


    def job(self):
        t = datetime.datetime.now()
        date = datetime.date.today()
        hour = datetime.time(t.hour, t.minute)
        #dias pasados
        turns = Turn.objects.filter(day__date__lt=date, status=0)
        for turn in turns:
            turn.status = 4
            turn.save()

        #hasta hoy
        turns = Turn.objects.filter(day__date=date, status=0, start__lte=hour)
        for turn in turns:
            turn.status = 4
            turn.save()

        print "run job .D"



cronScheduler.register(UpdateTurnStatus)
Exemplo n.º 28
0
    # print '--class.checknews()'
    # run every 60 seconds (1 minutes)
    # run_every = 60*0.05 
    run_every = 60*60*24    #每天检查一次
    #run_every=60*0.1
        
    def job(self):
        # This will be executed every 5 minutes
        if debug: print '--class.ProxyUpdate.job()'
        #sourcelink.test()
        proxy.main()
        #sourcelink.test()

#print '--cronScheduler.register is start.'
cronScheduler.register(ProxyUpdate)
#cronScheduler.execute()


'''
from dateutil.tz import tzlocal
localtimezone = tzlocal.get_localzone()
print '--localtimezone:',localtimezone
'''

#import time
#print '--',time.timezone
#print '--','Etc/GMT%+d' % (time.timezone / 3600)
#offsetHour = time.timezone / 3600
#return 'Etc/GMT%+d' % offsetHour
Exemplo n.º 29
0
Arquivo: cron.py Projeto: Xodarap/Eipi
from django_cron import cronScheduler, Job
from eipi2.feeds.addFeeds import addFeeds
from eipi2.feeds.add_comments import add_comments
# Scheduled tasks

class UpdateFeeds(Job):
    # run every hour
    run_every = 3600
    def job(self):
        addFeeds.addAllFeeds()
        add_comments.add_comments()

cronScheduler.register(UpdateFeeds)
Exemplo n.º 30
0
from django_cron import cronScheduler, Job
import logging

class update_shuttles(Job):
    """
    Keep live track of shuttles
    """
    # run every 10 seconds
    run_every = 10
            
    def job(self):
        logging.debug('yes1!!!#131!!')

cronScheduler.register(update_shuttles)
Exemplo n.º 31
0
from django_cron import cronScheduler, Job
from messagesender import messageSender

print "Hello This is Cligo Cron"

class sendmessage(Job):
    # this code should run every 1 min = 60s
    run_every = 10
    
    def job(self):
        # this cde will execute every 5 min
        messageSender()
        ### send message

cronScheduler.register(sendmessage)
Exemplo n.º 32
0
from django_cron import cronScheduler, Job
from reminders.views import send_reminder
from models import Reminder
from datetime import datetime
from django.contrib.auth.models import User

class sendMail(Job):
    run_every = 100

    def job(self):
        cron_test()

cronScheduler.register(sendMail)

Exemplo n.º 33
0
from django_cron import cronScheduler, Job
import models
from django.utils import timezone
import datetime
from mailer import send_job_reminder


class Send_Job_Reminders(Job):
    run_every = 60 # every minute, but the cron library does it every 10minutes so it gets executed between 10 and 11 minutes

    def job(self):
        now = datetime.datetime.now();
        end = now + datetime.timedelta(1);
        for job in models.Job.objects.filter(time__range=(now, end), reminder_sent__exact=False):
            participants = []
            emails = []
            for bohne in models.Boehnli.objects.filter(job_id=job.id):
                if bohne.loco is not None:
                    participants.append(str(bohne.loco))
                    emails.append(bohne.loco.email)
            send_job_reminder(emails, job, ", ".join(participants), "http://my.ortoloco.ch")
            job.reminder_sent = True
            job.save()



cronScheduler.register(Send_Job_Reminders)

Exemplo n.º 34
0
        #Q(product_condition__icontains=req.product_condition) |
        #Q(product_pricing__icontains=req.product_pricing) |
        #Q(brand__icontains=word))
        results['user'] = products
    return results


def mail_alert():

    if product_alert():
        message_body = "Hi Consumer"
        try:
            send_mail("Product Available Notification", message_body,
                      ['*****@*****.**'], ['*****@*****.**'])
        except BadHeaderError:
            return HttpResponse('Invalid header found.')


class ProductAlert(Job):
    """
                Cron Job that checks user requests and alerts them if they are available in the stores
        """
    # Job will run hourly
    run_every = 300

    def job(self):
        mail_alert()


cronScheduler.register(ProductAlert)