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
Weblate
gajim
Commits
daaf9b17
Commit
daaf9b17
authored
13 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
auto-check for updates of installed plugins
parent
d3aa8075
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
plugins/plugin_installer/manifest.ini
+2
-1
2 additions, 1 deletion
plugins/plugin_installer/manifest.ini
plugins/plugin_installer/plugin_installer.py
+71
-3
71 additions, 3 deletions
plugins/plugin_installer/plugin_installer.py
with
73 additions
and
4 deletions
plugins/plugin_installer/manifest.ini
+
2
−
1
View file @
daaf9b17
[info]
name:
Plugin
Installer
short_name:
plugin_installer
version:
0.
3
version:
0.
4
description:
Install
and
upgrade
plugins
from
ftp
authors:
Denis
Fomin
<fominde@gmail.com>
Yann
Leboulanger
<asterix@lagaule.org>
homepage:
http://www.gajim.org/
This diff is collapsed.
Click to expand it.
plugins/plugin_installer/plugin_installer.py
+
71
−
3
View file @
daaf9b17
...
...
@@ -33,10 +33,17 @@ import sys
from
common
import
gajim
from
plugins
import
GajimPlugin
from
plugins.helpers
import
log_calls
,
log
from
dialogs
import
WarningDialog
,
HigDialog
from
dialogs
import
WarningDialog
,
HigDialog
,
YesNoDialog
from
plugins.gui
import
GajimPluginConfigDialog
def
convert_version_to_list
(
version_str
):
version_list
=
version_str
.
split
(
'
.
'
)
l
=
[]
while
len
(
version_list
):
l
.
append
(
int
(
version_list
.
pop
(
0
)))
return
l
class
PluginInstaller
(
GajimPlugin
):
@log_calls
(
'
PluginInstallerPlugin
'
)
...
...
@@ -44,6 +51,10 @@ class PluginInstaller(GajimPlugin):
self
.
description
=
_
(
'
Install and upgrade plugins from ftp
'
)
self
.
config_dialog
=
PluginInstallerPluginConfigDialog
(
self
)
self
.
config_default_values
=
{
'
ftp_server
'
:
(
'
ftp.gajim.org
'
,
''
)}
self
.
window
=
None
self
.
progressbar
=
None
self
.
available_plugins_model
=
None
self
.
upgrading
=
False
# True when opened from upgrade popup dialog
@log_calls
(
'
PluginInstallerPlugin
'
)
def
activate
(
self
):
...
...
@@ -52,6 +63,50 @@ class PluginInstaller(GajimPlugin):
self
.
id_
=
self
.
pl_menuitem
.
connect_after
(
'
activate
'
,
self
.
on_activate
)
if
'
plugins
'
in
gajim
.
interface
.
instances
:
self
.
on_activate
(
None
)
gobject
.
timeout_add_seconds
(
30
,
self
.
check_update
)
@log_calls
(
'
PluginInstallerPlugin
'
)
def
warn_update
(
self
,
plugins
):
def
open_update
(
dummy
):
self
.
upgrading
=
True
self
.
pl_menuitem
.
activate
()
nb
=
gajim
.
interface
.
instances
[
'
plugins
'
].
plugins_notebook
gobject
.
idle_add
(
nb
.
set_current_page
,
1
)
if
plugins
:
plugins_str
=
'
\n
'
.
join
(
plugins
)
YesNoDialog
(
_
(
'
Plugins updates
'
),
_
(
'
Some updates are available for
'
'
your installer plugins. Do you want to update those plugins:
'
'
\n
%s
'
)
%
plugins_str
,
on_response_yes
=
open_update
)
@log_calls
(
'
PluginInstallerPlugin
'
)
def
check_update
(
self
):
def
_run
():
to_update
=
[]
con
=
ftplib
.
FTP
(
ftp
.
server
)
con
.
login
()
con
.
cwd
(
'
plugins
'
)
plugins_dirs
=
con
.
nlst
()
for
dir_
in
plugins_dirs
:
try
:
con
.
retrbinary
(
'
RETR %s/manifest.ini
'
%
dir_
,
ftp
.
handleDownload
)
except
Exception
,
error
:
if
str
(
error
).
startswith
(
'
550
'
):
continue
ftp
.
config
.
readfp
(
io
.
BytesIO
(
ftp
.
buffer_
.
getvalue
()))
local_version
=
ftp
.
get_plugin_version
(
ftp
.
config
.
get
(
'
info
'
,
'
name
'
))
if
local_version
:
local
=
convert_version_to_list
(
local_version
)
remote
=
convert_version_to_list
(
ftp
.
config
.
get
(
'
info
'
,
'
version
'
))
if
remote
>
local
:
to_update
.
append
(
ftp
.
config
.
get
(
'
info
'
,
'
name
'
))
con
.
quit
()
gobject
.
idle_add
(
self
.
warn_update
,
to_update
)
ftp
=
Ftp
(
self
)
ftp
.
run
=
_run
ftp
.
start
()
@log_calls
(
'
PluginInstallerPlugin
'
)
def
deactivate
(
self
):
...
...
@@ -152,12 +207,13 @@ class PluginInstaller(GajimPlugin):
else
:
self
.
inslall_upgrade_button
.
set_property
(
'
sensitive
'
,
True
)
def
on_notebook_switch_page
(
self
,
widget
,
page
,
page_num
,
):
def
on_notebook_switch_page
(
self
,
widget
,
page
,
page_num
):
if
not
hasattr
(
self
,
'
ftp
'
)
and
self
.
page_num
==
page_num
:
self
.
available_plugins_model
.
clear
()
self
.
progressbar
.
show
()
self
.
ftp
=
Ftp
(
self
)
self
.
ftp
.
remote_dirs
=
None
self
.
ftp
.
upgrading
=
True
self
.
ftp
.
start
()
def
on_inslall_upgrade_clicked
(
self
,
widget
):
...
...
@@ -309,6 +365,7 @@ class PluginInstaller(GajimPlugin):
class
Ftp
(
threading
.
Thread
):
def
__init__
(
self
,
plugin
):
super
(
Ftp
,
self
).
__init__
()
self
.
plugin
=
plugin
self
.
window
=
plugin
.
window
self
.
server
=
plugin
.
config
[
'
ftp_server
'
]
self
.
progressbar
=
plugin
.
progressbar
...
...
@@ -317,6 +374,7 @@ class Ftp(threading.Thread):
self
.
buffer_
=
io
.
BytesIO
()
self
.
remote_dirs
=
None
self
.
append_to_model
=
True
self
.
upgrading
=
False
def
model_append
(
self
,
row
):
self
.
model
.
append
(
row
)
...
...
@@ -357,9 +415,19 @@ class Ftp(threading.Thread):
self
.
config
.
readfp
(
io
.
BytesIO
(
self
.
buffer_
.
getvalue
()))
local_version
=
self
.
get_plugin_version
(
self
.
config
.
get
(
'
info
'
,
'
name
'
))
upgrade
=
False
if
self
.
upgrading
and
local_version
:
local
=
convert_version_to_list
(
local_version
)
remote
=
convert_version_to_list
(
self
.
config
.
get
(
'
info
'
,
'
version
'
))
if
remote
>
local
:
upgrade
=
True
gobject
.
idle_add
(
self
.
plugin
.
inslall_upgrade_button
.
set_property
,
'
sensitive
'
,
True
)
gobject
.
idle_add
(
self
.
model_append
,
[
dir_
,
self
.
config
.
get
(
'
info
'
,
'
name
'
),
local_version
,
self
.
config
.
get
(
'
info
'
,
'
version
'
),
Fals
e
,
self
.
config
.
get
(
'
info
'
,
'
version
'
),
upgrad
e
,
self
.
config
.
get
(
'
info
'
,
'
description
'
),
self
.
config
.
get
(
'
info
'
,
'
authors
'
),
self
.
config
.
get
(
'
info
'
,
'
homepage
'
),
])
...
...
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