I use tornado.options to define a few options and parse from both the file and cmdline.
the problem is that I want to get the base_dir by use os.path.realpath(file). which will raise Exception.
how can I got out of this. this code was like below.
while I run python options.py, it will raise Error. the error msg was beow.
$ python options.py
Traceback (most recent call last):
File "options.py", line 19, in <module>
opts.parse_command_line(['options.py', '--config=config.py'])
File "/home/daipeng/.virtualenvs/logagent_env/local/lib/python2.7/site-packages/tornado/options.py", line 286, in parse_command_line
option.parse(value)
File "/home/daipeng/.virtualenvs/logagent_env/local/lib/python2.7/site-packages/tornado/options.py", line 448, in parse
self.callback(self._value)
File "options.py", line 9, in config_callback
option_parser.parse_config_file(path, final=False)
File "/home/daipeng/.virtualenvs/logagent_env/local/lib/python2.7/site-packages/tornado/options.py", line 306, in parse_config_file
exec_in(native_str(f.read()), config, config)
File "<string>", line 10, in exec_in
File "<string>", line 7, in <module>
NameError: name '__file__' is not defined
I use tornado.options to define a few options and parse from both the file and cmdline. the problem is that I want to get the base_dir by use os.path.realpath(file). which will raise Exception.
how can I got out of this. this code was like below.
while I run
python options.py
, it will raise Error. the error msg was beow.