def handle(self, *args, **options): me = singleton.SingleInstance(flavor_id="crontw") print('%s: Will run the Youtube harvester' % now.strftime('%y-%m-%d_%H:%M')) youtubeLogger.log("Will run the Youtube harvesters.") try: harvestYoutube() except: youtubeLogger.exception('YOUTUBE ROUTINE HAS ENCOUNTERED A TOP-LEVEL ERROR:') finally: youtubeLogger.log("The harvest has end for the Youtube harvesters.")
def handle(self, *args, **options): me = singleton.SingleInstance(flavor_id="cronyt") m = '%s: Will run the Youtube harvester' % now.strftime('%y-%m-%d_%H:%M') print(m) youtubeLogger.log(m) try: harvestYoutube() except: youtubeLogger.exception('YOUTUBE ROUTINE HAS ENCOUNTERED A TOP-LEVEL ERROR:') finally: print(myEmailTitle[0]) print(myEmailMessage[0]) youtubeLogger.log("The harvest has ended for the Youtube harvesters",showTime=True) if not DEBUG: send_routine_email(myEmailTitle[0], myEmailMessage[0])
import threading, re, time from Youtube.models import YTChannel,YTVideo,YTPlaylist,YTPlaylistItem,YTComment,Subscription from AspiraUser.models import UserProfile from apiclient.discovery import build from apiclient.errors import HttpError from datetime import datetime, timedelta from django.utils.timezone import utc from .queues import * import os from SocialNetworkHarvester_v1p0.settings import youtubeLogger, DEBUG, YOUTUBE_VIDEOS_LOCATION log = lambda s: youtubeLogger.log(s) if DEBUG else 0 pretty = lambda s: youtubeLogger.pretty(s) if DEBUG else 0 logerror = lambda s: youtubeLogger.exception(s) global updaterExitFlag threadsExitFlag = [False] def today(): return datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0, tzinfo=utc) def xDaysAgo(x=0): return today() - timedelta(days=x) def plurial(i): if i > 1: return 's' else: return ''
from django.db import models from SocialNetworkHarvester_v1p0.models import Integer_time_label, Big_integer_time_label, Image_time_label, time_label from SocialNetworkHarvester_v1p0.settings import youtubeLogger, DEBUG log = lambda s: youtubeLogger.log(s) if DEBUG else 0 pretty = lambda s: youtubeLogger.pretty(s) if DEBUG else 0 logerror = lambda s: youtubeLogger.exception(s) from Youtube.management.commands.harvest.queues import * import re from datetime import datetime from django.utils.timezone import utc today = lambda: datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0, tzinfo=utc) ####################### YTCHANNEL ####################### class YTChannel(models.Model): _ident = models.CharField(max_length=128,null=True, unique=True) userName = models.CharField(max_length=32, null=True) description = models.CharField(max_length=8192, null=True) keywords = models.CharField(max_length=1000, null=True) profileColor = models.CharField(max_length=16, null=True) title = models.CharField(max_length=512, null=True) publishedAt = models.DateTimeField(null=True) hiddenSubscriberCount = models.BooleanField(default=False) isLinked = models.BooleanField(default=False) privacyStatus = models.CharField(max_length=32, null=True) featuredChannel = models.ManyToManyField('self',related_name='featured_by') commentCount = models.BigIntegerField(null=True) subscriberCount = models.BigIntegerField(null=True)