2 # -*- coding: utf-8 -*-
4 # Copyright (C) 2013 Team-XBMC
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 from lib.common import log, dialog_yesno
25 from lib.common import upgrade_message as _upgrademessage
27 __addon__ = lib.common.__addon__
28 __addonversion__ = lib.common.__addonversion__
29 __addonname__ = lib.common.__addonname__
30 __addonpath__ = lib.common.__addonpath__
31 __icon__ = lib.common.__icon__
32 __localize__ = lib.common.__localize__
39 if __addon__.getSetting("versioncheck_enable") == 'true' and not xbmc.getCondVisibility('System.HasAddon(os.openelec.tv)'):
41 xbmc.executebuiltin('XBMC.AlarmClock(CheckAtBoot,XBMC.RunScript(service.xbmc.versioncheck, started),00:00:30,silent)')
42 xbmc.executebuiltin('XBMC.AlarmClock(CheckWhileRunning,XBMC.RunScript(service.xbmc.versioncheck, started),24:00:00,silent,loop)')
43 elif sys.argv[0] and sys.argv[1] == 'started':
44 if xbmc.getCondVisibility('System.Platform.Linux'):
46 _versionchecklinux(packages)
48 oldversion, msg = _versioncheck()
50 _upgrademessage(msg, False)
56 from lib.jsoninterface import get_installedversion, get_versionfilelist
57 from lib.versions import compare_version
58 # retrieve versionlists from supplied version file
59 versionlist = get_versionfilelist()
60 # retrieve version installed
61 version_installed = get_installedversion()
62 # copmpare installed and available
63 oldversion, msg = compare_version(version_installed, versionlist)
64 return oldversion, msg
67 def _versionchecklinux(packages):
68 if platform.dist()[0].lower() in ['ubuntu', 'debian', 'linuxmint']:
73 from lib.aptdeamonhandler import AptdeamonHandler
74 handler = AptdeamonHandler()
77 # since we need the user password, ask to check for new version first
78 from lib.shellhandlerapt import ShellHandlerApt
80 handler = ShellHandlerApt(sudo)
81 if dialog_yesno(32015):
83 elif dialog_yesno(32009, 32010):
84 log("disabling addon by user request")
85 __addon__.setSetting("versioncheck_enable", 'false')
89 if handler.check_upgrade_available(packages[0]):
90 if _upgrademessage(32012, True):
91 if __addon__.getSetting("upgrade_system") == "false":
92 result = handler.upgrade_package(packages[0])
94 result = handler.upgrade_system()
96 from lib.common import message_upgrade_success, message_restart
97 message_upgrade_success()
100 log("Error during upgrade")
102 log("Error: no handler found")
104 log("Unsupported platform %s" %platform.dist()[0])
109 if (__name__ == "__main__"):
110 log('Version %s started' % __addonversion__)