Exemple #1
0
    def __init__(self, basedir=u"."):
        service.MultiService.__init__(self)
        self.basedir = abspath_expanduser_unicode(unicode(basedir))
        self.config_fname = os.path.join(self.basedir, "tahoe.cfg")
        self._portnumfile = os.path.join(self.basedir, self.PORTNUMFILE)
        fileutil.make_dirs(os.path.join(self.basedir, "private"), 0700)
        with open(os.path.join(self.basedir, "private", "README"), "w") as f:
            f.write(PRIV_README)

        # creates self.config
        self.read_config()
        nickname_utf8 = self.get_config("node", "nickname", "<unspecified>")
        self.nickname = nickname_utf8.decode("utf-8")
        assert type(self.nickname) is unicode

        self.init_tempdir()
        self.check_privacy()

        self.create_log_tub()
        self.logSource="Node"
        self.setup_logging()

        self.create_i2p_provider()
        self.create_tor_provider()
        self.init_connections()
        self.set_tub_options()
        self.create_main_tub()
        self.create_control_tub()

        self.log("Node constructed. " + get_package_versions_string())
        iputil.increase_rlimits()
Exemple #2
0
    def __init__(self, config, basedir=u"."):
        """
        Initialize the node with the given configuration. It's base directory
        is the current directory by default.
        """
        service.MultiService.__init__(self)
        # ideally, this would only be in _Config (or otherwise abstracted)
        self.basedir = abspath_expanduser_unicode(unicode(basedir))
        # XXX don't write files in ctor!
        fileutil.make_dirs(os.path.join(self.basedir, "private"), 0700)
        with open(os.path.join(self.basedir, "private", "README"), "w") as f:
            f.write(PRIV_README)

        self.config = config
        self.get_config = config.get_config # XXX stopgap
        self.nickname = config.nickname # XXX stopgap

        self.init_tempdir()
        self.check_privacy()

        self.create_log_tub()
        self.logSource = "Node"
        self.setup_logging()

        self.create_i2p_provider()
        self.create_tor_provider()
        self.init_connections()
        self.set_tub_options()
        self.create_main_tub()
        self.create_control_tub()

        self.log("Node constructed. " + get_package_versions_string())
        iputil.increase_rlimits()
Exemple #3
0
    def __init__(self, basedir=u"."):
        service.MultiService.__init__(self)
        self.basedir = abspath_expanduser_unicode(unicode(basedir))
        self.config_fname = os.path.join(self.basedir, "tahoe.cfg")
        self._portnumfile = os.path.join(self.basedir, self.PORTNUMFILE)
        fileutil.make_dirs(os.path.join(self.basedir, "private"), 0700)
        with open(os.path.join(self.basedir, "private", "README"), "w") as f:
            f.write(PRIV_README)

        # creates self.config
        self.read_config()
        nickname_utf8 = self.get_config("node", "nickname", "<unspecified>")
        self.nickname = nickname_utf8.decode("utf-8")
        assert type(self.nickname) is unicode

        self.init_tempdir()
        self.check_privacy()

        self.create_log_tub()
        self.logSource = "Node"
        self.setup_logging()

        self.create_i2p_provider()
        self.create_tor_provider()
        self.init_connections()
        self.set_tub_options()
        self.create_main_tub()
        self.create_control_tub()

        self.log("Node constructed. " + get_package_versions_string())
        iputil.increase_rlimits()
Exemple #4
0
    def __init__(self, config, basedir=u"."):
        """
        Initialize the node with the given configuration. It's base directory
        is the current directory by default.
        """
        service.MultiService.__init__(self)
        # ideally, this would only be in _Config (or otherwise abstracted)
        self.basedir = abspath_expanduser_unicode(unicode(basedir))
        # XXX don't write files in ctor!
        fileutil.make_dirs(os.path.join(self.basedir, "private"), 0700)
        with open(os.path.join(self.basedir, "private", "README"), "w") as f:
            f.write(PRIV_README)

        self.config = config
        self.get_config = config.get_config  # XXX stopgap
        self.nickname = config.nickname  # XXX stopgap

        self.init_tempdir()
        self.check_privacy()

        self.create_log_tub()
        self.logSource = "Node"
        self.setup_logging()

        self.create_i2p_provider()
        self.create_tor_provider()
        self.init_connections()
        self.set_tub_options()
        self.create_main_tub()
        self.create_control_tub()

        self.log("Node constructed. " + get_package_versions_string())
        iputil.increase_rlimits()
Exemple #5
0
 def test_versions(self):
     basedir = "test_client.Basic.test_versions"
     os.mkdir(basedir)
     fileutil.write(os.path.join(basedir, "tahoe.cfg"), BASECONFIG + "[storage]\n" + "enabled = true\n")
     c = client.Client(basedir)
     ss = c.getServiceNamed("storage")
     verdict = ss.remote_get_version()
     self.failUnlessReallyEqual(verdict["application-version"], str(allmydata.__full_version__))
     self.failIfEqual(str(allmydata.__version__), "unknown")
     self.failUnless("." in str(allmydata.__full_version__), "non-numeric version in '%s'" % allmydata.__version__)
     all_versions = allmydata.get_package_versions_string()
     self.failUnless(allmydata.__appname__ in all_versions)
     # also test stats
     stats = c.get_stats()
     self.failUnless("node.uptime" in stats)
     self.failUnless(isinstance(stats["node.uptime"], float))
Exemple #6
0
 def test_versions(self):
     basedir = "test_client.Basic.test_versions"
     os.mkdir(basedir)
     open(os.path.join(basedir, "introducer.furl"), "w").write("")
     c = client.Client(basedir)
     ss = c.getServiceNamed("storage")
     verdict = ss.remote_get_version()
     self.failUnlessReallyEqual(verdict["application-version"],
                                str(allmydata.__full_version__))
     self.failIfEqual(str(allmydata.__version__), "unknown")
     self.failUnless("." in str(allmydata.__full_version__),
                     "non-numeric version in '%s'" % allmydata.__version__)
     all_versions = allmydata.get_package_versions_string()
     self.failUnless(allmydata.__appname__ in all_versions)
     log.msg("tahoe versions: %s" % all_versions)
     # also test stats
     stats = c.get_stats()
     self.failUnless("node.uptime" in stats)
     self.failUnless(isinstance(stats["node.uptime"], float))
Exemple #7
0
 def test_versions(self):
     basedir = "test_client.Basic.test_versions"
     os.mkdir(basedir)
     open(os.path.join(basedir, "introducer.furl"), "w").write("")
     c = client.Client(basedir)
     ss = c.getServiceNamed("storage")
     verdict = ss.remote_get_version()
     self.failUnlessReallyEqual(verdict["application-version"],
                                str(allmydata.__full_version__))
     self.failIfEqual(str(allmydata.__version__), "unknown")
     self.failUnless("." in str(allmydata.__full_version__),
                     "non-numeric version in '%s'" % allmydata.__version__)
     all_versions = allmydata.get_package_versions_string()
     self.failUnless(allmydata.__appname__ in all_versions)
     log.msg("tahoe versions: %s" % all_versions)
     # also test stats
     stats = c.get_stats()
     self.failUnless("node.uptime" in stats)
     self.failUnless(isinstance(stats["node.uptime"], float))
Exemple #8
0
    def __init__(self, basedir=u"."):
        service.MultiService.__init__(self)
        self.basedir = abspath_expanduser_unicode(unicode(basedir))
        self._portnumfile = os.path.join(self.basedir, self.PORTNUMFILE)
        self._tub_ready_observerlist = observer.OneShotObserverList()
        fileutil.make_dirs(os.path.join(self.basedir, "private"), 0700)
        open(os.path.join(self.basedir, "private", "README"), "w").write(PRIV_README)

        # creates self.config
        self.read_config()
        nickname_utf8 = self.get_config("node", "nickname", "<unspecified>")
        self.nickname = nickname_utf8.decode("utf-8")
        assert type(self.nickname) is unicode

        self.init_tempdir()
        self.create_tub()
        self.logSource="Node"

        self.setup_logging()
        self.log("Node constructed. " + get_package_versions_string())
        iputil.increase_rlimits()
Exemple #9
0
 def test_versions(self):
     basedir = "test_client.Basic.test_versions"
     os.mkdir(basedir)
     fileutil.write(os.path.join(basedir, "tahoe.cfg"), \
                        BASECONFIG + \
                        "[storage]\n" + \
                        "enabled = true\n")
     c = client.Client(basedir)
     ss = c.getServiceNamed("storage")
     verdict = ss.remote_get_version()
     self.failUnlessReallyEqual(verdict["application-version"],
                                str(allmydata.__full_version__))
     self.failIfEqual(str(allmydata.__version__), "unknown")
     self.failUnless("." in str(allmydata.__full_version__),
                     "non-numeric version in '%s'" % allmydata.__version__)
     all_versions = allmydata.get_package_versions_string()
     self.failUnless(allmydata.__appname__ in all_versions)
     # also test stats
     stats = c.get_stats()
     self.failUnless("node.uptime" in stats)
     self.failUnless(isinstance(stats["node.uptime"], float))
Exemple #10
0
    def __init__(self, basedir=u"."):
        service.MultiService.__init__(self)
        self.basedir = abspath_expanduser_unicode(unicode(basedir))
        self._portnumfile = os.path.join(self.basedir, self.PORTNUMFILE)
        self._tub_ready_observerlist = observer.OneShotObserverList()
        fileutil.make_dirs(os.path.join(self.basedir, "private"), 0700)
        open(os.path.join(self.basedir, "private", "README"), "w").write(PRIV_README)

        # creates self.config
        self.read_config()
        nickname_utf8 = self.get_config("node", "nickname", "<unspecified>")
        self.nickname = nickname_utf8.decode("utf-8")
        assert type(self.nickname) is unicode

        self.init_tempdir()
        self.create_tub()
        self.logSource="Node"

        self.setup_ssh()
        self.setup_logging()
        self.log("Node constructed. " + get_package_versions_string())
        iputil.increase_rlimits()
Exemple #11
0
    def __init__(self, config, main_tub, control_tub, i2p_provider, tor_provider):
        """
        Initialize the node with the given configuration. Its base directory
        is the current directory by default.
        """
        service.MultiService.__init__(self)

        self.config = config
        self.get_config = config.get_config # XXX stopgap
        self.nickname = config.nickname # XXX stopgap

        # this can go away once Client.init_client_storage_broker is moved into create_client()
        # (tests sometimes have None here)
        self._i2p_provider = i2p_provider
        self._tor_provider = tor_provider

        self.init_tempdir()

        self.create_log_tub()
        self.logSource = "Node"
        self.setup_logging()

        self.tub = main_tub
        if self.tub is not None:
            self.nodeid = b32decode(self.tub.tubID.upper())  # binary format
            self.short_nodeid = b32encode(self.nodeid).lower()[:8]  # for printing
            self.config.write_config_file("my_nodeid", b32encode(self.nodeid).lower() + "\n")
            self.tub.setServiceParent(self)
        else:
            self.nodeid = self.short_nodeid = None

        self.control_tub = control_tub
        if self.control_tub is not None:
            self.control_tub.setServiceParent(self)

        self.log("Node constructed. " + get_package_versions_string())
        iputil.increase_rlimits()
Exemple #12
0
 def opt_version_and_path(self):
     import allmydata
     print >> self.stdout, allmydata.get_package_versions_string(
         show_paths=True, debug=True)
     self.no_command_needed = True
Exemple #13
0
    def opt_version_and_path(self):
        import allmydata

        print >>self.stdout, allmydata.get_package_versions_string(show_paths=True, debug=True)
        self.no_command_needed = True
Exemple #14
0
    def opt_version(self):
        import allmydata

        print >>self.stdout, allmydata.get_package_versions_string()
        sys.exit(0)
Exemple #15
0
 def data_version(self, ctx, data):
     return get_package_versions_string()
Exemple #16
0
 def data_version(self, ctx, data):
     return get_package_versions_string()
Exemple #17
0
    def opt_version_and_path(self):
        import allmydata

        print >>self.stdout, allmydata.get_package_versions_string(show_paths=True)
        sys.exit(0)
Exemple #18
0
 def opt_version(self):
     import allmydata
     print(allmydata.get_package_versions_string(debug=True), file=self.stdout)
     self.no_command_needed = True