Ejemplo n.º 1
0
 def _read_config(self, filename, passphrase):
     if os.path.exists(filename):
         confstr = crypto.read_file(filename, passphrase)
         return config.ConfigBuilder().build_config(confstr)
     else:
         print _("Creating new config file: %s" % filename)
         return config.Config()
Ejemplo n.º 2
0
 def _do_command(self):
     """
     Executes the command.
     """
     try:
         content = crypto.read_file(self.options.config, self.passphrase)
     except crypto.DecryptionException:
         print self.parser.error(_("Error decrypting configuration file"))
     print(json.dumps(json.loads(content), sort_keys=True, indent=4))
Ejemplo n.º 3
0
 def _do_command(self):
     """
     Executes the command.
     """
     try:
         content = crypto.read_file(self.options.config, self.passphrase)
     except crypto.DecryptionException:
         print self.parser.error(_("Error decrypting configuration file"))
     print(json.dumps(json.loads(content), sort_keys = True, indent = 4))
Ejemplo n.º 4
0
    def _read_config(self, filename, password):
        """
        Read config file and decrypt with the given password.

        Note that password here is the password provided by the user, not the
        actual salted AES key.
        """
        if os.path.exists(filename):
            try:
                confstr = crypto.read_file(filename, password)
            except crypto.DecryptionException:
                print self.parser.error(_("Error decrypting configuration file"))

            try:
                return config.ConfigBuilder().build_config(confstr)
            except config.BadJsonException:
                print self.parser.error(_("Cannot parse configuration, check encryption password"))

        else:
            print _("Creating new config file: %s" % filename)
            return config.Config()
Ejemplo n.º 5
0
    def _read_config(self, filename, password):
        """
        Read config file and decrypt with the given password.

        Note that password here is the password provided by the user, not the
        actual salted AES key.
        """
        if os.path.exists(filename):
            try:
                confstr = crypto.read_file(filename, password)
            except crypto.DecryptionException:
                print self.parser.error(
                    _("Error decrypting configuration file"))

            try:
                return config.ConfigBuilder().build_config(confstr)
            except config.BadJsonException:
                print self.parser.error(
                    _("Cannot parse configuration, check encryption password"))

        else:
            print _("Creating new config file: %s" % filename)
            return config.Config()
Ejemplo n.º 6
0
Archivo: dump.py Proyecto: wzzrd/rho
#!/usr/bin/python

import sys
from rho import crypto

content = crypto.read_file('rho.conf', sys.argv[1])
print(content)
Ejemplo n.º 7
0
 def _do_command(self):
     """
     Executes the command.
     """
     content = crypto.read_file(self.options.config, self.passphrase)
     print (json.dumps(json.loads(content), sort_keys=True, indent=4))