コード例 #1
0
 def test_reject_default_in_yaml(self):
     connections = {'introducers': {
         u'default': { 'furl': 'furl1' },
         }}
     self.yaml_path.setContent(yamlutil.safe_dump(connections))
     e = self.assertRaises(ValueError, create_client, self.basedir)
     self.assertEquals(str(e), "'default' introducer furl cannot be specified in introducers.yaml; please fix impossible configuration.")
コード例 #2
0
    def test_reject_default_in_yaml(self):
        """
        If an introducer is configured in tahoe.cfg with the deprecated
        [client]introducer.furl then a "default" introducer in
        introducers.yaml is rejected.
        """
        connections = {
            'introducers': {
                u'default': {
                    'furl': 'furl1'
                },
            },
        }
        self.yaml_path.setContent(
            ensure_binary(yamlutil.safe_dump(connections)))
        FilePath(self.basedir).child("tahoe.cfg").setContent(
            b"[client]\n"
            b"introducer.furl = furl1\n")

        with self.assertRaises(ValueError) as ctx:
            yield create_client(self.basedir)

        self.assertEquals(
            str(ctx.exception),
            "'default' introducer furl cannot be specified in tahoe.cfg and introducers.yaml; "
            "please fix impossible configuration.",
        )
コード例 #3
0
 def test_ok(self):
     connections = {'introducers': {
         u'one': { 'furl': 'furl1' },
         }}
     self.yaml_path.setContent(yamlutil.safe_dump(connections))
     myclient = create_client(self.basedir)
     tahoe_cfg_furl = myclient.introducer_furls[0]
     self.assertEquals(tahoe_cfg_furl, 'furl1')
コード例 #4
0
def save_magic_folders(node_directory, folders):
    fileutil.write_atomically(
        os.path.join(node_directory, u"private", u"magic_folders.yaml"),
        yamlutil.safe_dump({u"magic-folders": folders}),
    )

    config = configutil.get_config(os.path.join(node_directory, u"tahoe.cfg"))
    configutil.set_config(config, "magic_folder", "enabled", "True")
    configutil.write_config(os.path.join(node_directory, u"tahoe.cfg"), config)
コード例 #5
0
ファイル: client.py プロジェクト: gvsurenderreddy/tahoe-lafs
 def _save_announcements(self):
     announcements = []
     for _, value in self._inbound_announcements.items():
         ann, key_s, time_stamp = value
         server_params = {
             "ann" : ann,
             "key_s" : key_s,
             }
         announcements.append(server_params)
     announcement_cache_yaml = yamlutil.safe_dump(announcements)
     self._cache_filepath.setContent(announcement_cache_yaml)
コード例 #6
0
ファイル: client.py プロジェクト: vrusinov/tahoe-lafs
 def _save_announcements(self):
     announcements = []
     for _, value in self._inbound_announcements.items():
         ann, key_s, time_stamp = value
         server_params = {
             "ann" : ann,
             "key_s" : key_s,
             }
         announcements.append(server_params)
     announcement_cache_yaml = yamlutil.safe_dump(announcements)
     self._cache_filepath.setContent(announcement_cache_yaml)
コード例 #7
0
ファイル: client.py プロジェクト: teotikalki/tahoe-lafs
 def load_connections(self):
     """
     Load the connections.yaml file if it exists, otherwise
     create a default configuration.
     """
     fn = os.path.join(self.basedir, "private", "connections.yaml")
     connections_filepath = FilePath(fn)
     try:
         with connections_filepath.open() as f:
             self.connections_config = yamlutil.safe_load(f)
     except EnvironmentError:
         self.connections_config = { 'servers' : {} }
         content = yamlutil.safe_dump(self.connections_config)
         connections_filepath.setContent(content)
コード例 #8
0
ファイル: client.py プロジェクト: bhyvex/tahoe-lafs
 def load_connections(self):
     """
     Load the connections.yaml file if it exists, otherwise
     create a default configuration.
     """
     fn = os.path.join(self.basedir, "private", "connections.yaml")
     connections_filepath = FilePath(fn)
     try:
         with connections_filepath.open() as f:
             self.connections_config = yamlutil.safe_load(f)
     except EnvironmentError:
         self.connections_config = { 'servers' : {} }
         content = yamlutil.safe_dump(self.connections_config)
         connections_filepath.setContent(content)
コード例 #9
0
 def _save_announcements(self):
     announcements = []
     for _, value in self._inbound_announcements.items():
         ann, key_s, time_stamp = value
         # On Python 2, bytes strings are encoded into YAML Unicode strings.
         # On Python 3, bytes are encoded as YAML bytes. To minimize
         # changes, Python 3 for now ensures the same is true.
         server_params = {
             "ann": ann,
             "key_s": ensure_text(key_s),
         }
         announcements.append(server_params)
     announcement_cache_yaml = yamlutil.safe_dump(announcements)
     if isinstance(announcement_cache_yaml, unicode):
         announcement_cache_yaml = announcement_cache_yaml.encode("utf-8")
     self._cache_filepath.setContent(announcement_cache_yaml)
コード例 #10
0
    def test_introducer_count(self):
        """ Ensure that the Client creates same number of introducer clients
        as found in "basedir/private/introducers" config file. """
        connections = {'introducers':
            {
            u'intro1':{ 'furl': 'furl1' },
            u'intro2':{ 'furl': 'furl4' }
        },
        }
        self.yaml_path.setContent(yamlutil.safe_dump(connections))
        # get a client and count of introducer_clients
        myclient = create_client(self.basedir)
        ic_count = len(myclient.introducer_clients)

        # assertions
        self.failUnlessEqual(ic_count, 3)
コード例 #11
0
    def test_introducer_count(self):
        """
        If there are two introducers configured in ``introducers.yaml`` then
        ``Client`` creates two introducer clients.
        """
        connections = {
            'introducers': {
                u'intro1': {
                    'furl': 'furl1'
                },
                u'intro2': {
                    'furl': 'furl4'
                },
            },
        }
        self.yaml_path.setContent(yamlutil.safe_dump(connections))
        # get a client and count of introducer_clients
        myclient = yield create_client(self.basedir)
        ic_count = len(myclient.introducer_clients)

        # assertions
        self.failUnlessEqual(ic_count, len(connections["introducers"]))
コード例 #12
0
 def test_introducerless(self):
     connections = {'introducers': {} }
     self.yaml_path.setContent(yamlutil.safe_dump(connections))
     myclient = create_client(self.basedir)
     self.assertEquals(len(myclient.introducer_furls), 0)