Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
595735da
authored
Sep 30, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
circle: manually watch directories for less files
parent
ae45c595
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
circle/watch.py
+67
-0
requirements/base.txt
+1
-0
No files found.
circle/watch.py
0 → 100644
View file @
595735da
import
subprocess
import
os
import
pyinotify
from
django.conf
import
settings
STATIC_FILES
=
u'--include-path={}'
.
format
(
':'
.
join
(
settings
.
STATICFILES_DIRS
))
class
LessUtils
(
object
):
@staticmethod
def
less_path_to_css_path
(
pathname
):
return
"
%
s.css"
%
pathname
[:
-
1
*
len
(
".less"
)]
@staticmethod
def
compile_less
(
less_pathname
,
css_pathname
):
cmd
=
[
"lessc"
,
STATIC_FILES
,
less_pathname
,
css_pathname
]
print
(
"
\n
%
s"
%
(
"="
*
30
))
print
(
"Compiling:
%
s"
%
os
.
path
.
basename
(
less_pathname
))
try
:
subprocess
.
check_output
(
cmd
)
except
subprocess
.
CalledProcessError
as
e
:
print
(
e
.
output
)
else
:
print
(
"Successfully compiled:
\n
%
s
\n
->
\n
%
s"
%
(
less_pathname
,
css_pathname
))
# for first run compile everything
print
(
"Initial LESS compiles"
)
current_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
for
root
,
dirs
,
files
in
os
.
walk
(
"/home/cloud/circle/circle"
):
for
f
in
files
:
if
not
f
.
endswith
(
".less"
):
continue
relpath
=
os
.
path
.
relpath
(
root
,
current_dir
)
if
relpath
.
startswith
((
"static_collected"
,
"bower_components"
)):
continue
less_pathname
=
"
%
s/
%
s"
%
(
root
,
f
)
css_pathname
=
LessUtils
.
less_path_to_css_path
(
less_pathname
)
LessUtils
.
compile_less
(
less_pathname
,
css_pathname
)
print
(
"
\n
%
s
\n
"
%
(
"="
*
30
))
print
(
"End of initial LESS compiles
\n
"
)
# after first run watch less files
wm
=
pyinotify
.
WatchManager
()
class
EventHandler
(
pyinotify
.
ProcessEvent
):
def
process_IN_MODIFY
(
self
,
event
):
if
not
event
.
name
.
endswith
(
".less"
):
return
css_pathname
=
LessUtils
.
less_path_to_css_path
(
event
.
pathname
)
LessUtils
.
compile_less
(
event
.
pathname
,
css_pathname
)
handler
=
EventHandler
()
notifier
=
pyinotify
.
Notifier
(
wm
,
handler
)
wm
.
add_watch
(
current_dir
,
pyinotify
.
IN_MODIFY
,
rec
=
True
)
notifier
.
loop
()
requirements/base.txt
View file @
595735da
...
...
@@ -36,3 +36,4 @@ pika==0.9.13
Fabric==1.9.0
lxml==3.3.5
django-pipeline==1.3.25
pyinotify==0.9.4
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