Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
slapos.core
Commits
a70ab87e
Commit
a70ab87e
authored
May 12, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use prettytable
parent
472421c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
25 deletions
+19
-25
slapos/cli/proxy_show.py
slapos/cli/proxy_show.py
+19
-25
No files found.
slapos/cli/proxy_show.py
View file @
a70ab87e
...
...
@@ -3,12 +3,12 @@
import
collections
import
logging
from
slapos.cli.config
import
ConfigCommand
from
slapos.proxy
import
ProxyConfig
import
lxml.etree
import
prettytable
import
sqlite3
from
slapos.cli.config
import
ConfigCommand
from
slapos.proxy
import
ProxyConfig
from
slapos.proxy.db_version
import
DB_VERSION
...
...
@@ -53,33 +53,31 @@ tbl_partition = 'partition' + DB_VERSION
tbl_partition_network
=
'partition_network'
+
DB_VERSION
tbl_slave
=
'slave'
+
DB_VERSION
null_str
=
u"-"
def
coalesce
(
*
seq
):
el
=
None
for
el
in
seq
:
if
el
is
not
None
:
return
el
return
el
def
print_table
(
qry
,
tablename
,
skip
=
None
):
if
skip
is
None
:
skip
=
set
()
columns
=
[
c
[
0
]
for
c
in
qry
.
description
if
c
[
0
]
not
in
skip
]
rows
=
[]
for
row
in
qry
.
fetchall
():
line
=
{}
for
col
in
columns
:
val
=
row
[
col
]
if
val
is
None
:
val
=
null_str
line
[
col
]
=
val
.
strip
()
rows
.
append
(
line
)
max_width
=
{
col
:
len
(
col
)
for
col
in
columns
}
for
row
in
rows
:
for
col
in
columns
:
val
=
row
[
col
]
max_width
[
col
]
=
max
(
max_width
[
col
],
len
(
val
)
if
val
else
0
)
rows
.
append
([
coalesce
(
row
[
col
],
'-'
)
for
col
in
columns
])
hdr
=
[
col
.
center
(
max_width
[
col
])
for
col
in
columns
]
pt
=
prettytable
.
PrettyTable
(
columns
)
# https://code.google.com/p/prettytable/wiki/Tutorial
print
for
row
in
rows
:
pt
.
add_row
(
row
)
if
rows
:
print
'table %s:'
%
tablename
,
...
...
@@ -92,12 +90,8 @@ def print_table(qry, tablename, skip=None):
else
:
print
print
' | '
.
join
(
hdr
)
print
'-+-'
.
join
(
'-'
*
len
(
h
)
for
h
in
hdr
)
for
row
in
rows
:
cells
=
[
row
[
col
].
ljust
(
max_width
[
col
])
for
col
in
columns
]
print
' | '
.
join
(
cells
)
print
pt
.
get_string
(
border
=
True
,
padding_width
=
0
,
vrules
=
prettytable
.
NONE
)
print
def
print_params
(
conn
):
...
...
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