Beispiel #1
0
    def __init__(self, shortcut):
        super(PPAShortcutHandler, self).__init__()
        try:
            self.shortcut = mangle_ppa_shortcut(shortcut)
        except:
            raise ShortcutException(_("ERROR: '{shortcut}' is not a valid ppa format")
                                      .format(shortcut=shortcut))
        info = get_ppa_info(self.shortcut)

        if "private" in info and info["private"]:
            raise ShortcutException(
                _("Adding private PPAs is not supported currently"))

        self._info = info
    def __init__(self, shortcut):
        self.shortcut = shortcut

        prefix = "cloud-archive:"

        subs = {
            'shortcut': shortcut,
            'prefix': prefix,
            'ca_names': sorted(MAP.keys())
        }
        if not shortcut.startswith(prefix):
            raise ValueError(
                _("shortcut '%(shortcut)s' did not start with '%(prefix)s'") %
                subs)

        name_in = shortcut[len(prefix):]
        caname = ALIASES.get(name_in, name_in)

        subs.update({'input_name': name_in})
        if caname not in MAP:
            raise ShortcutException(
                _("'%(input_name)s': not a valid cloud-archive name.\n"
                  "Must be one of %(ca_names)s") % subs)

        self.caname = caname
        self._info = MAP[caname].copy()
        self._info['web_link'] = WEB_LINK
Beispiel #3
0
 def expand(self, codename, distro=None):
     if codename not in (MAP[self.caname]['release'],
                         os.environ.get("CA_ALLOW_CODENAME")):
         raise ShortcutException(
             _("cloud-archive for %(os_release)s only supported on %(codename)s")
             % {'codename': MAP[self.caname]['release'],
                'os_release': self.caname.capitalize()})
     dist = MAP[self.caname]['sldfmt'] % {'codename': codename}
     line = ' '.join(('deb', MIRROR, dist, 'main',))
     return (line, _fname_for_caname(self.caname))
Beispiel #4
0
    def __init__(self, shortcut):
        super(PPAShortcutHandler, self).__init__()
        self.shortcut = mangle_ppa_shortcut(shortcut)
        info = get_ppa_info(self.shortcut)

        if "private" in info and info["private"]:
            raise ShortcutException(
                _("Adding private PPAs is not supported currently"))

        self._info = info
Beispiel #5
0
def get_ppa_info(shortcut):
    user = shortcut.split("/")[0]
    ppa = "/".join(shortcut.split("/")[1:])
    try:
        ret = get_ppa_info_from_lp(user, ppa)
        ret["distribution"] = ret["distribution_link"].split('/')[-1]
        ret["owner"] = ret["owner_link"].split('/')[-1]
        return ret
    except (HTTPError, Exception):
        msg = []
        msg.append(_("Cannot add PPA: 'ppa:%s/%s'.") % (user, ppa))

        # If the PPA does not exist, then try to find if the user/team
        # exists. If it exists, list down the PPAs
        raise ShortcutException('\n'.join(msg) + "\n" +
                                _get_suggested_ppa_message(user, ppa))

    except (ValueError, PPAException):
        raise ShortcutException(
            _("Cannot access PPA (%s) to get PPA information, "
              "please check your internet connection.") % \
              (LAUNCHPAD_PPA_API % (user, ppa)))
Beispiel #6
0
 def expand(self, codename):
     if codename not in (CODENAME, os.environ.get("CA_ALLOW_CODENAME")):
         raise ShortcutException(
             _("cloud-archive only supported on %(codename)s") %
             {'codename': CODENAME})
     dist = MAP[self.caname]['sldfmt'] % {'codename': codename}
     line = ' '.join((
         'deb',
         MIRROR,
         dist,
         'main',
     ))
     return (line, _fname_for_caname(self.caname))