Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
58ea785e
Commit
58ea785e
authored
Sep 15, 2015
by
David Baumgold
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9660 from OmarIthawi/edraak/watch-xmodule-assets
Watch and process xmodule assets
parents
c82e928b
82c0206c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
pavelib/assets.py
+42
-0
No files found.
pavelib/assets.py
View file @
58ea785e
...
@@ -109,6 +109,30 @@ class XModuleSassWatcher(SassWatcher):
...
@@ -109,6 +109,30 @@ class XModuleSassWatcher(SassWatcher):
traceback
.
print_exc
()
traceback
.
print_exc
()
class
XModuleAssetsWatcher
(
PatternMatchingEventHandler
):
"""
Watches for css and js file changes
"""
ignore_directories
=
True
patterns
=
[
'*.css'
,
'*.js'
]
def
register
(
self
,
observer
):
"""
Register files with observer
"""
observer
.
schedule
(
self
,
'common/lib/xmodule/'
,
recursive
=
True
)
def
on_modified
(
self
,
event
):
print
(
'
\t
CHANGED:'
,
event
.
src_path
)
try
:
process_xmodule_assets
()
except
Exception
:
# pylint: disable=broad-except
traceback
.
print_exc
()
# To refresh the hash values of static xmodule content
restart_django_servers
()
def
coffeescript_files
():
def
coffeescript_files
():
"""
"""
return find command for paths containing coffee files
return find command for paths containing coffee files
...
@@ -163,6 +187,8 @@ def compile_sass(options):
...
@@ -163,6 +187,8 @@ def compile_sass(options):
sh
(
cmd
(
*
parts
))
sh
(
cmd
(
*
parts
))
print
(
"
\t\t
Finished compiling sass."
)
def
compile_templated_sass
(
systems
,
settings
):
def
compile_templated_sass
(
systems
,
settings
):
"""
"""
...
@@ -172,6 +198,7 @@ def compile_templated_sass(systems, settings):
...
@@ -172,6 +198,7 @@ def compile_templated_sass(systems, settings):
"""
"""
for
sys
in
systems
:
for
sys
in
systems
:
sh
(
django_cmd
(
sys
,
settings
,
'preprocess_assets'
))
sh
(
django_cmd
(
sys
,
settings
,
'preprocess_assets'
))
print
(
"
\t\t
Finished preprocessing {} assets."
.
format
(
sys
))
def
process_xmodule_assets
():
def
process_xmodule_assets
():
...
@@ -179,6 +206,19 @@ def process_xmodule_assets():
...
@@ -179,6 +206,19 @@ def process_xmodule_assets():
Process XModule static assets.
Process XModule static assets.
"""
"""
sh
(
'xmodule_assets common/static/xmodule'
)
sh
(
'xmodule_assets common/static/xmodule'
)
print
(
"
\t\t
Finished processing xmodule assets."
)
def
restart_django_servers
():
"""
Restart the django server.
`$ touch` makes the Django file watcher thinks that something has changed, therefore
it restarts the server.
"""
sh
(
cmd
(
"touch"
,
'lms/urls.py'
,
'cms/urls.py'
,
))
def
collect_assets
(
systems
,
settings
):
def
collect_assets
(
systems
,
settings
):
...
@@ -189,6 +229,7 @@ def collect_assets(systems, settings):
...
@@ -189,6 +229,7 @@ def collect_assets(systems, settings):
"""
"""
for
sys
in
systems
:
for
sys
in
systems
:
sh
(
django_cmd
(
sys
,
settings
,
"collectstatic --noinput > /dev/null"
))
sh
(
django_cmd
(
sys
,
settings
,
"collectstatic --noinput > /dev/null"
))
print
(
"
\t\t
Finished collecting {} assets."
.
format
(
sys
))
@task
@task
...
@@ -206,6 +247,7 @@ def watch_assets(options):
...
@@ -206,6 +247,7 @@ def watch_assets(options):
CoffeeScriptWatcher
()
.
register
(
observer
)
CoffeeScriptWatcher
()
.
register
(
observer
)
SassWatcher
()
.
register
(
observer
)
SassWatcher
()
.
register
(
observer
)
XModuleSassWatcher
()
.
register
(
observer
)
XModuleSassWatcher
()
.
register
(
observer
)
XModuleAssetsWatcher
()
.
register
(
observer
)
print
(
"Starting asset watcher..."
)
print
(
"Starting asset watcher..."
)
observer
.
start
()
observer
.
start
()
...
...
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