Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lettuce
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
lettuce
Commits
25cedbe9
Commit
25cedbe9
authored
Dec 27, 2010
by
Gabriel Falcão
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clever output
parent
3f589544
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
lettuce/plugins/colored_shell_output.py
+36
-0
No files found.
lettuce/plugins/colored_shell_output.py
View file @
25cedbe9
...
...
@@ -17,11 +17,39 @@
import
os
import
re
import
sys
import
fcntl
import
struct
import
termios
from
lettuce
import
strings
from
lettuce
import
core
from
lettuce.terrain
import
after
from
lettuce.terrain
import
before
def
get_terminal_size
():
def
ioctl_GWINSZ
(
fd
):
try
:
cr
=
struct
.
unpack
(
'hh'
,
fcntl
.
ioctl
(
fd
,
termios
.
TIOCGWINSZ
,
'1234'
))
except
:
return
None
return
cr
cr
=
ioctl_GWINSZ
(
0
)
or
ioctl_GWINSZ
(
1
)
or
ioctl_GWINSZ
(
2
)
if
not
cr
:
try
:
fd
=
os
.
open
(
os
.
ctermid
(),
os
.
O_RDONLY
)
cr
=
ioctl_GWINSZ
(
fd
)
os
.
close
(
fd
)
except
:
pass
if
not
cr
:
try
:
cr
=
(
os
.
getenv
(
'LINES'
),
os
.
getenv
(
'COLUMNS'
))
except
:
cr
=
(
25
,
80
)
return
int
(
cr
[
1
]),
int
(
cr
[
0
])
def
wrt
(
what
):
sys
.
stdout
.
write
(
what
.
encode
(
'utf-8'
))
...
...
@@ -77,6 +105,14 @@ def print_step_ran(step):
prefix
=
'
\033
[A'
width
,
height
=
get_terminal_size
()
lines_up
=
len
(
string
)
/
float
(
width
)
if
lines_up
<
1
:
lines_up
=
1
else
:
lines_up
=
int
(
lines_up
)
+
1
prefix
=
prefix
*
lines_up
if
step
.
failed
:
color
=
"
\033
[0;31m"
...
...
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