Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-video-worker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-video-worker
Commits
bb447aaa
Unverified
Commit
bb447aaa
authored
Apr 20, 2018
by
Gregory Martin
Committed by
GitHub
Apr 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #29 from edx/yro/ElimPrintStatements
Improve logging, delete stray print statements
parents
7ff39492
6fb83d6b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
75 deletions
+61
-75
video_worker/abstractions.py
+20
-22
video_worker/celeryapp.py
+0
-5
video_worker/generate_delivery.py
+7
-5
video_worker/reporting.py
+0
-15
video_worker/validate.py
+17
-15
video_worker/video_images.py
+17
-13
No files found.
video_worker/abstractions.py
View file @
bb447aaa
...
...
@@ -8,10 +8,10 @@ AbstractionLayer Object (acts as master abstraction)
"""
import
json
import
os
import
logging
import
requests
from
reporting
import
ErrorObject
,
Output
from
reporting
import
Output
import
generate_apitoken
from
video_worker.utils
import
get_config
from
global_vars
import
*
...
...
@@ -23,6 +23,8 @@ requests.packages.urllib3.disable_warnings()
settings
=
get_config
()
logger
=
logging
.
getLogger
(
__name__
)
class
Video
(
object
):
"""
...
...
@@ -51,20 +53,17 @@ class Video(object):
test case
"""
if
self
.
veda_id
is
not
None
and
len
(
settings
[
'veda_api_url'
])
==
0
:
ErrorObject
()
.
print_error
(
message
=
'VEDA API Config Incorrect, run test to debug'
)
return
None
logger
.
error
(
'[ENCODE_WORKER] VEDA API Config Incorrect'
)
return
if
self
.
veda_id
is
None
and
self
.
mezz_filepath
is
None
:
print
self
.
mezz_filepath
self
.
mezz_extension
=
'.mp4'
self
.
mezz_title
=
TEST_VIDEO_FILE
self
.
mezz_filepath
=
os
.
path
.
join
(
TEST_VIDEO_DIR
,
TEST_VIDEO_FILE
)
self
.
valid
=
True
return
None
if
self
.
veda_id
is
not
None
:
return
if
self
.
veda_id
:
"""
Generated Token
"""
...
...
@@ -160,10 +159,13 @@ class Encode(object):
veda_token
=
generate_apitoken
.
veda_tokengen
()
if
veda_token
is
None
:
ErrorObject
()
.
print_error
(
message
=
"VEDA Token Generate"
logger
.
error
(
'[ENCODE_WORKER] : {id} {encode} VEDA Token Generate'
.
format
(
id
=
self
.
VideoObject
.
veda_id
,
encode
=
self
.
profile_name
)
return
None
)
return
data
=
{
'product_spec'
:
self
.
profile_name
}
...
...
@@ -183,10 +185,13 @@ class Encode(object):
enc_dict
=
json
.
loads
(
x
.
text
)
if
len
(
enc_dict
[
'results'
])
==
0
:
ErrorObject
()
.
print_error
(
message
=
"VEDA API Encode Mismatch: No Data"
logger
.
error
(
'[ENCODE_WORKER] : {id} {encode} VEDA API Encode Mismatch: No Data'
.
format
(
id
=
self
.
VideoObject
.
veda_id
,
encode
=
self
.
profile_name
)
)
return
None
return
for
e
in
enc_dict
[
'results'
]:
if
e
[
'product_spec'
]
==
self
.
profile_name
and
e
[
'profile_active'
]
is
True
:
...
...
@@ -223,10 +228,3 @@ class Encode(object):
with
open
(
self
.
encode_library
)
as
data_file
:
data
=
json
.
load
(
data_file
)
return
data
[
"ENCODE_PROFILES"
]
def
main
():
pass
if
__name__
==
'__main__'
:
sys
.
exit
(
main
())
video_worker/celeryapp.py
View file @
bb447aaa
...
...
@@ -94,11 +94,6 @@ def queue_transcode(vid_name, encode_command):
pass
@app.task
def
test_command
(
message
):
print
message
if
__name__
==
'__main__'
:
app
=
cel_start
()
app
.
start
()
video_worker/generate_delivery.py
View file @
bb447aaa
...
...
@@ -6,22 +6,22 @@ from VEDA_WORK_DIR, retrieves and checks URL, and passes info to objects
import
boto
import
boto.s3
from
boto.exception
import
S3ResponseError
from
boto.s3.key
import
Key
import
hashlib
import
logging
import
os
import
sys
import
shutil
from
global_vars
import
MULTI_UPLOAD_BARRIER
,
ENCODE_WORK_DIR
from
reporting
import
ErrorObject
from
video_worker.utils
import
get_config
settings
=
get_config
()
logger
=
logging
.
getLogger
(
__name__
)
class
Deliverable
():
class
Deliverable
(
object
):
def
__init__
(
self
,
VideoObject
,
encode_profile
,
output_file
,
**
kwargs
):
self
.
VideoObject
=
VideoObject
...
...
@@ -138,8 +138,10 @@ class Deliverable():
b
=
conn
.
lookup
(
settings
[
'veda_deliverable_bucket'
])
if
b
is
None
:
ErrorObject
()
.
print_error
(
message
=
'Deliverable Fail: s3 Bucket Connection Error'
logger
.
error
(
'[ENCODE_WORKER] : {file} Deliverable Fail: s3 Bucket Connection Error'
.
format
(
file
=
self
.
output_file
)
)
return
False
...
...
video_worker/reporting.py
View file @
bb447aaa
...
...
@@ -32,21 +32,6 @@ class Credentials(object):
return
None
class
ErrorObject
(
object
):
"""
Unspecified errors with a message
"""
@staticmethod
def
print_error
(
message
):
decorator
=
"***************E*R*R*O*R*******************"
outgoing
=
'
\n
%
s
\n\n
%
s
\n\n
%
s
\n
'
%
(
NODE_COLORS_BLUE
+
decorator
+
NODE_COLORS_END
,
message
,
NODE_COLORS_BLUE
+
decorator
+
NODE_COLORS_END
,
)
print
outgoing
class
Output
(
object
):
"""
Various reporting methods
...
...
video_worker/validate.py
View file @
bb447aaa
...
...
@@ -15,16 +15,18 @@ FUTURE:
- artifacting?
"""
import
logging
import
os
import
subprocess
import
sys
from
reporting
import
ErrorObject
,
Output
from
reporting
import
Output
from
video_worker.utils
import
get_config
settings
=
get_config
()
logger
=
logging
.
getLogger
(
__name__
)
class
ValidateVideo
:
...
...
@@ -41,14 +43,18 @@ class ValidateVideo:
-file exists
"""
if
not
os
.
path
.
exists
(
self
.
filepath
):
ErrorObject
()
.
print_error
(
message
=
'File QA fail: File is not found
\n
'
+
self
.
filepath
logger
.
error
(
'[ENCODE_WORKER] : {filepath} File QA fail: File is not found'
.
format
(
filepath
=
self
.
filepath
)
)
return
False
if
os
.
stat
(
self
.
filepath
)
.
st_size
==
0
:
ErrorObject
()
.
print_error
(
message
=
'File QA fail: Filesize is 0'
logger
.
error
(
'[ENCODE_WORKER] : {filepath} File QA fail: Filesize is 0'
.
format
(
filepath
=
self
.
filepath
)
)
return
False
...
...
@@ -74,29 +80,24 @@ class ValidateVideo:
return
False
if
"multiple edit list entries, a/v desync might occur, patch welcome"
in
line
:
print
1
return
False
if
"Duration: "
in
line
:
"""Get and Test Duration"""
if
"Duration: 00:00:00.0"
in
line
:
print
2
return
False
elif
"Duration: N/A, "
in
line
:
print
3
return
False
vid_duration
=
line
.
split
(
'Duration: '
)[
1
]
.
split
(
','
)[
0
]
.
strip
()
duration
=
Output
.
seconds_from_string
(
duration
=
vid_duration
)
if
duration
<
1.05
:
print
'TOO SHORT'
return
False
try
:
duration
except
:
print
'NO DUR'
return
False
"""
...
...
@@ -105,7 +106,6 @@ class ValidateVideo:
if
self
.
VideoObject
is
not
None
and
self
.
product_file
is
True
:
# within five seconds
if
not
(
self
.
VideoObject
.
mezz_duration
-
5
)
<=
duration
<=
(
self
.
VideoObject
.
mezz_duration
+
5
):
print
6
return
False
return
True
...
...
@@ -118,10 +118,12 @@ class ValidateVideo:
-file exists
"""
if
not
os
.
path
.
exists
(
self
.
filepath
):
ErrorObject
()
.
print_error
(
message
=
'File Vars fail: File is not found
\n
'
+
self
.
filepath
logger
.
error
(
'[ENCODE_WORKER] : {filepath} File QA fail: Filesize is 0'
.
format
(
filepath
=
self
.
filepath
)
)
return
None
return
# Filesize
return_dict
.
setdefault
(
'filesize'
,
os
.
stat
(
self
.
filepath
)
.
st_size
)
...
...
video_worker/video_images.py
View file @
bb447aaa
...
...
@@ -16,7 +16,6 @@ from boto.s3.key import Key
import
generate_apitoken
from
video_worker.utils
import
get_config
from
video_worker.reporting
import
ErrorObject
from
video_worker.utils
import
build_url
...
...
@@ -28,7 +27,7 @@ START_PERCENTAGE = 2.0 / 100
# skip 10 percent of video duration from end to avoid end credits
END_PERCENTAGE
=
10.0
/
100
LOGGER
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
VideoImages
(
object
):
...
...
@@ -80,11 +79,12 @@ class VideoImages(object):
"""
Generate video images using ffmpeg.
"""
if
self
.
video_object
is
None
:
ErrorObject
()
.
print_error
(
message
=
'Video Images generation failed: No Video Object'
if
not
self
.
video_object
:
logger
.
error
(
'[ENCODE_WORKER] : {id} Video Image generation failed: No Video Object'
.
format
(
)
)
return
None
return
generated_images
=
[]
for
position
in
self
.
calculate_positions
(
self
.
video_object
.
mezz_duration
):
...
...
@@ -108,8 +108,8 @@ class VideoImages(object):
universal_newlines
=
True
)
stdoutdata
,
stderrdata
=
process
.
communicate
()
LOGGER
.
info
(
'executing command >>
%
s'
,
command
)
LOGGER
.
info
(
'command output >> out=
%
s -- err=
%
s'
,
stdoutdata
,
stderrdata
)
logger
.
info
(
'executing command >>
%
s'
,
command
)
logger
.
info
(
'command output >> out=
%
s -- err=
%
s'
,
stdoutdata
,
stderrdata
)
return_images
=
[]
for
image
in
generated_images
:
...
...
@@ -133,10 +133,8 @@ class VideoImages(object):
try
:
bucket
=
s3_connection
.
get_bucket
(
self
.
settings
[
'aws_video_images_bucket'
])
except
S3ResponseError
:
ErrorObject
()
.
print_error
(
message
=
'Invalid Storage Bucket for Video Images'
)
return
None
logger
.
error
(
'[ENCODE_WORKER] : Invalid Storage Bucket for Video Images'
)
return
image_keys
=
[]
for
generated_image
in
generated_images
:
...
...
@@ -184,4 +182,10 @@ class VideoImages(object):
)
if
not
response
.
ok
:
ErrorObject
.
print_error
(
message
=
response
.
content
)
logger
.
error
(
'[ENCODE_WORKER] : {id} {message}'
.
format
(
id
=
self
.
video_object
.
val_id
,
message
=
response
.
content
))
if
__name__
==
'__main__'
:
vi
=
VideoImages
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment