[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] Merge branch 'ticket-40002-plus-squashed'



commit f05a15fa61664756925cd6dd74a0a26914598b78
Merge: 99bd06c 67f83d7
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Sat Jul 18 11:41:17 2020 -0400

    Merge branch 'ticket-40002-plus-squashed'

 .travis.yml               |  33 ++--------
 README                    |   2 +-
 chutney                   |  20 +++++-
 lib/chutney/Templating.py |  18 +++---
 lib/chutney/TorNet.py     | 151 ++++++++++++++++++++++------------------------
 5 files changed, 104 insertions(+), 120 deletions(-)

diff --cc lib/chutney/TorNet.py
index 37bef04,123fc50..2d219ac
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@@ -1260,56 -1254,14 +1256,56 @@@ class LocalNodeController(NodeControlle
      SHORT_FILE_CODE = -100
      NO_PROGRESS_CODE = 0
      SUCCESS_CODE = 100
 +    ONIONDESC_PUBLISHED_CODE = 200
 +    HSV2_KEYWORD = "hidden service v2"
 +    HSV3_KEYWORD = "hidden service v3"
  
 -    def getLastBootstrapStatus(self):
 -        """Look through the logs and return the last bootstrap message
 -           received as a 3-tuple of percentage complete, keyword
 -           (optional), and message.
 +    def updateLastOnionServiceDescStatus(self):
 +        """Look through the logs and cache the last onion service
 +           descriptor status received.
 +        """
 +        logfname = self.getLogfile(info=True)
 +        if not os.path.exists(logfname):
 +            return (LocalNodeController.MISSING_FILE_CODE,
 +                    "no_logfile", "There is no logfile yet.")
 +        percent = LocalNodeController.NO_RECORDS_CODE
 +        keyword = "no_message"
 +        message = "No onion service descriptor messages yet."
 +        with open(logfname, 'r') as f:
 +            for line in f:
 +                m_v2 = re.search(r'Launching upload for hidden service (.*)',
 +                                 line)
 +                if m_v2:
 +                    percent = LocalNodeController.ONIONDESC_PUBLISHED_CODE
 +                    keyword = LocalNodeController.HSV2_KEYWORD
 +                    message = m_v2.groups()[0]
 +                    break
 +                # else check for HSv3
 +                m_v3 = re.search(r'Service ([^\s]+ [^\s]+ descriptor of revision .*)',
 +                                 line)
 +                if m_v3:
 +                    percent = LocalNodeController.ONIONDESC_PUBLISHED_CODE
 +                    keyword = LocalNodeController.HSV3_KEYWORD
 +                    message = m_v3.groups()[0]
 +                    break
 +        self.most_recent_oniondesc_status = (percent, keyword, message)
 +
 +    def getLastOnionServiceDescStatus(self):
 +        """Return the last onion descriptor message fetched by
 +           updateLastOnionServiceDescStatus as a 3-tuple of percentage
 +           complete, the hidden service version, and message.
 +
 +           The return status depends on the last time updateLastStatus()
 +           was called; that function must be called before this one.
 +        """
 +        return self.most_recent_oniondesc_status
 +
 +    def updateLastBootstrapStatus(self):
 +        """Look through the logs and cache the last bootstrap message
 +           received.
          """
          logfname = self.getLogfile()
-         if not os.path.exists(logfname):
+         if not logfname.exists():
              return (LocalNodeController.MISSING_FILE_CODE,
                      "no_logfile", "There is no logfile yet.")
          percent = LocalNodeController.NO_RECORDS_CODE

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits