Exemple #1
0
    def run(self):
        provName = self.get_option("name")
        orgName = self.get_option("org")
        manifestPath = self.get_option("file")
        force = self.get_option("force")

        try:
            f = open(get_abs_path(manifestPath))
        except IOError:
            system_exit(os.EX_IOERR, _("File %s does not exist") % manifestPath)

        prov = get_provider(orgName, provName)

        try:
            response = run_spinner_in_bg(
                self.api.import_manifest, (prov["id"], f, force), message=_("Importing manifest, please wait... ")
            )
        except ServerRequestError, re:
            if (
                re.args[0] == 400
                and "displayMessage" in re.args[1]
                and re.args[1]["displayMessage"] == "Import is older than existing data"
            ):
                re.args[1]["displayMessage"] = (
                    "Import is older than existing data," + " please try with --force option to import manifest."
                )
            raise re, None, sys.exc_info()[2]
Exemple #2
0
    def read_content(self, use_prompt):
        gpgkey_file = self.get_option('file')

        if gpgkey_file:
            with open(get_abs_path(gpgkey_file), "r") as f:
                content = f.read()
        elif use_prompt:
            print _("Enter content of the GPG key (finish input with CTRL+D):")
            content = stdin.read()
        else:
            content = None
        return content
Exemple #3
0
    def read_content(self, use_prompt):
        gpgkey_file = self.get_option('file')

        if gpgkey_file:
            with open(get_abs_path(gpgkey_file), "r") as f:
                content = f.read()
        elif use_prompt:
            print _("Enter content of the GPG key (finish input with CTRL+D):")
            content = stdin.read()
        else:
            content = None
        return content
Exemple #4
0
    def run(self):
        provName = self.get_option('name')
        orgName  = self.get_option('org')
        manifestPath = self.get_option('file')
        force = self.get_option('force')

        try:
            f = open(get_abs_path(manifestPath))
        except IOError:
            system_exit(os.EX_IOERR, _("File %s does not exist") % manifestPath)

        prov = get_provider(orgName, provName)

        task = ManifestAsyncTask(self.api.import_manifest(prov["id"], f, force))
        run_spinner_in_bg(wait_for_async_task, [task], message=_("Importing manifest, please wait... "))

        return ManifestAsyncTask.evaluate_task_status(task,
            failed =   _("Provider [ %s ] failed to import manifest") % provName,
            canceled = _("Provider [ %s ] canceled manifest import") % provName,
            ok =       _("Provider [ %s ] manifest import complete") % provName
        )
Exemple #5
0
    def run(self):
        provName = self.get_option('name')
        orgName = self.get_option('org')
        manifestPath = self.get_option('file')
        force = self.get_option('force')

        try:
            f = open(get_abs_path(manifestPath))
        except IOError:
            system_exit(os.EX_IOERR,
                        _("File %s does not exist") % manifestPath)

        prov = get_provider(orgName, provName)

        task = ManifestAsyncTask(self.api.import_manifest(
            prov["id"], f, force))
        run_spinner_in_bg(wait_for_async_task, [task],
                          message=_("Importing manifest, please wait... "))

        return ManifestAsyncTask.evaluate_task_status(
            task,
            failed=_("Provider [ %s ] failed to import manifest") % provName,
            canceled=_("Provider [ %s ] canceled manifest import") % provName,
            ok=_("Provider [ %s ] manifest import complete") % provName)
Exemple #6
0
 def open_file(cls, path):
     return open(get_abs_path(path),"w")