[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [chutney/master] TorNet: Add status code constants
commit d62288806414b45c584f5d8fd4b8b29e3dcae618
Author: teor <teor@xxxxxxxxxxxxxx>
Date: Mon Mar 9 15:57:39 2020 +1000
TorNet: Add status code constants
And update some old code to use them.
Part of 33379.
---
lib/chutney/TorNet.py | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index d5b90a6..415b284 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -1037,6 +1037,14 @@ class LocalNodeController(NodeController):
logname = "notice.log"
return os.path.join(datadir, logname)
+ INTERNAL_ERROR_CODE = -400
+ NOT_YET_IMPLEMENTED_CODE = -300
+ MISSING_FILE_CODE = -200
+ NO_RECORDS_CODE = -100
+ INCOMPLETE_RECORDS_CODE = -50
+ NO_PROGRESS_CODE = 0
+ SUCCESS_CODE = 100
+
def getLastBootstrapStatus(self):
"""Look through the logs and return the last bootstrap message
received as a 3-tuple of percentage complete, keyword
@@ -1044,8 +1052,11 @@ class LocalNodeController(NodeController):
"""
logfname = self.getLogfile()
if not os.path.exists(logfname):
- return (-200, "no_logfile", "There is no logfile yet.")
- percent,keyword,message=-100,"no_message","No bootstrap messages yet."
+ return (LocalNodeController.MISSING_FILE_CODE,
+ "no_logfile", "There is no logfile yet.")
+ percent = LocalNodeController.NO_RECORDS_CODE
+ keyword = "no_message"
+ message = "No bootstrap messages yet."
with open(logfname, 'r') as f:
for line in f:
m = re.search(r'Bootstrapped (\d+)%(?: \(([^\)]*)\))?: (.*)',
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits