[tor-commits] [nyx/master] Suppress errors if os.putenv doesn't work

atagar at torproject.org atagar at torproject.org
Mon Oct 30 20:58:26 UTC 2017


commit bcb01229bef28ac087f9db0ea96bfe3f47875df0
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Oct 30 13:44:10 2017 -0700

    Suppress errors if os.putenv doesn't work
    
    These are to sidestep issues on some platforms. Generally certainly fine if
    they don't take effect. Caught thanks to tor-relays@ beta tester on FreeBSD...
    
      nyx: environment corrupt; missing value for
      Traceback (most recent call last):
        File "./run_nyx", line 14, in <module>
          nyx.main()
        File "/usr/home/ryan/nyx/nyx/__init__.py", line 147, in main
          nyx.starter.main()
        File "/usr/home/ryan/nyx/stem/util/conf.py", line 289, in wrapped
          return func(*args, config = config, **kwargs)
        File "/usr/home/ryan/nyx/nyx/starter.py", line 90, in main
          os.putenv('LANG', 'C')  # make subcommands (ps, netstat, etc) provide
      english results
      OSError: [Errno 14] Bad address
---
 nyx/starter.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/nyx/starter.py b/nyx/starter.py
index 789e67c..6f90bfd 100644
--- a/nyx/starter.py
+++ b/nyx/starter.py
@@ -87,8 +87,15 @@ def main(config):
   _use_unicode()
   _set_process_name()
 
-  os.putenv('LANG', 'C')  # make subcommands (ps, netstat, etc) provide english results
-  os.putenv('ESCDELAY', '0')  # make 'esc' take effect right away
+  try:
+    os.putenv('LANG', 'C')  # make subcommands (ps, netstat, etc) provide english results
+  except:
+    pass
+
+  try:
+    os.putenv('ESCDELAY', '0')  # make 'esc' take effect right away
+  except:
+    pass
 
   try:
     nyx.curses.start(nyx.draw_loop, acs_support = config.get('acs_support', True), transparent_background = True, cursor = False)





More information about the tor-commits mailing list