Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit f579279

Browse files
authored
Merge pull request #70 from edx/yro/release_bugfix
1.2.0 Release Debug
2 parents e0e2d4c + 56b28ce commit f579279

File tree

6 files changed

+71
-88
lines changed

6 files changed

+71
-88
lines changed

bin/heal

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python
2+
"""
3+
Deliver
4+
5+
Command Line Interface
6+
"""
27
import os
38
import sys
49
import argparse
@@ -14,12 +19,7 @@ from control.celeryapp import maintainer_healer
1419
from control.veda_heal import VedaHeal
1520
from VEDA_OS01.models import Course, Video
1621
from VEDA_OS01.transcripts import retrieve_three_play_translations
17-
18-
"""
19-
Deliver
20-
21-
Command Line Interface
22-
"""
22+
from VEDA.utils import get_config
2323

2424

2525
class HealCli:
@@ -30,6 +30,10 @@ class HealCli:
3030
self.binscript = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'heal')
3131

3232
def schedule(self):
33+
"""
34+
Reschedule Heal process via Celery ETA
35+
"""
36+
auth_dict = get_config()
3337
go_time = datetime.datetime.now(pytz.timezone("America/New_York")) \
3438
.replace(hour=0, minute=0, second=0, microsecond=0) \
3539
.astimezone(pytz.utc) + timedelta(days=1)

control/tests/test_heal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def test_heal(self):
125125
'video_active': True,
126126
},
127127
{
128-
'edx_id': '1',
128+
'edx_id': '2',
129129
'video_trans_status': 'Complete',
130130
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
131131
'video_active': False,

control/veda_file_discovery.py

+24-33
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,59 @@
1+
"""
2+
multi-point videofile discovery
3+
Currently:
4+
Amazon S3 (studio-ingest as well as about/marketing
5+
video ingest
6+
)
7+
Local (watchfolder w/o edit priv.)
8+
9+
"""
110

211
import json
312
import logging
13+
import os.path
14+
415
import boto
516
import boto.s3
6-
from boto.exception import S3ResponseError, S3DataError
7-
17+
from boto.exception import NoAuthHandlerFound, S3DataError, S3ResponseError
818
from opaque_keys import InvalidKeyError
919
from opaque_keys.edx.keys import CourseKey
1020

21+
from control_env import *
1122
from VEDA.utils import extract_course_org, get_config
23+
from veda_file_ingest import VedaIngest, VideoProto
1224
from VEDA_OS01.models import TranscriptCredentials
25+
from veda_utils import ErrorObject
26+
from veda_val import VALAPICall
1327

1428
try:
1529
boto.config.add_section('Boto')
1630
except:
1731
pass
1832
boto.config.set('Boto', 'http_socket_timeout', '100')
1933

20-
"""
21-
multi-point videofile discovery
22-
Currently:
23-
FTP
24-
Amazon S3 (studio-ingest as well as about/marketing
25-
video ingest
26-
)
27-
Local (watchfolder w/o edit priv.)
28-
29-
"""
30-
from control_env import *
31-
from veda_utils import ErrorObject
32-
from veda_file_ingest import VideoProto, VedaIngest
33-
from veda_val import VALAPICall
34-
3534
LOGGER = logging.getLogger(__name__)
3635

3736

3837
class FileDiscovery(object):
3938

4039
def __init__(self, **kwargs):
4140
self.video_info = {}
42-
4341
self.auth_dict = get_config()
44-
4542
self.bucket = None
46-
"""
47-
FTP Server Vars
48-
"""
49-
self.ftp_key = None
50-
self.ftp_follow_delay = str(5000)
51-
self.ftp_log = "/Users/Shared/edX1/LG/Transfers.log"
52-
self.wfm_log = "/Users/Shared/edX1/LG/WFM.log"
53-
self.ftp_faillog = "/Users/Shared/edX1/LG/FailedTransfers.log"
5443
self.node_work_directory = kwargs.get('node_work_directory', WORK_DIRECTORY)
5544

5645
def about_video_ingest(self):
5746
"""
5847
Crawl VEDA Upload bucket
5948
"""
6049
if self.node_work_directory is None:
61-
ErrorObject().print_error(
62-
message='No Workdir'
63-
)
50+
print '[Discovery Error] No Workdir'
51+
return
52+
try:
53+
conn = boto.connect_s3()
54+
except NoAuthHandlerFound:
55+
print '[Discovery Error] BOTO Auth Handler'
6456
return
65-
conn = boto.connect_s3()
66-
6757
try:
6858
self.bucket = conn.get_bucket(self.auth_dict['veda_s3_upload_bucket'])
6959
except S3ResponseError:
@@ -217,7 +207,6 @@ def download_video_to_working_directory(self, key, file_name, file_extension):
217207
"""
218208
if len(file_extension) == 3:
219209
file_name = u'{file_name}.{ext}'.format(file_name=file_name, ext=file_extension)
220-
221210
try:
222211
key.get_contents_to_filename(os.path.join(self.node_work_directory, file_name))
223212
file_ingested = True
@@ -263,6 +252,8 @@ def discover_studio_ingested_videos(self):
263252
self.validate_metadata_and_feed_to_ingest(video_s3_key=self.bucket.get_key(video_s3_key.name))
264253
except S3ResponseError:
265254
ErrorObject.print_error(message='[File Ingest] S3 Ingest Connection Failure')
255+
except NoAuthHandlerFound:
256+
ErrorObject.print_error(message='[Discovery Error] BOTO Auth Handler')
266257
else:
267258
ErrorObject.print_error(message='[File Ingest] No Working Node directory')
268259

control/veda_file_ingest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def queue_job(self):
162162
jobid = uuid.uuid1().hex[0:10]
163163
celeryapp.worker_task_fire.apply_async(
164164
(veda_id, encode_profile, jobid),
165-
queue=self.auth_dict['celery_worker_queue']
165+
queue=self.auth_dict['celery_worker_queue'].split(',')[0]
166166
)
167167

168168
"""

control/veda_heal.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def send_encodes(self):
8585
jobid = uuid.uuid1().hex[0:10]
8686
celeryapp.worker_task_fire.apply_async(
8787
(veda_id, encode_profile, jobid),
88-
queue=self.auth_dict['celery_worker_queue']
88+
queue=self.auth_dict['celery_worker_queue'].split(',')[0]
8989
)
9090

9191
def determine_fault(self, video_object):
@@ -95,15 +95,15 @@ def determine_fault(self, video_object):
9595
LOGGER.info('[HEAL] : {id}'.format(id=video_object.edx_id))
9696
if self.freezing_bug is True:
9797
if video_object.video_trans_status == 'Corrupt File':
98+
self.val_status = 'file_corrupt'
9899
return []
99100

100-
if video_object.video_trans_status == 'Review Reject':
101+
if video_object.video_trans_status == 'Review Reject' or video_object.video_trans_status == 'Review Hold' or \
102+
video_object.video_trans_status == 'Review Hold':
101103
return []
102104

103-
if video_object.video_trans_status == 'Review Hold':
104-
return []
105-
106-
if video_object.video_active is False:
105+
if video_object.video_trans_status == 'Youtube Duplicate':
106+
self.val_status = 'duplicate'
107107
return []
108108

109109
"""

youtube_callback/sftp_id_retrieve.py

+29-41
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33
44
"""
55
import datetime
6-
from datetime import timedelta
7-
import django
8-
from django.utils.timezone import utc
96
import fnmatch
107
import os
11-
from os.path import expanduser
12-
import pysftp
138
import shutil
149
import sys
1510
import xml.etree.ElementTree as ET
11+
from datetime import timedelta
12+
from os.path import expanduser
13+
14+
import django
15+
import pysftp
16+
from django.utils.timezone import utc
17+
18+
from control.veda_utils import ErrorObject, Metadata, VideoProto
19+
from control.veda_val import VALAPICall
20+
from frontend.abvid_reporting import report_status
21+
from VEDA_OS01.models import URL, Encode, Video
22+
from youtube_callback.daemon import get_course
1623

1724
project_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1825
if project_path not in sys.path:
@@ -21,11 +28,6 @@
2128
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'VEDA.settings.local')
2229
django.setup()
2330

24-
from VEDA_OS01.models import Video, Encode, URL
25-
from frontend.abvid_reporting import report_status
26-
from control.veda_val import VALAPICall
27-
from control.veda_utils import ErrorObject, Metadata, VideoProto
28-
from youtube_callback.daemon import get_course
2931

3032
"""
3133
Defaults:
@@ -72,19 +74,16 @@ def xml_downloader(course):
7274
cnopts = pysftp.CnOpts()
7375
cnopts.hostkeys = None
7476

75-
try:
76-
with pysftp.Connection(
77-
'partnerupload.google.com',
78-
username=course.yt_logon,
79-
private_key=private_key,
80-
port=19321,
81-
cnopts=cnopts
82-
) as s1:
83-
for d in s1.listdir_attr():
84-
crawl_sftp(d=d, s1=s1)
85-
except:
86-
ErrorObject.print_error("Failed Auth: Youtube SFTP")
87-
return None
77+
with pysftp.Connection(
78+
'partnerupload.google.com',
79+
username=course.yt_logon,
80+
private_key=private_key,
81+
port=19321,
82+
cnopts=cnopts
83+
) as s1:
84+
s1.timeout = 60.0
85+
for d in s1.listdir_attr():
86+
crawl_sftp(d=d, s1=s1)
8887

8988

9089
def crawl_sftp(d, s1):
@@ -284,30 +283,25 @@ def urlpatch(upload_data):
284283
return None
285284

286285
if len(encode_list) == 0:
287-
Video.objects.filter(
288-
edx_id=upload_data['edx_id']
289-
).update(
290-
video_trans_status='Complete'
291-
)
286+
Video.objects.filter(edx_id=upload_data['edx_id']).update(video_trans_status='Complete')
292287
val_status = 'file_complete'
293-
294288
else:
295289
val_status = 'transcode_active'
296290

297-
VAC = VALAPICall(
291+
ApiConn = VALAPICall(
298292
video_proto=video_proto,
299293
val_status=val_status,
300294
endpoint_url=upload_data['youtube_id'],
301295
encode_profile='youtube'
302296
)
303-
VAC.call()
297+
ApiConn.call()
304298

305299
elif upload_data['status'] == 'Duplicate' and \
306300
upload_data['file_suffix'] == '100':
307301

308302
url_query = URL.objects.filter(
309303
videoID=Video.objects.filter(
310-
edx_id=test_id.edx_id
304+
edx_id=upload_data['edx_id']
311305
).latest(),
312306
encode_profile=Encode.objects.get(
313307
encode_suffix=upload_data['file_suffix']
@@ -322,12 +316,7 @@ def urlpatch(upload_data):
322316
youtube_id=''
323317
)
324318

325-
Video.objects.filter(
326-
edx_id=upload_data['edx_id']
327-
).update(
328-
video_trans_status='Youtube Duplicate'
329-
)
330-
319+
Video.objects.filter(edx_id=upload_data['edx_id']).update(video_trans_status='Youtube Duplicate')
331320
video_proto = VideoProto(
332321
veda_id=test_id.edx_id,
333322
val_id=test_id.studio_id,
@@ -336,11 +325,10 @@ def urlpatch(upload_data):
336325
bitrate='0',
337326
s3_filename=test_id.studio_id
338327
)
339-
340-
VAC = VALAPICall(
328+
ApiConn = VALAPICall(
341329
video_proto=video_proto,
342330
val_status="duplicate",
343331
endpoint_url="DUPLICATE",
344332
encode_profile='youtube'
345333
)
346-
VAC.call()
334+
ApiConn.call()

0 commit comments

Comments
 (0)