Opened 3 months ago

Closed 2 months ago

#27350 closed defect (fixed)

Nyx -d ignores supplied file name

Reported by: traumschule Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Nyx Version:
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Thanks for this nice tool!

Running nyx from git without arguments destroys the interface with stem debug messages. One needs to

$ ./run_nyx 2>nyx.log

The offered -d option seems to fail reliably:

$ ./run_nyx -d nyx.log
Traceback (most recent call last):
  File "./run_nyx", line 14, in <module>
    nyx.main()
  File "nyx/nyx/__init__.py", line 176, in main
    nyx.starter.main()
  File "/usr/lib/python2.7/dist-packages/stem/util/conf.py", line 289, in wrapped
    return func(*args, config = config, **kwargs)
  File "nyx/nyx/starter.py", line 67, in main
    _setup_debug_logging(args)
  File "nyx/nyx/starter.py", line 135, in _setup_debug_logging
    os.makedirs(debug_dir)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 2] No such file or directory: ''

The packaged version says

$ nyx -d nyx.log
Unable to write to our debug log file (nyx.log): No such file or directory

$ nyx --version
nyx version 2.0.4 (released November 5, 2017)

Child Tickets

Change History (9)

comment:1 Changed 3 months ago by atagar

Ick! Great catch, thanks traumschule. At work at the moment but simple one to fix. :P

comment:2 Changed 3 months ago by traumschule

Status: newneeds_review

I got around the empty path error but stems output still appears on the screen. Do you have an ad hoc direction to fix it?
https://github.com/traumschule/nyx

comment:3 Changed 3 months ago by atagar

Thanks traumschule. That isn't quite the fix I'll be going with but close.

In Python you should almost never use the 'is' keyword since it does object address comparisons. Under the covers Python does aggressive object caching so 99% of the time it will seem to work, but occasionally it won't. Often when you least expect it.

The only exception is None comparison. In that case ("if x is None") the 'is' keyword is suggested.

In python None, empty strings, and empty list trustiness resolve to 'False' so the proper fix here is...

if debug_dir and not os.path.exists(debug_dir): 

Sorry about the long explanation. Just seemed a good educational opportunity. ;P

stems output still appears on the screen

Sorry, I didn't understand this bit. Your fix corrected the stacktrace but you got another error?

Last edited 3 months ago by atagar (previous) (diff)

comment:4 Changed 3 months ago by traumschule

appreciate it! i had debug_dir == '' before I looked at the code around it, the wrong strategy in this case.

Running nyx from git without arguments destroys the interface with stem debug messages. One needs to
$ ./run_nyx 2>nyx.log

what do you see when you run ./run_nyx? in my case stems debug output fills the screen mixed with the ncurses interface. if you don't have i need to figure out, what happens here.

comment:5 Changed 3 months ago by atagar

Hi traumschule, fix pushed. When I run './run_nyx -d nyx.log' I see the following message on stdout, then the curses front page...

./run_nyx -d nyx.log
Saving a debug log to nyx.log, please check it for sensitive information before sharing it.

This is with the git master copy of nyx and stem. What are you seeing? Dumb question, but per chance did you modify your copy of stem (for instance by adding print statements)?

comment:6 Changed 3 months ago by traumschule

I did not make any changes to stem, but maybe you know this output and have a guess what's going on:

$ ./run_nyx -d nyx.log
TRACE:stem:Nyx 2.0.4-dev Debug Dump                                                                                                                                             
Stem Version: 1.6.0
Python Version: 2.7.15
Platform: Linux (debian buster/sid )
--------------------------------------------------------------------------------
Nyx Configuration (/home/user/.nyx/config):
[file doesn't exist]
--------------------------------------------------------------------------------
Saving a debug log to nyx.log, please check it for sensitive information before sharing it.
NOTICE:stem:No nyxrc loaded, using defaults. You can customize nyx by placing a configuration file at /home/user/.nyx/config (see https://nyx.torproject.org/nyxrc.sample
for its options).
TRACE:stem:config entry 'tor_chroot' not found, defaulting to ''
TRACE:stem:Sent to tor: PROTOCOLINFO 1
TRACE:stem:Received from tor:
250-PROTOCOLINFO 1
250-AUTH METHODS=COOKIE,SAFECOOKIE COOKIEFILE="/var/run/tor/control.authcookie"
250-VERSION Tor="0.3.4.7-rc"
250 OK
...

comment:7 Changed 3 months ago by atagar

Huh. Odd. That is Nyx's debug output. That is to say, the stuff that should be going into nyx.log.

What does nyx.log contain? I'm guessing it's either empty or a copy of that. In either case I'm puzzled why that's going to stdout rather than the file. :/

comment:8 Changed 3 months ago by traumschule

This only happens with ./run_nyx from git and not /usr/bin/nyx installed by apt.

What does nyx.log contain?

The same.

I'm guessing it's either empty or a copy
of that.

In either case I'm puzzled why that's going to stdout rather
than the file. :/

You are not alone :)

BTW: I got a mail from "Tor Bug Tracker & Wiki" <blackhole@…> with your answer to this ticket and answered to the given Reply-To address tor-assistants@… and got back:

Tor-assistants@ is no longer available. For contact information please see...
https://www.torproject.org/about/contact.html.en

comment:9 Changed 2 months ago by traumschule

Resolution: fixed
Status: needs_reviewclosed

the original issues is fixed, opened #27517 for debug output issue

Note: See TracTickets for help on using tickets.