def pin_changed(gpio, level, tick):
  global g_gpio_pin
  global g_shutdown_time
  global g_reboot_time
  global g_pressed_time
  if (level == 0):
    g_pressed_time = datetime.now()
##    xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Shut:"+str((float(g_shutdown_time) - g_hibernate_time)/1000),1,__icon__))
##    xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Reb:"+str((float(g_reboot_time) - g_shutdown_time)/1000),1,__icon__))
##    time.sleep(float(g_shutdown_time)/1000)
##    lev = g_pi.read(g_gpio_pin)
##    if (lev == 0):
##      xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Shutdown",1,__icon__))
##    else:
##      return
##    time.sleep((float(g_reboot_time) - g_shutdown_time)/1000)
##    lev = g_pi.read(g_gpio_pin)
##    if (lev == 0):
##      xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Reboot",1,__icon__))
##    else:
##      return
  elif (level == 1):
    curtime = datetime.now()
    timediff = curtime - g_pressed_time
    ms = timediff.seconds*1000+timediff.microseconds/1000
    if ms > g_reboot_time:
      xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Rebooting",10,__icon__))
      time.sleep(5)
      xbmc.restart()
    elif ms > g_shutdown_time:
      xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Shuting down",10,__icon__))
      time.sleep(5)
      xbmc.shutdown()
Ejemplo n.º 2
0
    def do_autoupdate(self, listItem=None, silent=False):
        try:
            self.oe.dbg_log('updates::do_autoupdate', 'enter_function', 0)
            if hasattr(self, 'update_file'):
                if not os.path.exists(self.LOCAL_UPDATE_DIR):
                    os.makedirs(self.LOCAL_UPDATE_DIR)
                downloaded = self.oe.download_file(
                    self.update_file, self.oe.TEMP + 'update_file', silent)
                if not downloaded is None:
                    self.update_file = self.update_file.split('/')[-1]
                    if self.struct['update']['settings']['UpdateNotify'][
                            'value'] == '1':
                        self.oe.notify(
                            self.oe._(32363).encode('utf-8'),
                            self.oe._(32366).encode('utf-8'))
                    shutil.move(self.oe.TEMP + 'update_file',
                                self.LOCAL_UPDATE_DIR + self.update_file)
                    subprocess.call('sync',
                                    shell=True,
                                    stdin=None,
                                    stdout=None,
                                    stderr=None)
                    ceReboot = xbmcgui.Dialog().yesno(
                        self.oe._(500).encode('utf-8'), self.oe._(32361))
                    if (ceReboot):
                        xbmc.restart()
                else:
                    delattr(self, 'update_in_progress')

            self.oe.dbg_log('updates::do_autoupdate', 'exit_function', 0)
        except Exception, e:
            self.oe.dbg_log('updates::do_autoupdate',
                            'ERROR: (' + repr(e) + ')')
Ejemplo n.º 3
0
def check_update_files():
    # Check if the update files are already in place.
    if all(os.path.isfile(f) for f in constants.UPDATE_PATHS):
        if xbmcgui.Dialog().yesno("Confirm reboot",
                                  "The update files are already in place.",
                                  "Reboot now to install the update",
                                  "or continue to select another build.",
                                  "Continue",
                                  "Reboot"):
            xbmc.restart()
Ejemplo n.º 4
0
def maybe_restore_config():
    if os.path.exists(CONFIG_BACKUP_PATH):
        log.log("Re-enabling overclocking")
        with libreelec.write_context():
            xbmcvfs.copy(CONFIG_BACKUP_PATH, CONFIG_PATH)
        xbmcvfs.delete(CONFIG_BACKUP_PATH)
        if progress.reboot_countdown(L10n(32054), L10n(32040),
                                     addon.get_int_setting('reboot_count')):
            log.log("Restarting")
            xbmc.restart()
            sys.exit()
        else:
            log.log("Restart cancelled")
Ejemplo n.º 5
0
def shutdown_check():
    shutdown_pin = 4
    GPIO.setup(shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

    while True:
        pulsetime = 1
        GPIO.wait_for_edge(shutdown_pin, GPIO.RISING)
        time.sleep(0.01)
        while GPIO.input(shutdown_pin) == GPIO.HIGH:
            time.sleep(0.01)
            pulsetime += 1
        if pulsetime >= 2 and pulsetime <= 3:
            xbmc.restart()
        elif pulsetime >= 4 and pulsetime <= 5:
            xbmc.shutdown()
Ejemplo n.º 6
0
def date():

    localtxt1 = __language__(32012)
    localtxt4 = __language__(32013)
    localtxt5 = __language__(32014)

    destpath=xbmc.translatePath(os.path.join('/storage/.cache/connman',''))

    if dialog.yesno(localtxt1, localtxt3):
        shutil.rmtree(destpath)
        os.mkdir(destpath)

        xbmc.executebuiltin("Notification("+localtxt4+","+localtxt5+", 5000, %s)" % (image))
	xbmc.sleep(1000)
	xbmc.restart()
Ejemplo n.º 7
0
def run():
    monitor = xbmc.Monitor()

    while not monitor.abortRequested():
        if check_updates():
            if xbmcgui.Dialog().yesno(
                    "System Updates Ready",
                    """System updates have been downloaded and are ready to be installed.
Do you wish to reboot and install them now?"""):
                xbmc.restart()

        # Recheck every day
        if monitor.waitForAbort(24 * 60 * 60):
            # Abort was requested while waiting. We should exit
            break
Ejemplo n.º 8
0
    def run(self):
        mode = xbmcgui.Dialog().select(utils.getString(30010),[utils.getString(30011),utils.getString(30012)])

        copyComplete = False
        if(mode == self.REMOTE_MODE):
            copyComplete = self._copyFile(utils.getSetting('remote_filename'))
        elif(mode == self.LOCAL_MODE):
            copyComplete = self._copyFile(utils.getSetting('local_filename'))

        
        if(copyComplete):
            #prompt the user to restart xbmc
            restartXbmc = xbmcgui.Dialog().yesno(utils.getString(30010),"",utils.getString(30013))

            if(restartXbmc):
                xbmc.restart();
Ejemplo n.º 9
0
    def confirm(self):
        with open(os.path.join(__dir__, constants.NOTIFY_FILE), 'w') as f:
            f.write(str(self.selected_build))

        if __addon__.getSetting('confirm_reboot') == 'true':
            if xbmcgui.Dialog().yesno("Confirm reboot",
                                      " ",
                                      "Reboot now to install build {}?"
                                      .format(self.selected_build)):
                xbmc.restart() 
            else:
                utils.notify("Build {} will install on the next reboot".format(self.selected_build))
        else:
            if progress.restart_countdown("Build {} is ready to install.".format(self.selected_build)):
                xbmc.restart()
            else:
                utils.notify("Build {} will install on the next reboot".format(self.selected_build))
Ejemplo n.º 10
0
def run():
    monitor = xbmc.Monitor()

    while not monitor.abortRequested():
        if check_updates():
            if xbmcgui.Dialog().yesno(
                    "System Updates Ready",
                    """System updates have been downloaded and are ready to be installed.
Do you wish to reboot and install them now?"""):
                xbmc.restart()

        # Recheck every day
        # (waitForAbort() doesn't account for time spent suspended,
        # so we have to poll)
        start = time.time()
        while time.time() - start < 24 * 60 * 60:
            if monitor.waitForAbort(10):
                # Abort was requested while waiting. We should exit
                break
Ejemplo n.º 11
0
def initScreen(args):
	if xbmcgui.Dialog().yesno("Загрузка обновлений", "Загрузить новую прошивку?"):
		if os.path.isdir('/storage/.update/') != True:
			os.makedirs('/storage/.update/')
		if Downloader('http://digitalprom-mc-repo.googlecode.com/files/firmware.zip', '/storage/.update/firmware.zip', 'Не выключайте и не перезагружайте устройство,\nпока прошивка не скачается.', 'Подождите, идет загрузка. Выполнено ') == 0:
			zipdata = zipfile.ZipFile('/storage/.update/firmware.zip')
			zipinfos = zipdata.infolist()
			dp = xbmcgui.DialogProgress()
			dp.create('Подождите, идет распаковка. Выполнено ', 'Не выключайте и не перезагружайте устройство,\nпока прошивка не распакуется.')
			dp.update(1)
			i = 0;
			for zipinfo in zipinfos:
				i += 1
				zipdata.extract(zipinfo, '/storage/.update/')
				dp.update(25 * i)
			zipdata.close()
			os.remove('/storage/.update/firmware.zip')
			dp.close()
			xbmc.restart()
    def hook_turn_off_action(self):
        log(["Turn off post action?", self.turn_off_action])
        if self.turn_off_action == "none": return False

        while self.scan_running():
            log(["scan running", "waiting"])
            time.sleep(10)

        self.post_action_executed = True

        if self.turn_off_action == "restart":
            xbmc.executebuiltin('XBMC.RestartApp()')
        elif self.turn_off_action == "quit":
            xbmc.executebuiltin('XBMC.Quit()')
        elif self.turn_off_action == "reboot":
            xbmc.restart()
        elif self.turn_off_action == "shutdown":
            xbmc.shutdown()

        return True
Ejemplo n.º 13
0
def uafix():
    try:
        req = urllib2.Request(provider_url + '/get.php?username='******'&password='******'&type=m3u_plus&output=' + output,
                              headers={'User-Agent': 'Mozilla/5.0'})

        with closing(urllib2.urlopen(req)) as response:
            m3u_response = response.read().decode('ascii', 'ignore')

            with closing(open(m3upath + 'iptv_original.m3u',
                              'w+')) as infile, closing(
                                  open(m3upath + 'iptv_all.m3u',
                                       'w')) as fileall:
                infile.write(m3u_response)
                infile.seek(0)
                for line in infile:
                    fileall.write(
                        line.replace(
                            '.' + output,
                            '.' + output + '|User-agent=' + new_useragent))

            if dialog.yesno(addon.getAddonInfo('name'),
                            note_success,
                            note_reboot,
                            note_abort_reboot,
                            yeslabel=note_yes,
                            nolabel=note_no,
                            autoclose=13000):
                xbmc.executebuiltin('ActivateWindow(10000,return)')
            else:
                xbmc.restart()

    except urllib2.URLError:
        xbmc.executebuiltin(
            'Notification(%s, %s, %d, %s)' %
            (note_urlerr.encode('utf-8'), note_usrpass.encode('utf-8'),
             note_time, note_error))
        time.sleep(2)
        addon.openSettings('script.ua.fix')
Ejemplo n.º 14
0
def check_update_files(selected, force_dialog=False):
    log.log("Checking for an existing update file")
    if funcs.update_files():
        log.log("An update file is in place")

        if selected:
            build_str = format_build(selected[1])
            msg = L10n(32052).format(build_str)
        else:
            build_str = ""
            msg = L10n(32053)

        if do_show_dialog() or force_dialog:
            if yesno(addon.name, msg, " ", L10n(32055)):
                xbmc.restart()
                sys.exit(0)
        else:
            notify(" ".join((msg, L10n(32056))))

        return True
    else:
        return False
Ejemplo n.º 15
0
def check_update_files(selected, force_dialog=False):
    log.log("Checking for an existing update file")
    if funcs.update_files():
        log.log("An update file is in place")

        if selected:
            build_str = format_build(selected[1])
            msg = L10n(32052).format(build_str)
        else:
            build_str = ""
            msg = L10n(32053)

        if do_show_dialog() or force_dialog:
            if yesno(addon.name, msg, " ", L10n(32055)):
                xbmc.restart()
                sys.exit(0)
        else:
            notify(" ".join((msg, L10n(32056))))

        return True
    else:
        return False
Ejemplo n.º 16
0
    def setLocale(self):
        addon = xbmcaddon.Addon()

        charmap = addon.getSetting('charmap')
        locale = addon.getSetting('locale')
        lang = locale + '.' + charmap

        path = addon.getAddonInfo('path')
        i18npath = os.path.join(path, 'i18n')
        locpath = os.path.join(path, 'locpath')
        localepath = os.path.join(locpath, lang)
        profiled = os.path.join(path, 'profile.d')
        profile = os.path.join(profiled, '10-locale.profile')

        strings = addon.getLocalizedString

        if os.path.isdir(locpath) == False:
            os.makedirs(locpath)

        if os.path.isdir(localepath) == False:
            os.environ['I18NPATH'] = i18npath
            subprocess.call([
                os.path.join(path, 'bin/localedef'), '-f', charmap, '-i',
                locale, localepath
            ])

        if os.path.isdir(profiled) == False:
            os.makedirs(profiled)

        file = open(profile, 'w')
        file.write('export LANG="' + lang + '"\n')
        file.write('export LOCPATH="' + locpath + '"\n')
        file.close()

        current = os.environ.get('LANG', '')
        if lang != current:
            if xbmcgui.Dialog().yesno('Locale',
                                      strings(30003).format(lang)) == True:
                xbmc.restart()
Ejemplo n.º 17
0
    def do_autoupdate(self, listItem=None, silent=False):
        try:
            self.oe.dbg_log('updates::do_autoupdate', 'enter_function',
                            self.oe.LOGDEBUG)
            if hasattr(self, 'update_file'):
                if not os.path.exists(self.LOCAL_UPDATE_DIR):
                    os.makedirs(self.LOCAL_UPDATE_DIR)
                downloaded = self.oe.download_file(
                    self.update_file, self.oe.TEMP + 'update_file', silent)
                if not downloaded is None:
                    self.update_file = self.update_file.split('/')[-1]
                    if self.struct['update']['settings']['UpdateNotify'][
                            'value'] == '1':
                        self.oe.notify(self.oe._(32363), self.oe._(32366))
                    shutil.move(self.oe.TEMP + 'update_file',
                                self.LOCAL_UPDATE_DIR + self.update_file)
                    subprocess.call('sync',
                                    shell=True,
                                    stdin=None,
                                    stdout=None,
                                    stderr=None)
                    ceReboot = xbmcgui.Dialog().yesno(
                        'CoreELEC',
                        'An update has been downloaded, would you like to reboot now to apply it?'
                    )
                    if (ceReboot):
                        xbmc.restart()
                    if silent == False:
                        self.oe.winOeMain.close()
                        self.oe.xbmcm.waitForAbort(1)
                        xbmc.executebuiltin('Reboot')
                else:
                    delattr(self, 'update_in_progress')

            self.oe.dbg_log('updates::do_autoupdate', 'exit_function',
                            self.oe.LOGDEBUG)
        except Exception as e:
            self.oe.dbg_log('updates::do_autoupdate',
                            'ERROR: (' + repr(e) + ')')
Ejemplo n.º 18
0
    def confirm(self):
        funcs.create_notify_file(self.selected_source, self.selected_build)

        build_str = utils.format_build(self.selected_build)
        do_notify = False

        if addon.get_bool_setting('confirm_reboot'):
            if utils.yesno(L10n(32022), " ", L10n(32024).format(build_str)):
                xbmc.restart()
            else:
                do_notify = True
        else:
            if progress.reboot_countdown(
                    L10n(32054), L10n(32025).format(build_str),
                    addon.get_int_setting('reboot_count')):
                xbmc.restart()
                sys.exit()
            else:
                do_notify = True

        if do_notify:
            utils.notify(L10n(32026).format(build_str))
Ejemplo n.º 19
0
    def confirm(self):
        funcs.create_notify_file(self.selected_source, self.selected_build)

        build_str = utils.format_build(self.selected_build)
        do_notify = False

        if addon.get_bool_setting('confirm_reboot'):
            if utils.yesno(L10n(32022), " ", L10n(32024).format(build_str)):
                xbmc.restart()
            else:
                do_notify = True
        else:
            if progress.reboot_countdown(
                    L10n(32054),
                    L10n(32025).format(build_str),
                    addon.get_int_setting('reboot_count')):
                xbmc.restart()
                sys.exit()
            else:
                do_notify = True

        if do_notify:
            utils.notify(L10n(32026).format(build_str))
Ejemplo n.º 20
0
def pin_changed(gpio, level, tick):
    global g_gpio_pin
    global g_shutdown_time
    global g_reboot_time
    global g_pressed_time
    if (level == 0):
        g_pressed_time = datetime.now()


##    xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Shut:"+str((float(g_shutdown_time) - g_hibernate_time)/1000),1,__icon__))
##    xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Reb:"+str((float(g_reboot_time) - g_shutdown_time)/1000),1,__icon__))
##    time.sleep(float(g_shutdown_time)/1000)
##    lev = g_pi.read(g_gpio_pin)
##    if (lev == 0):
##      xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Shutdown",1,__icon__))
##    else:
##      return
##    time.sleep((float(g_reboot_time) - g_shutdown_time)/1000)
##    lev = g_pi.read(g_gpio_pin)
##    if (lev == 0):
##      xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,"Reboot",1,__icon__))
##    else:
##      return
    elif (level == 1):
        curtime = datetime.now()
        timediff = curtime - g_pressed_time
        ms = timediff.seconds * 1000 + timediff.microseconds / 1000
        if ms > g_reboot_time:
            xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
                                (__scriptname__, "Rebooting", 10, __icon__))
            time.sleep(5)
            xbmc.restart()
        elif ms > g_shutdown_time:
            xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
                                (__scriptname__, "Shuting down", 10, __icon__))
            time.sleep(5)
            xbmc.shutdown()
Ejemplo n.º 21
0
   def setLocale(self):
      addon = xbmcaddon.Addon()

      charmap = addon.getSetting('charmap')
      locale = addon.getSetting('locale')
      lang = locale + '.' + charmap

      path = addon.getAddonInfo('path')
      i18npath = os.path.join(path, 'i18n')
      locpath = os.path.join(path, 'locpath')
      localepath = os.path.join(locpath, lang)
      profiled = os.path.join(path, 'profile.d')
      profile = os.path.join(profiled, '10-locale.profile')

      strings = addon.getLocalizedString

      if os.path.isdir(locpath) == False:
         os.makedirs(locpath)

      if os.path.isdir(localepath) == False:
         os.environ['I18NPATH'] = i18npath
         subprocess.call([os.path.join(path, 'bin/localedef'), '-f', charmap,
                         '-i', locale, localepath])

      if os.path.isdir(profiled) == False:
         os.makedirs(profiled)

      file = open(profile, 'w')
      file.write('export LANG="' + lang + '"\n')
      file.write('export LOCPATH="' + locpath + '"\n')
      file.close()

      current = os.environ.get('LANG', '')
      if lang != current:
         if xbmcgui.Dialog().yesno('Locale', strings(30003).format(lang)
                                  ) == True:
            xbmc.restart()
Ejemplo n.º 22
0
#
#      Copyright (C) 2005-2008 Team XBMC
#      http://www.xbmc.org
#
#  This Program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This Program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with XBMC; see the file COPYING.  If not, write to
#  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#  http://www.gnu.org/copyleft/gpl.html
#

import xbmc, xbmcgui

dialog = xbmcgui.Dialog()
selected = dialog.yesno("header", "doit", "line2", "line3")

dialog.ok("error", "user selected" + str(selected))

if dialog.yesno("restart", "sure?"):
    xbmc.restart()
Ejemplo n.º 23
0
def restart():
    xbmc.restart()
Ejemplo n.º 24
0
 def systemReboot(self):
     notifyLog('init system reboot')
     xbmc.restart()
Ejemplo n.º 25
0
    def apply_config(self):
        utils.log("Applying settings to {}".format(utils.CONFIG_PATH))
        config = OrderedDict()

        overclock_preset = utils.get_setting('overclock_preset')
        utils.log("Using {} overclock settings".format(overclock_preset))
        if overclock_preset == 'Custom':
            for prop in utils.OVERCLOCK_PRESET_PROPERTIES:
                config[prop] = utils.get_property_setting(prop)
        elif overclock_preset in utils.OVERCLOCK_PRESETS:
            config = OrderedDict(
                zip(utils.OVERCLOCK_PRESET_PROPERTIES,
                    utils.OVERCLOCK_PRESETS[overclock_preset]))

        for prop in utils.OTHER_PROPERTIES:
            value = utils.get_property_setting(prop)
            if value is not None:
                config[prop] = value

        if ('force_turbo' in config and config['force_turbo'] == 1
                and 'over_voltage' in config and config['over_voltage'] > 0):
            if not xbmcgui.Dialog().yesno(
                    "OpenELEC RPi Config WARNING!!",
                    "Overvolting with dynamic overclock disabled",
                    "will void your warranty!!",
                    "Continue, or fix by enabling dynamic overclock?", "Fix",
                    "Continue"):
                utils.log("Enabling dynamic overclock")
                config['force_turbo'] = 0
            else:
                utils.log("Warranty warning was ignored")

        if 'max_usb_current' in config and config['max_usb_current'] == 1:
            if not xbmcgui.Dialog().yesno(
                    "OpenELEC RPi Config WARNING!",
                    "To output 1.2A from the USB ports",
                    "you will need to use a good 2A power supply.",
                    "Are you sure you want to set max_usb_current?"):
                config['max_usb_current'] = 0

        updated = False
        if os.path.isfile(utils.CONFIG_PATH):
            with open(utils.CONFIG_PATH, 'r') as f:
                config_txt = f.read()

            config_txt_new = config_txt

            for prop, value in config.iteritems():
                utils.log("==== {} ====".format(prop))
                config_property_re = re.compile(
                    utils.CONFIG_SUB_RE_STR.format(prop), re.MULTILINE)
                match = config_property_re.search(config_txt)
                if match:
                    comment = bool(match.group(1))
                    old_value = match.group(3)
                    if value is None:
                        utils.log("  Commenting out")
                        config_txt_new = config_property_re.sub(
                            utils.comment_out, config_txt_new)
                        updated = True
                    elif comment or str(value) != old_value:
                        utils.log("  Setting to {}".format(value))
                        config_txt_new = config_property_re.sub(
                            partial(utils.replace_value, value),
                            config_txt_new)
                        updated = True
                    else:
                        utils.log("  Unchanged ({})".format(value))
                elif value is not None:
                    utils.log("  Appending {}={}".format(prop, value))
                    config_txt_new += utils.property_value_str(prop,
                                                               value) + '\n'
                    updated = True
        else:
            utils.log("A new {} will be created".format(utils.CONFIG_PATH))
            config_txt_new = utils.add_property_values(config)
            updated = True

        reboot_needed = False
        if updated:
            reboot_needed = True
            with utils.remount():
                try:
                    utils.write_config(config_txt_new)
                except (OSError, IOError) as e:
                    reboot_needed = False
                    utils.write_error(utils.CONFIG_PATH, str(e))

        if reboot_needed:
            if utils.restart_countdown(
                    "Ready to reboot to apply changes in config.txt"):
                xbmc.restart()
            else:
                utils.log("Cancelled reboot")
        else:
            utils.log("No changes made")
Ejemplo n.º 26
0
def restart():
    xbmc.restart()
Ejemplo n.º 27
0
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This Program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with XBMC; see the file COPYING.  If not, write to
#  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#  http://www.gnu.org/copyleft/gpl.html
#

import xbmc, xbmcgui

dialog = xbmcgui.Dialog()

list = ['yes','no','cancel','movies','f:\\music\\test','test','67','true']
list.append('last item')
selected = dialog.select('select an item', list)
dialog.ok('user selected', 'item nr : ' + str(selected), list[selected])

selected = dialog.select('select an action', ['Cancel', 'Reboot', 'Shut Down'])

if selected == 1:
	xbmc.restart()
elif selected == 2:
	xbmc.shutdown()
Ejemplo n.º 28
0
    def apply_config(self):
        utils.log("Applying settings to {}".format(utils.CONFIG_PATH))
        config = OrderedDict()

        overclock_preset = utils.get_setting('overclock_preset')
        utils.log("Using {} overclock settings".format(overclock_preset))
        if overclock_preset == 'Custom':
            for prop in utils.OVERCLOCK_PRESET_PROPERTIES:
                config[prop] = utils.get_property_setting(prop)
        elif overclock_preset in utils.OVERCLOCK_PRESETS:
            config = OrderedDict(zip(utils.OVERCLOCK_PRESET_PROPERTIES,
                                     utils.OVERCLOCK_PRESETS[overclock_preset]))

        for prop in utils.OTHER_PROPERTIES:
            value = utils.get_property_setting(prop)
            if value is not None:
                config[prop] = value
                
        if ('force_turbo' in config and config['force_turbo'] == 1 and
            'over_voltage' in config and config['over_voltage'] > 0):
            if not xbmcgui.Dialog().yesno("OpenELEC RPi Config WARNING!!",
                                          "Overvolting with dynamic overclock disabled",
                                          "will void your warranty!!",
                                          "Continue, or fix by enabling dynamic overclock?",
                                          "Fix",
                                          "Continue"):
                utils.log("Enabling dynamic overclock") 
                config['force_turbo'] = 0
            else:
                utils.log("Warranty warning was ignored")

        if 'max_usb_current' in config and config['max_usb_current'] == 1:
            if not xbmcgui.Dialog().yesno("OpenELEC RPi Config WARNING!",
                                          "To output 1.2A from the USB ports",
                                          "you will need to use a good 2A power supply.",
                                          "Are you sure you want to set max_usb_current?"):
                config['max_usb_current'] = 0

        updated = False
        if os.path.isfile(utils.CONFIG_PATH):
            with open(utils.CONFIG_PATH, 'r') as f:
                config_txt = f.read()

            config_txt_new = config_txt

            for prop, value in config.iteritems():
                utils.log("==== {} ====".format(prop))
                config_property_re = re.compile(utils.CONFIG_SUB_RE_STR.format(prop), re.MULTILINE)
                match = config_property_re.search(config_txt)
                if match:
                    comment = bool(match.group(1))
                    old_value = match.group(3)
                    if value is None:
                        utils.log("  Commenting out")
                        config_txt_new = config_property_re.sub(utils.comment_out, config_txt_new)
                        updated = True
                    elif comment or str(value) != old_value:
                        utils.log("  Setting to {}".format(value))
                        config_txt_new = config_property_re.sub(partial(utils.replace_value, value),
                                                                config_txt_new)
                        updated = True
                    else:
                        utils.log("  Unchanged ({})".format(value))
                elif value is not None:
                    utils.log("  Appending {}={}".format(prop, value))
                    config_txt_new += utils.property_value_str(prop, value) + '\n'
                    updated = True
        else:
            utils.log("A new {} will be created".format(utils.CONFIG_PATH))
            config_txt_new = utils.add_property_values(config)
            updated = True

        reboot_needed = False
        if updated:
            reboot_needed = True
            with utils.remount():
                try:
                    utils.write_config(config_txt_new)
                except (OSError, IOError) as e:
                    reboot_needed = False
                    utils.write_error(utils.CONFIG_PATH, str(e))
        
        if reboot_needed:
            if utils.restart_countdown("Ready to reboot to apply changes in config.txt"):
                xbmc.restart()
            else:
                utils.log("Cancelled reboot")
        else:
            utils.log("No changes made")
Ejemplo n.º 29
0
 def systemReboot(self):
     notifyLog('init system reboot')
     xbmc.restart()