look in correct ftp folder according to gajim version

This commit is contained in:
Yann Leboulanger
2013-08-28 13:16:43 +02:00
parent 9b229cd690
commit ed47951f20
2 changed files with 11 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
[info] [info]
name: Plugin Installer name: Plugin Installer
short_name: plugin_installer short_name: plugin_installer
version: 0.12 version: 0.12.1
description: Install and upgrade plugins from ftp description: Install and upgrade plugins from ftp
authors: Denis Fomin <fominde@gmail.com> authors: Denis Fomin <fominde@gmail.com>
Yann Leboulanger <asterix@lagaule.org> Yann Leboulanger <asterix@lagaule.org>

View File

@@ -78,6 +78,12 @@ class PluginInstaller(GajimPlugin):
icon = Gtk.Image() icon = Gtk.Image()
self.def_icon = icon.render_icon(Gtk.STOCK_PREFERENCES, self.def_icon = icon.render_icon(Gtk.STOCK_PREFERENCES,
Gtk.IconSize.MENU) Gtk.IconSize.MENU)
if gajim.version.startswith('0.15'):
self.server_folder = 'plugins_0.15'
elif gajim.version.startswith('0.16.10'):
self.server_folder = 'plugins_gtk3'
else:
self.server_folder = 'plugins_0.16'
@log_calls('PluginInstallerPlugin') @log_calls('PluginInstallerPlugin')
def activate(self): def activate(self):
@@ -118,7 +124,7 @@ class PluginInstaller(GajimPlugin):
try: try:
to_update = [] to_update = []
con = self.ftp_connect() con = self.ftp_connect()
con.cwd('plugins_gtk3') con.cwd(self.server_folder)
con.retrbinary('RETR manifests.zip', ftp.handleDownload) con.retrbinary('RETR manifests.zip', ftp.handleDownload)
zip_file = zipfile.ZipFile(ftp.buffer_) zip_file = zipfile.ZipFile(ftp.buffer_)
manifest_list = zip_file.namelist() manifest_list = zip_file.namelist()
@@ -501,7 +507,7 @@ class Ftp(threading.Thread):
GLib.idle_add(self.progressbar.set_text, GLib.idle_add(self.progressbar.set_text,
_('Connecting to server')) _('Connecting to server'))
self.ftp = self.plugin.ftp_connect() self.ftp = self.plugin.ftp_connect()
self.ftp.cwd('plugins_gtk3') self.ftp.cwd(self.plugin.server_folder)
self.progressbar.set_show_text(True) self.progressbar.set_show_text(True)
if not self.remote_dirs: if not self.remote_dirs:
GLib.idle_add(self.progressbar.set_text, GLib.idle_add(self.progressbar.set_text,
@@ -601,7 +607,7 @@ class Ftp(threading.Thread):
else: else:
files.append(i[1:]) files.append(i[1:])
dirs, files = [], [] dirs, files = [], []
nlstr('/plugins_gtk3/' + remote_dir) nlstr('/%s/%s' % (self.plugin.server_folder, remote_dir)
base_dir, user_dir = gajim.PLUGINS_DIRS base_dir, user_dir = gajim.PLUGINS_DIRS
if not os.path.isdir(user_dir): if not os.path.isdir(user_dir):
@@ -625,7 +631,7 @@ class Ftp(threading.Thread):
GLib.idle_add(self.progressbar.set_text, GLib.idle_add(self.progressbar.set_text,
_('Downloading "%s"') % filename) _('Downloading "%s"') % filename)
full_filename = os.path.join(local_dir, filename.replace( full_filename = os.path.join(local_dir, filename.replace(
'plugins_gtk3', 'plugins')) self.plugin.server_folder, 'plugins'))
try: try:
file_ = open(full_filename, 'wb') file_ = open(full_filename, 'wb')