-1
ValueError: invalid \x escape:
  File "SConstruct", line 49:
    execfile("hosts.cfg")

I'm completely stumped with this one guys...

If I print right before line 49, I can see the output. On the very first line of "hosts.cfg" I put a second print statement which is never executed.

fIwJlxSzApHEZIl
  • 11,861
  • 6
  • 62
  • 71
  • 5
    And what's in hosts.cfg? – Jon Skeet May 11 '12 at 23:11
  • 1
    What happens when you run it like `python hosts.cfg`? – Kirk Strauser May 11 '12 at 23:12
  • IOError: [Errno 2] No such file or directory: 'python hosts.py': – fIwJlxSzApHEZIl May 11 '12 at 23:13
  • 1
    Where'd `hosts.py` come from? I thought we were talking about `hosts.cfg`. – Kirk Strauser May 11 '12 at 23:18
  • We were. I renamed it hosts.py to see if that helped, which it didn't. – fIwJlxSzApHEZIl May 11 '12 at 23:18
  • 1
    No, I mean actually run it from the command line. Forget the `SConstruct` file: actually run "python hosts.py" directly to see what happens. – Kirk Strauser May 11 '12 at 23:20
  • Oh that's a great idea I didn't think of Kirk. I nailed down the issue in my answer below, I was so caught up in thinking that the line that Python was talking about, 49, was the one causing the error. Didn't think it could be the hosts.cfg file contents. I think I've learned a good lesson. – fIwJlxSzApHEZIl May 11 '12 at 23:22
  • Python should have printed a "stack backtrace" showing all the functions being called. It probably died inside a function like `json.loads()` which was probably called from a function like `evaluate_config_file()` or something like that. If you study the backtrace it will often steer you right toward the problem. If you study it and still can't find the problem, you might want to paste a copy of the backtrace in to your question for others to study. – steveha May 12 '12 at 00:03

2 Answers2

3

Even on Windows, forward slashes should work for directory names, so you could standardize on those:

"libpath" : [".", "../xlib", "../tools", "../info"],

Or use raw strings, as @Adam Rosenfield already said in a comment:

"libpath" : [r".", r"..\xlib", r"..\tools", r"..\info"],

I think both of the above solutions are better than doubling all the backslashes, and loads better than just doubling backslashes for directory names that start with 'x'.

steveha
  • 74,789
  • 21
  • 92
  • 117
0
"libpath" : [".", "..\xlib", "..\tools", "..\info"],

This was the problematic line inside hosts.cfg, don't know why Python kept complaining about the execfile line instead of the one inside the file I was calling.

I changed to:

\\xlib and it's working now.
fIwJlxSzApHEZIl
  • 11,861
  • 6
  • 62
  • 71