Commit e795d07f by Gregory Martin Committed by GitHub

Merge pull request #15 from edx/yro/fix_yt_csv_bug

csv fnmatch fix
parents d28bd1bc 0cfe41ce
""" """
Check SFTP dropboxes for YT Video ID XML information Check SFTP dropboxes for YT Video ID XML information
""" """
import datetime import datetime
from datetime import timedelta
import django import django
from django.utils.timezone import utc
import fnmatch import fnmatch
import newrelic.agent import newrelic.agent
import os import os
from os.path import expanduser
import pysftp import pysftp
import shutil import shutil
import sys import sys
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from os.path import expanduser
from datetime import timedelta
from django.utils.timezone import utc
project_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) project_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_path not in sys.path: if project_path not in sys.path:
sys.path.append(project_path) sys.path.append(project_path)
...@@ -28,8 +25,7 @@ from VEDA_OS01.models import Video, Encode, URL ...@@ -28,8 +25,7 @@ from VEDA_OS01.models import Video, Encode, URL
from frontend.abvid_reporting import report_status from frontend.abvid_reporting import report_status
from control.veda_val import VALAPICall from control.veda_val import VALAPICall
from control.veda_utils import ErrorObject, Metadata, VideoProto from control.veda_utils import ErrorObject, Metadata, VideoProto
from youtube_callback.daemon import get_course
from youtube_callback.daemon import generate_course_list, get_course
newrelic.agent.initialize( newrelic.agent.initialize(
os.path.join( os.path.join(
...@@ -43,7 +39,6 @@ Defaults: ...@@ -43,7 +39,6 @@ Defaults:
""" """
homedir = expanduser("~") homedir = expanduser("~")
workdir = os.path.join(homedir, 'download_data_holding') workdir = os.path.join(homedir, 'download_data_holding')
YOUTUBE_LOOKBACK_DAYS = 15 YOUTUBE_LOOKBACK_DAYS = 15
...@@ -124,11 +119,11 @@ def crawl_sftp(d, s1): ...@@ -124,11 +119,11 @@ def crawl_sftp(d, s1):
for f in s1.listdir_attr(): for f in s1.listdir_attr():
filetime = datetime.datetime.fromtimestamp(f.st_mtime) filetime = datetime.datetime.fromtimestamp(f.st_mtime)
if filetime > datetime.datetime.now() - timedelta(days=YOUTUBE_LOOKBACK_DAYS) and \ if not filetime > datetime.datetime.now() - timedelta(days=YOUTUBE_LOOKBACK_DAYS):
fnmatch.fnmatch(f.filename, '*.xml'): continue
""" if fnmatch.fnmatch(f.filename, '*.xml') or fnmatch.fnmatch(f.filename, '*.csv'):
Determine If there's an extant dl for this same ID # Determine If there are extant downloaded status files for this same ID,
""" # If yes, increment filename
x = 0 x = 0
while True: while True:
""" """
...@@ -359,9 +354,3 @@ def urlpatch(upload_data): ...@@ -359,9 +354,3 @@ def urlpatch(upload_data):
encode_profile='youtube' encode_profile='youtube'
) )
VAC.call() VAC.call()
if __name__ == "__main__":
course = get_course(course_id='COLACGIM')
if course is not None:
callfunction(course)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment