コード例 #1
0
ファイル: api.py プロジェクト: agrimaldi/dataserv-client
    def config(self, set_wallet=None, set_payout_address=None):
        """
        Set and then show the config settings.

        :param set_wallet: Set the HWIF for registration/auth address.
        :param set_payout_address:  Set the payout address.
        :return: Configuation object.
        """
        config_updated = False

        # update payout address if requested
        if set_payout_address:
            self.cfg["payout_address"] = set_payout_address
            config_updated = True

        # update wallet if requested
        if set_wallet:
            self.cfg["wallet"] = set_wallet
            config_updated = True

        # save config if updated
        if config_updated:
            config.save(self.btctxstore, self.cfg_path, self.cfg)

        print(json.dumps(self.cfg, indent=2))  # should we output this?
        return self.cfg
コード例 #2
0
    def test_save_overwrites(self):
        path = tempfile.mktemp()

        # create config
        created_data = config.create(self.btctxstore, path)

        # update config
        updated_data = copy.deepcopy(created_data)
        updated_data["payout_address"] = "1A8WqiJDh3tGVeEefbMN5BVDYxx2XSoWgG"
        config.save(self.btctxstore, path, updated_data)

        # confirm overwriten
        loaded_data = config.get(self.btctxstore, path)
        self.assertEqual(updated_data, loaded_data)
        os.remove(path)
コード例 #3
0
    def test_save_overwrites(self):
        path = tempfile.mktemp()

        # create config
        created_data = config.create(self.btctxstore, path)

        # update config
        updated_data = copy.deepcopy(created_data)
        updated_data["payout_address"] = "1A8WqiJDh3tGVeEefbMN5BVDYxx2XSoWgG"
        config.save(self.btctxstore, path, updated_data)

        # confirm overwriten
        loaded_data = config.get(self.btctxstore, path)
        self.assertEqual(updated_data, loaded_data)
        os.remove(path)
コード例 #4
0
    def _initialize_config(self, set_master_secret, set_payout_address):
        if os.path.exists(self.config_path):
            self._load_config()
        else:  # initialize config
            if not set_master_secret:  # create random master secret
                secret_data = base64.b64encode(os.urandom(256))
                set_master_secret = secret_data.decode('utf-8')
            if not set_payout_address:  # use root address if not given
                set_payout_address = self._get_root_address(set_master_secret)

        if set_master_secret or set_payout_address:
            self.config = {
                "version": __version__,
                "master_secret": set_master_secret,
                "payout_address": set_payout_address,
            }
            config.save(self.config_path, self.config)
コード例 #5
0
    def config(self, set_wallet=None, set_payout_address=None):
        """Display saved config."""
        config_updated = False

        # update payout address if requested
        if set_payout_address:
            self.cfg["payout_address"] = set_payout_address
            config_updated = True
            # FIXME update dataserv here

        # update wallet if requested
        if set_wallet:
            self.cfg["wallet"] = set_wallet
            config_updated = True

        if config_updated:  # save config if updated
            config.save(self.btctxstore, self.cfg_path, self.cfg)

        print(json.dumps(self.cfg, indent=2))
        return self.cfg
コード例 #6
0
ファイル: test_config.py プロジェクト: F483/dataserv-client
 def test_roundtrip_unencrypted(self):
     path = tempfile.mktemp()
     input_data = {
         "version": version.__version__,
         "wallet": {
             "master_secret": "",
         },
         "payout_address": "1A8WqiJDh3tGVeEefbMN5BVDYxx2XSoWgG",
         "cold_storage": {
             "pub_hwifs": [],
             "addresses": [],
         },
         "storage_dirs": [
             {"path": "~/.storj/store", "capacity": 1024 * 1024 * 1024},
         ]
     }
     config.save(path, input_data)
     output_data = config.load(path)
     self.assertEqual(input_data, output_data)
     os.remove(path)
コード例 #7
0
ファイル: api.py プロジェクト: lockthenlock/dataserv-client
    def config(self, set_wallet=None, set_payout_address=None):
        """Display saved config."""
        config_updated = False

        # update payout address if requested
        if set_payout_address: 
            self.cfg["payout_address"] = set_payout_address
            config_updated = True
            # FIXME update dataserv here

        # update wallet if requested
        if set_wallet: 
            self.cfg["wallet"] = set_wallet
            config_updated = True

        if config_updated: # save config if updated
            config.save(self.btctxstore, self.cfg_path, self.cfg)

        print(json.dumps(self.cfg, indent=2))
        return self.cfg