Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
bf93cb76
Commit
bf93cb76
authored
16 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
detect latex conversion error and print them in textview. Fixes #4439
parent
e706e86c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/exceptions.py
+9
-0
9 additions, 0 deletions
src/common/exceptions.py
src/conversation_textview.py
+28
-8
28 additions, 8 deletions
src/conversation_textview.py
with
37 additions
and
8 deletions
src/common/exceptions.py
+
9
−
0
View file @
bf93cb76
...
...
@@ -82,6 +82,15 @@ class Cancelled(Exception):
'''
The user cancelled an operation
'''
pass
class
LatexError
(
Exception
):
'''
sqlite2 raised pysqlite2.dbapi2.OperationalError
'''
def
__init__
(
self
,
text
=
''
):
Exception
.
__init__
(
self
)
self
.
text
=
text
def
__str__
(
self
):
return
self
.
text
class
GajimGeneralException
(
Exception
):
'''
This exception is our general exception
'''
def
__init__
(
self
,
text
=
''
):
...
...
This diff is collapsed.
Click to expand it.
src/conversation_textview.py
+
28
−
8
View file @
bf93cb76
...
...
@@ -50,6 +50,7 @@ from common.fuzzyclock import FuzzyClock
from
htmltextview
import
HtmlTextView
from
common.exceptions
import
GajimGeneralException
from
common.exceptions
import
LatexError
NOT_SHOWN
=
0
ALREADY_RECEIVED
=
1
...
...
@@ -964,16 +965,27 @@ class ConversationTextview:
file
.
flush
()
file
.
close
()
p
=
Popen
([
'
latex
'
,
'
--interaction=nonstopmode
'
,
tmpfile
+
'
.tex
'
],
cwd
=
gettempdir
())
exitcode
=
p
.
wait
()
try
:
p
=
Popen
([
'
latex
'
,
'
--interaction=nonstopmode
'
,
tmpfile
+
'
.tex
'
],
cwd
=
gettempdir
())
exitcode
=
p
.
wait
()
except
Exception
,
e
:
exitcode
=
_
(
'
Error executing
"
%(command)s
"
: %(error)s
'
)
%
{
'
command
'
:
'
latex --interaction=nonstopmode %s.tex
'
%
tmpfile
,
'
error
'
:
str
(
e
)}
if
exitcode
==
0
:
latex_png_dpi
=
gajim
.
config
.
get
(
'
latex_png_dpi
'
)
p
=
Popen
([
'
dvipng
'
,
'
-bg
'
,
'
white
'
,
'
-T
'
,
'
tight
'
,
'
-D
'
,
latex_png_dpi
,
tmpfile
+
'
.dvi
'
,
'
-o
'
,
tmpfile
+
'
.png
'
],
cwd
=
gettempdir
())
exitcode
=
p
.
wait
()
try
:
p
=
Popen
([
'
dvipng
'
,
'
-bg
'
,
'
rgb 1.0 1.0 1.0
'
,
'
-T
'
,
'
tight
'
,
'
-D
'
,
latex_png_dpi
,
tmpfile
+
'
.dvi
'
,
'
-o
'
,
tmpfile
+
'
.png
'
],
cwd
=
gettempdir
())
exitcode
=
p
.
wait
()
except
Exception
,
e
:
exitcode
=
_
(
'
Error executing
"
%(command)s
"
: %(error)s
'
)
%
{
'
command
'
:
'
dvipng -bg rgb 1.0 1.0 1.0 -T tight -D %s %s.dvi -o %s.png
'
%
\
(
latex_png_dpi
,
tmpfile
,
tmpfile
),
'
error
'
:
str
(
e
)}
extensions
=
[
'
.tex
'
,
'
.log
'
,
'
.aux
'
,
'
.dvi
'
]
for
ext
in
extensions
:
...
...
@@ -982,6 +994,9 @@ class ConversationTextview:
except
Exception
:
pass
if
isinstance
(
exitcode
,
(
unicode
,
str
)):
raise
LatexError
(
exitcode
)
if
exitcode
==
0
:
result
=
tmpfile
+
'
.png
'
...
...
@@ -1076,7 +1091,12 @@ class ConversationTextview:
if
not
show_ascii_formatting_chars
:
special_text
=
special_text
[
1
:
-
1
]
# remove _ _
elif
special_text
.
startswith
(
'
$$
'
)
and
special_text
.
endswith
(
'
$$
'
):
imagepath
=
self
.
latex_to_image
(
special_text
)
try
:
imagepath
=
self
.
latex_to_image
(
special_text
)
except
LatexError
,
e
:
# print the error after the line has been written
gobject
.
idle_add
(
self
.
print_conversation_line
,
str
(
e
),
''
,
'
info
'
,
''
,
None
)
imagepath
=
None
end_iter
=
buffer
.
get_end_iter
()
anchor
=
buffer
.
create_child_anchor
(
end_iter
)
if
imagepath
is
not
None
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment