[Pkg-privacy-commits] [obfsproxy] 179/353: Emit CLI argument parsing errors to stdout (instead of stderr).
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository obfsproxy.
commit 2551b93a3a62e1cea1262cc7b59af3df53f4da95
Author: George Kadianakis <desnacked at riseup.net>
Date: Tue Aug 6 22:51:03 2013 +0300
Emit CLI argument parsing errors to stdout (instead of stderr).
Tor will log any lines received on stdout by a pluggable
transport. This might help debug situations where the user had a wrong
ClientTransportPlugin torrc line.
---
obfsproxy/common/argparser.py | 12 ++++++++++++
obfsproxy/pyobfsproxy.py | 6 +++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/obfsproxy/common/argparser.py b/obfsproxy/common/argparser.py
new file mode 100644
index 0000000..3377597
--- /dev/null
+++ b/obfsproxy/common/argparser.py
@@ -0,0 +1,12 @@
+import argparse
+import sys
+
+"""
+Overrides argparse.ArgumentParser so that it emits error messages to
+stdout instead of stderr.
+"""
+class MyArgumentParser(argparse.ArgumentParser):
+ def _print_message(self, message, fd=None):
+ if message:
+ fd = sys.stdout
+ fd.write(message)
diff --git a/obfsproxy/pyobfsproxy.py b/obfsproxy/pyobfsproxy.py
index 31ea395..374f665 100755
--- a/obfsproxy/pyobfsproxy.py
+++ b/obfsproxy/pyobfsproxy.py
@@ -8,11 +8,11 @@ Currently, not all of the obfsproxy command line options have been implemented.
"""
import sys
-import argparse
import obfsproxy.network.launch_transport as launch_transport
import obfsproxy.transports.transports as transports
import obfsproxy.common.log as logging
+import obfsproxy.common.argparser as argparser
import obfsproxy.common.heartbeat as heartbeat
import obfsproxy.managed.server as managed_server
import obfsproxy.managed.client as managed_client
@@ -29,8 +29,8 @@ def set_up_cli_parsing():
query individual transports to register their own external-mode
arguments."""
- parser = argparse.ArgumentParser(
- description='Obfsproxy: A pluggable transports proxy written in Python')
+ parser = argparser.MyArgumentParser(
+ description='py-obfsproxy: A pluggable transports proxy written in Python')
subparsers = parser.add_subparsers(title='supported transports', dest='name')
parser.add_argument('-v', '--version', action='version', version=__version__)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfsproxy.git
More information about the Pkg-privacy-commits
mailing list