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
54e47436
Commit
54e47436
authored
19 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
add an exceptions file that contain our custom exceptions
parent
0bf6346a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/exceptions.py
+56
-0
56 additions, 0 deletions
src/common/exceptions.py
src/common/logger.py
+3
-8
3 additions, 8 deletions
src/common/logger.py
src/gajim-remote.py
+5
-28
5 additions, 28 deletions
src/gajim-remote.py
with
64 additions
and
36 deletions
src/common/exceptions.py
0 → 100644
+
56
−
0
View file @
54e47436
## exceptions.py
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <kourem@gmail.com>
##
## Copyright (C) 2003-2005 Gajim Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 2 only.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
from
common
import
i18n
_
=
i18n
.
_
class
PysqliteNotAvailable
(
Exception
):
'''
sqlite2 is not installed or python bindings are missing
'''
def
__init__
(
self
):
Exception
.
__init__
(
self
)
def
__str__
(
self
):
return
_
(
'
pysqlite2 (aka python-pysqlite2) dependency is missing.
'
\
'
After you install pysqlite3, if you want to migrate your logs
'
\
'
to the new database, please read: http://trac.gajim.org/wiki/MigrateLogToDot9DB
'
\
'
Exiting...
'
)
class
ServiceNotAvailable
(
Exception
):
'''
This exception is raised when we cannot use Gajim remotely
'''
def
__init__
(
self
):
Exception
.
__init__
(
self
)
def
__str__
(
self
):
return
_
(
'
Service not available: Gajim is not running, or remote_control is False
'
)
class
DbusNotSupported
(
Exception
):
'''
D-Bus is not installed or python bindings are missing
'''
def
__init__
(
self
):
Exception
.
__init__
(
self
)
def
__str__
(
self
):
return
_
(
'
D-Bus is not present on this machine or python module is missing
'
)
class
SessionBusNotPresent
(
Exception
):
'''
This exception indicates that there is no session daemon
'''
def
__init__
(
self
):
Exception
.
__init__
(
self
)
def
__str__
(
self
):
return
_
(
'
Session bus is not available
'
)
This diff is collapsed.
Click to expand it.
src/common/logger.py
+
3
−
8
View file @
54e47436
...
...
@@ -22,20 +22,15 @@ import sys
import
time
import
datetime
from
common
import
exceptions
from
common
import
i18n
_
=
i18n
.
_
try
:
from
pysqlite2
import
dbapi2
as
sqlite
except
ImportError
:
error
=
_
(
'
pysqlite2 (aka python-pysqlite2) dependency is missing.
'
\
'
After you install pysqlite3, if you want to migrate your logs
'
\
'
to the new database, please read: http://trac.gajim.org/wiki/MigrateLogToDot9DB
'
\
'
Exiting...
'
)
print
>>
sys
.
stderr
,
error
sys
.
exit
()
raise
exceptions
.
PysqliteNotAvailable
GOT_JIDS_ALREADY_IN_DB
=
False
# see get_jids_already_in_db()
if
os
.
name
==
'
nt
'
:
...
...
This diff is collapsed.
Click to expand it.
src/gajim-remote.py
+
5
−
28
View file @
54e47436
...
...
@@ -32,6 +32,7 @@ import signal
signal
.
signal
(
signal
.
SIGINT
,
signal
.
SIG_DFL
)
# ^C exits the application
import
traceback
from
common
import
exceptions
from
common
import
i18n
_
=
i18n
.
_
...
...
@@ -43,34 +44,10 @@ def send_error(error_message):
sys
.
stderr
.
flush
()
sys
.
exit
(
1
)
class
ServiceNotAvailable
(
Exception
):
'''
This exception is raised when we cannot use Gajim remotely
'''
def
__init__
(
self
):
Exception
.
__init__
(
self
)
def
__str__
(
self
):
return
_
(
'
Service not available: Gajim is not running, or remote_control is False
'
)
class
DbusNotSupported
(
Exception
):
'''
D-Bus is not installed or python bindings are missing
'''
def
__init__
(
self
):
Exception
.
__init__
(
self
)
def
__str__
(
self
):
return
_
(
'
D-Bus is not present on this machine or python module is missing
'
)
class
SessionBusNotPresent
(
Exception
):
'''
This exception indicates that there is no session daemon
'''
def
__init__
(
self
):
Exception
.
__init__
(
self
)
def
__str__
(
self
):
return
_
(
'
Session bus is not available
'
)
try
:
import
dbus
except
:
raise
DbusNotSupported
raise
exceptions
.
DbusNotSupported
_version
=
getattr
(
dbus
,
'
version
'
,
(
0
,
20
,
0
))
if
_version
[
1
]
>=
41
:
...
...
@@ -236,7 +213,7 @@ class GajimRemote:
id
=
self
.
sbus
.
add_signal_receiver
(
self
.
show_vcard_info
,
'
VcardInfo
'
,
INTERFACE
,
SERVICE
,
OBJ_PATH
)
except
Exception
,
e
:
raise
ServiceNotAvailable
raise
exceptions
.
ServiceNotAvailable
res
=
self
.
call_remote_method
()
self
.
print_result
(
res
)
...
...
@@ -282,7 +259,7 @@ class GajimRemote:
try
:
self
.
sbus
=
dbus
.
SessionBus
()
except
:
raise
SessionBusNotPresent
raise
exceptions
.
SessionBusNotPresent
if
_version
[
1
]
>=
30
:
obj
=
self
.
sbus
.
get_object
(
SERVICE
,
OBJ_PATH
)
...
...
@@ -566,7 +543,7 @@ Type "%s help %s" for more info') % (args[argv_len][0], BASENAME, self.command))
return
res
except
Exception
,
e
:
print
str
(
e
)
raise
ServiceNotAvailable
raise
exceptions
.
ServiceNotAvailable
return
None
if
__name__
==
'
__main__
'
:
...
...
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