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
John Smith
gajim
Commits
c0330a86
Commit
c0330a86
authored
13 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
stop using shelve, it cannot work when upgrading python version. Fixes #6988
parent
4ab2a659
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/plugin.py
+42
-7
42 additions, 7 deletions
src/plugins/plugin.py
with
42 additions
and
7 deletions
src/plugins/plugin.py
+
42
−
7
View file @
c0330a86
...
...
@@ -32,6 +32,9 @@ from common import gajim
from
plugins.helpers
import
log_calls
,
log
from
plugins.gui
import
GajimPluginConfigDialog
import
logging
log
=
logging
.
getLogger
(
'
gajim.p.plugin
'
)
class
GajimPlugin
(
object
):
'''
...
...
@@ -191,17 +194,15 @@ class GajimPlugin(object):
def
deactivate
(
self
):
pass
import
shelve
import
UserDict
import
cPickle
class
GajimPluginConfig
(
UserDict
.
DictMixin
):
class
GajimPluginConfig
():
@log_calls
(
'
GajimPluginConfig
'
)
def
__init__
(
self
,
plugin
):
self
.
plugin
=
plugin
self
.
FILE_PATH
=
os
.
path
.
join
(
gajim
.
PLUGINS_CONFIG_DIR
,
self
.
plugin
.
short_name
).
decode
(
'
utf-8
'
).
encode
(
locale
.
getpreferredencoding
())
#log.debug('FILE_PATH = %s'%(self.FILE_PATH))
self
.
data
=
None
@log_calls
(
'
GajimPluginConfig
'
)
...
...
@@ -222,17 +223,51 @@ class GajimPluginConfig(UserDict.DictMixin):
del
self
.
data
[
key
]
self
.
save
()
@log_calls
(
'
GajimPluginConfig
'
)
def
__contains__
(
self
,
key
):
return
key
in
self
.
data
def
__iter__
(
self
):
for
k
in
self
.
data
.
keys
():
yield
k
def
keys
(
self
):
return
self
.
data
.
keys
()
@log_calls
(
'
GajimPluginConfig
'
)
def
save
(
self
):
self
.
data
.
sync
()
#log.debug(str(self.data))
fd
=
open
(
self
.
FILE_PATH
,
'
wb
'
)
cPickle
.
dump
(
self
.
data
,
fd
)
fd
.
close
()
@log_calls
(
'
GajimPluginConfig
'
)
def
load
(
self
):
self
.
data
=
shelve
.
open
(
self
.
FILE_PATH
)
if
os
.
path
.
isfile
(
'
qwe
'
):
fd
=
open
(
self
.
FILE_PATH
,
'
rb
'
)
try
:
self
.
data
=
cPickle
.
load
(
fd
)
fd
.
close
()
except
EOFError
:
fd
.
close
()
try
:
import
shelve
s
=
shelve
.
open
(
self
.
FILE_PATH
)
for
(
k
,
v
)
in
s
.
iteritems
():
self
.
data
[
k
]
=
v
s
.
close
()
self
.
save
()
except
:
log
.
warn
(
'
%s plugin config file not readable. Saving it as
'
'
%s and creating a new one
'
%
(
self
.
plugin
.
short_name
,
self
.
FILE_PATH
+
'
.bak
'
))
if
os
.
path
.
exists
(
self
.
FILE_PATH
+
'
.bak
'
):
os
.
rename
(
self
.
FILE_PATH
,
self
.
FILE_PATH
+
'
.bak
'
)
self
.
data
=
{}
self
.
save
()
else
:
self
.
data
=
{}
self
.
save
()
class
GajimPluginException
(
Exception
):
pass
...
...
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