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/>.
23 from lib.common import log, dialog_yesno
24 from lib.common import upgrade_message as _upgrademessage
26 __addon__ = lib.common.__addon__
27 __addonversion__ = lib.common.__addonversion__
28 __addonname__ = lib.common.__addonname__
29 __addonpath__ = lib.common.__addonpath__
30 __icon__ = lib.common.__icon__
37 if not xbmc.getCondVisibility('System.HasAddon(os.openelec.tv)'):
39 xbmc.executebuiltin('XBMC.AlarmClock(CheckAtBoot,XBMC.RunScript(service.xbmc.versioncheck, started),00:00:30,silent)')
40 xbmc.executebuiltin('XBMC.AlarmClock(CheckWhileRunning,XBMC.RunScript(service.xbmc.versioncheck, started),24:00:00,silent,loop)')
41 elif sys.argv[0] and sys.argv[1] == 'started':
42 if xbmc.getCondVisibility('System.Platform.Linux') and __addon__.getSetting("upgrade_apt") == 'true':
44 _versionchecklinux(packages)
46 oldversion, msg = _versioncheck()
48 _upgrademessage(msg, oldversion, False)
54 from lib.jsoninterface import get_installedversion, get_versionfilelist
55 from lib.versions import compare_version
56 # retrieve versionlists from supplied version file
57 versionlist = get_versionfilelist()
58 # retrieve version installed
59 version_installed = get_installedversion()
60 # copmpare installed and available
61 oldversion, msg = compare_version(version_installed, versionlist)
62 return oldversion, msg
65 def _versionchecklinux(packages):
66 if platform.dist()[0].lower() in ['ubuntu', 'debian', 'linuxmint']:
71 from lib.aptdeamonhandler import AptdeamonHandler
72 handler = AptdeamonHandler()
75 # since we need the user password, ask to check for new version first
76 from lib.shellhandlerapt import ShellHandlerApt
78 handler = ShellHandlerApt(sudo)
79 if dialog_yesno(32015):
81 elif dialog_yesno(32009, 32010):
82 log("disabling addon by user request")
83 __addon__.setSetting("versioncheck_enable", 'false')
87 if handler.check_upgrade_available(packages[0]):
88 if _upgrademessage(32012, oldversion, True):
89 if __addon__.getSetting("upgrade_system") == "false":
90 result = handler.upgrade_package(packages[0])
92 result = handler.upgrade_system()
94 from lib.common import message_upgrade_success, message_restart
95 message_upgrade_success()
98 log("Error during upgrade")
100 log("Error: no handler found")
102 log("Unsupported platform %s" %platform.dist()[0])
107 if (__name__ == "__main__"):
108 log('Version %s started' % __addonversion__)