ok
Direktori : /sbin/ |
Current File : //sbin/clncheck-3.6 |
#!/usr/libexec/platform-python # # License key checking tool. # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2024 All Rights Reserved # # see the output of "--help" for the valid options. import json import sys import gettext t = gettext.translation('rhn-client-tools', fallback=True) # Python 3 translations don't have a ugettext method if not hasattr(t, 'ugettext'): t.ugettext = t.gettext _ = t.ugettext from up2date_client import rhnreg from up2date_client import up2dateErrors from up2date_client import rhncli class ClnCheckCli(rhncli.RhnCli): def __init__(self): super().__init__() self.optparser.add_option("--serverUrl", action="store", help=_("Specify a url to use as a server")), self.optparser.add_option("--sslCACert", action="store", help=_("Specify a file to use as the ssl CA cert")), self.optparser.add_option("--activationkey", action="store", help=_("Specify an activation key")), def main(self): if self.options.serverUrl: rhnreg.cfg.set("serverURL", self.options.serverUrl) if self.options.sslCACert: rhnreg.cfg.set("sslCACert", self.options.sslCACert) if not self.options.activationkey: print(_("An activationkey is required " "to check a license.")) sys.exit(-1) rhnreg.getCaps() try: key_information = rhnreg.checkKey(self.options.activationkey) except up2dateErrors.CommunicationError as e: print("%s" % e.errmsg) sys.exit(1) else: print(json.dumps(key_information)) return 0 if __name__ == "__main__": cli = ClnCheckCli() cli.run()