示例#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 then existing data," + " please try with --force option to import manifest."
                )
            raise re, None, sys.exc_info()[2]
示例#2
0
文件: gpg_key.py 项目: pmutha/katello
    def read_content(self, use_prompt):
        file = self.get_option('file')

        if file:
            with open(get_abs_path(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
示例#3
0
    def read_content(self, use_prompt):
        file = self.get_option('file')

        if file:
            with open(get_abs_path(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
示例#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:
            print _("File %s does not exist" % manifestPath)
            return os.EX_IOERR

        prov = get_provider(orgName, provName)
        if prov != None:
            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 then existing data, please try with --force option to import manifest."
                raise re
            f.close()
            print response
            return os.EX_OK
示例#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:
            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 then existing data, please try with --force option to import manifest."
            raise re
示例#6
0
 def open_file(self, path):
     return open(get_abs_path(path),"w")
示例#7
0
 def open_file(cls, path):
     return open(get_abs_path(path),"w")
示例#8
0
 def open_file(self, path):
     return open(get_abs_path(path),"w")