Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
db95a417a5ec
Commit
fce94e73
authored
Nov 06, 2019
by
Laurent Peuch
Browse files
[debug/source_highlight] rename highlight to highlight_terminal
parent
e55f6f6a8d28
Changes
4
Hide whitespace changes
Inline
Side-by-side
cubicweb/misc/source_highlight.py
View file @
db95a417
...
...
@@ -12,7 +12,7 @@ except ImportError:
has_pygments
=
False
def
highlight
(
code
,
language
):
def
highlight
_terminal
(
code
,
language
):
if
not
has_pygments
:
return
code
...
...
cubicweb/server/querier.py
View file @
db95a417
...
...
@@ -32,7 +32,7 @@ from cubicweb import Binary, server
from
cubicweb.rset
import
ResultSet
from
cubicweb.utils
import
QueryCache
,
RepeatList
from
cubicweb.misc.source_highlight
import
highlight
from
cubicweb.misc.source_highlight
import
highlight
_terminal
from
cubicweb.server.rqlannotation
import
SQLGenAnnotator
,
set_qdata
from
cubicweb.server.ssplanner
import
READ_ONLY_RTYPES
,
add_types_restriction
from
cubicweb.server.edition
import
EditedEntity
...
...
@@ -524,7 +524,7 @@ class QuerierHelper(object):
if
server
.
DEBUG
&
(
server
.
DBG_RQL
|
server
.
DBG_SQL
):
if
server
.
DEBUG
&
(
server
.
DBG_MORE
|
server
.
DBG_SQL
):
print
(
'*'
*
80
)
print
(
"querier input"
,
highlight
(
repr
(
rql
)[
1
:
-
1
],
'RQL'
),
repr
(
args
))
print
(
"querier input"
,
highlight
_terminal
(
repr
(
rql
)[
1
:
-
1
],
'RQL'
),
repr
(
args
))
try
:
rqlst
,
cachekey
=
self
.
rql_cache
.
get
(
cnx
,
rql
,
args
)
except
UnknownEid
:
...
...
cubicweb/server/sources/__init__.py
View file @
db95a417
...
...
@@ -27,13 +27,13 @@ from yams.schema import role_name
from
cubicweb
import
ValidationError
,
set_log_methods
,
server
,
_
from
cubicweb.server
import
SOURCE_TYPES
from
cubicweb.misc.source_highlight
import
highlight
from
cubicweb.misc.source_highlight
import
highlight
_terminal
def
dbg_st_search
(
uri
,
union
,
args
,
cachekey
=
None
,
prefix
=
'rql for'
):
if
server
.
DEBUG
&
server
.
DBG_RQL
:
global
t
print
(
" "
,
prefix
,
uri
,
"source:"
,
highlight
(
repr
(
union
.
as_string
())[
1
:
-
1
],
'RQL'
))
print
(
" "
,
prefix
,
uri
,
"source:"
,
highlight
_terminal
(
repr
(
union
.
as_string
())[
1
:
-
1
],
'RQL'
))
t
=
time
()
if
server
.
DEBUG
&
server
.
DBG_MORE
:
print
(
' args'
,
repr
(
args
))
...
...
cubicweb/server/sources/native.py
View file @
db95a417
...
...
@@ -50,7 +50,7 @@ from cubicweb.server.hook import CleanupDeletedEidsCacheOp
from
cubicweb.server.edition
import
EditedEntity
from
cubicweb.server.sources
import
AbstractSource
,
dbg_st_search
,
dbg_results
from
cubicweb.server.sources.rql2sql
import
SQLGenerator
from
cubicweb.misc.source_highlight
import
highlight
from
cubicweb.misc.source_highlight
import
highlight
_terminal
from
cubicweb.statsd_logger
import
statsd_timeit
...
...
@@ -68,12 +68,12 @@ class LogCursor(object):
it's a function just so that it shows up in profiling
"""
if
server
.
DEBUG
&
server
.
DBG_SQL
:
print
(
'exec'
,
highlight
(
query
,
"SQL"
),
args
)
print
(
'exec'
,
highlight
_terminal
(
query
,
"SQL"
),
args
)
try
:
self
.
cu
.
execute
(
str
(
query
),
args
)
except
Exception
as
ex
:
print
(
"sql: %r
\n
args: %s
\n
dbms message: %r"
%
(
highlight
(
query
,
"SQL"
),
args
,
ex
.
args
[
0
]))
highlight
_terminal
(
query
,
"SQL"
),
args
,
ex
.
args
[
0
]))
raise
def
fetchall
(
self
):
...
...
@@ -686,7 +686,7 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
"""
cursor
=
cnx
.
cnxset
.
cu
if
server
.
DEBUG
&
server
.
DBG_SQL
:
print
(
'exec'
,
highlight
(
query
,
"SQL"
),
args
,
cnx
.
cnxset
.
cnx
)
print
(
'exec'
,
highlight
_terminal
(
query
,
"SQL"
),
args
,
cnx
.
cnxset
.
cnx
)
try
:
# str(query) to avoid error if it's a unicode string
cursor
.
execute
(
str
(
query
),
args
)
...
...
@@ -749,7 +749,7 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
it's a function just so that it shows up in profiling
"""
if
server
.
DEBUG
&
server
.
DBG_SQL
:
print
(
'execmany'
,
highlight
(
query
,
"SQL"
),
'with'
,
len
(
args
),
'arguments'
,
print
(
'execmany'
,
highlight
_terminal
(
query
,
"SQL"
),
'with'
,
len
(
args
),
'arguments'
,
cnx
.
cnxset
.
cnx
)
cursor
=
cnx
.
cnxset
.
cu
try
:
...
...
Write
Preview
Supports
Markdown
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