Ejemplo n.º 1
0
    def status(self):

        self.node.lock.acquire()
        port = self.node.address[1]
        n_peers = len(self.node.peers)
        n_bytes = self.node.network_usage
        self.node.lock.release()

        self.file_server.lock.acquire()
        n_files = len(self.file_server.paths)
        self.file_server.lock.release()

        status = _("Circle daemon running on port %d:\n") % port
        if self.config.get("public_dir"):
            status += _("  Public directory: ") + self.config["public_dir"] + "\n"
        else:
            status += _("  No public directory\n")
        if self.config.get("publish_apt"):
            status += _("  Apt cache published if available\n")
        else:
            status += _("  Apt cache not published\n")
        status += (
            _("  %d files published (this may take a while to update)\n") % n_files
            + _("  Connected to %d peers, ") % n_peers
            + _("hashtable is %s\n")
            % (("inactive", "active (%d links)" % len(self.node.links))[self.node.hashtable_running])
            + _("  Total network usage %s\n") % utility.human_size(n_bytes)
        )

        if self.http_running:
            # import circle_http
            status = status + circle_http.status()
        return status
Ejemplo n.º 2
0
 def set_http(self):
     # import circle_http
     str = circle_http.status()
     if self.config.get("http") == 0:
         if self.http_running:
             str = circle_http.stop()
         return str
     elif self.config.get("http") == 2:
         if not self.http_running:
             str = circle_http.start("local", self)
         return str
     elif self.config.get("http") == 1:
         if not self.http_running:
             str = circle_http.start("remote", self)
         return str