Esempio n. 1
0
 def do_list(cls, args):
     current_sdk = sdk_manager.get_current_sdk()
     local_sdks = sdk_manager.list_local_sdks()
     local_sdk_versions = sdk_manager.list_local_sdk_versions()
     sorted_local_sdks = sorted(local_sdks, key=lambda x: version_to_key(x['version']), reverse=True)
     if len(local_sdks) > 0:
         print("Installed SDKs:")
         for sdk in sorted_local_sdks:
             line = sdk['version']
             if sdk['channel']:
                 line += " ({})".format(sdk['channel'])
             if sdk['version'] == current_sdk:
                 line += " (active)"
             print(line)
         print()
     else:
         print("No SDKs installed yet.")
     if sdk_manager.get_channel() != '':
         channel_text = ' ({} channel)'.format(sdk_manager.get_channel())
     else:
         channel_text = ''
     print("Available SDKs{}:".format(channel_text))
     try:
         for sdk in sdk_manager.list_remote_sdks():
             if sdk['version'] in local_sdk_versions:
                 continue
             line = sdk['version']
             if sdk['channel']:
                 line += " ({})".format(sdk['channel'])
             if sdk['version'] == current_sdk:
                 line += " (active)"
             print(line)
     except requests.RequestException:
         print("Could not fetch list of available SDKs.")
Esempio n. 2
0
    def run(self):
        last_check = config.get('update-checks', {}).get(self.component, {})
        if last_check.get('timestamp',
                          0) < time.time() - 86400:  # minus one day
            logger.debug("Haven't looked for updates lately; checking...")
            try:
                latest = sdk_manager.request(
                    "/v1/files/{}/latest?channel={}".format(
                        self.component, sdk_manager.get_channel()))
            except requests.RequestException as e:
                logger.info("Update check failed: %s", e)
                return
            if not 200 <= latest.status_code < 400:
                logger.info("Update check failed: %s (%s)", latest.status_code,
                            latest.reason)
                return

            result = latest.json()
            with config.lock:
                config.setdefault('update-checks', {})[self.component] = {
                    'timestamp': time.time(),
                    'version': result['version'],
                    'release_notes': result.get('release_notes', None)
                }
            self._check_version(result['version'],
                                result.get('release_notes', None))
        else:
            self._check_version(last_check['version'],
                                last_check.get('release_notes', None))
Esempio n. 3
0
def _handle_tool_update(version, release_notes=None):
    _print()
    _print("An updated pebble tool, version {}, is available.".format(version))
    if release_notes is not None:
        _print(release_notes)
    if 'PEBBLE_IS_HOMEBREW' in os.environ:
        flag = ' --devel' if sdk_manager.get_channel() == 'beta' else ''
        _print("Run `brew update && brew upgrade{} pebble-sdk` to get it.".format(flag))
    else:
        _print("Head to https://developer.getpebble.com/sdk/ to get it.")
Esempio n. 4
0
def _handle_tool_update(version, release_notes=None):
    _print()
    _print("An updated pebble tool, version {}, is available.".format(version))
    if release_notes is not None:
        _print(release_notes)
    if 'PEBBLE_IS_HOMEBREW' in os.environ:
        flag = ' --devel' if sdk_manager.get_channel() == 'beta' else ''
        _print(
            "Run `brew update && brew upgrade{} pebble-sdk` to get it.".format(
                flag))
    else:
        _print("Head to https://developer.getpebble.com/sdk/ to get it.")
Esempio n. 5
0
 def do_list(cls, args):
     current_sdk = sdk_manager.get_current_sdk()
     local_sdks = sdk_manager.list_local_sdks()
     local_sdk_versions = sdk_manager.list_local_sdk_versions()
     sorted_local_sdks = sorted(local_sdks,
                                key=lambda x: version_to_key(x['version']),
                                reverse=True)
     if len(local_sdks) > 0:
         print("Installed SDKs:")
         for sdk in sorted_local_sdks:
             line = sdk['version']
             if sdk['channel']:
                 line += " ({})".format(sdk['channel'])
             if sdk['version'] == current_sdk:
                 line += " (active)"
             print(line)
         print()
     else:
         print("No SDKs installed yet.")
     if sdk_manager.get_channel() != '':
         channel_text = ' ({} channel)'.format(sdk_manager.get_channel())
     else:
         channel_text = ''
     print("Available SDKs{}:".format(channel_text))
     try:
         for sdk in sdk_manager.list_remote_sdks():
             if sdk['version'] in local_sdk_versions:
                 continue
             line = sdk['version']
             if sdk['channel']:
                 line += " ({})".format(sdk['channel'])
             if sdk['version'] == current_sdk:
                 line += " (active)"
             print(line)
     except requests.RequestException:
         print("Could not fetch list of available SDKs.")
Esempio n. 6
0
    def run(self):
        last_check = config.get('update-checks', {}).get(self.component, {})
        if last_check.get('timestamp', 0) < time.time() - 86400:  # minus one day
            logger.debug("Haven't looked for updates lately; checking...")
            latest = sdk_manager.request("/v1/files/{}/latest?channel={}"
                                  .format(self.component, sdk_manager.get_channel()))
            if not 200 <= latest.status_code < 400:
                logger.info("Update check failed: %s (%s)", latest.status_code, latest.reason)
                return

            result = latest.json()
            with config.lock:
                config.setdefault('update-checks', {})[self.component] = {
                    'timestamp': time.time(),
                    'version': result['version'],
                }
            self._check_version(result['version'])
        else:
            self._check_version(last_check['version'])
Esempio n. 7
0
 def do_set_channel(cls, args):
     sdk_manager.set_channel(args.channel)
     print("Set channel to {}.".format(sdk_manager.get_channel()))
Esempio n. 8
0
 def do_set_channel(cls, args):
     sdk_manager.set_channel(args.channel)
     print("Set channel to {}.".format(sdk_manager.get_channel()))