Exemplo n.º 1
0
from lib.django_from_shell import start_django
start_django()

from procrasdonate.models import *
from procrasdonate.processors import Processor

def delete_all_totals():
    # delete all totals
    for t in TotalTag.objects.all():
        t.delete()
    
    for t in TotalSite.objects.all():
        t.delete()
    
    for t in TotalSiteGroup.objects.all():
        t.delete()
    
    for t in TotalRecipient.objects.all():
        t.delete()
    
    for t in TotalUser.objects.all():
        t.delete()
        
def compute_totals_from_scratch():
    delete_all_totals()
    
    # process all visits
    for v in SiteVisit.objects.all():
        TotalSite.process(v.site, v.total_amount, v.total_time, model_utils.datetime_from_sqlite(v, 'dtime'))
        TotalUser.process(v.user, v.total_amount, v.total_time, model_utils.datetime_from_sqlite(v, 'dtime'))
    
Exemplo n.º 2
0
# min (0-59)    hour (0-23)     day of month (1-31)     month (1-12)    day of week (0-6, 0=Sunday)
0       *       *       *       *       python /var/sites/twitter/twitter/imager/cron/weatherizer.py

"""

import os, sys

# if use django.conf for settings, then need to definte
# DJANGO_SETTINGS_MODULE in crontab
#from django.conf import settings
import settings
os.chdir(settings.PROJECT_PATH)

from lib import django_from_shell
django_from_shell.start_django()

from twitter.twitter_lib import multipart
import base64, urllib2

import urllib, re
from twitter.imager.models import Code, Weatherized
from twitter.models import TwitterUser

def weatherize(u):
    print "    BEFORE", u.profile_background_img_url
    u.get_user_data()
    print "    AFTER", u.profile_background_img_url
    username = u.twitter_username
    password = u.password
    zipcode  = u.zipcode
Exemplo n.º 3
0
from lib.django_from_shell import start_django
start_django()

from procrasdonate.models import *
from procrasdonate.processors import Processor


def delete_all_totals():
    # delete all totals
    for t in TotalTag.objects.all():
        t.delete()

    for t in TotalSite.objects.all():
        t.delete()

    for t in TotalSiteGroup.objects.all():
        t.delete()

    for t in TotalRecipient.objects.all():
        t.delete()

    for t in TotalUser.objects.all():
        t.delete()


def compute_totals_from_scratch():
    delete_all_totals()

    # process all visits
    for v in SiteVisit.objects.all():
        TotalSite.process(v.site, v.total_amount, v.total_time,