crash on starting on systems which do not define 'hostname'
Brought to you by:
vikrampudi
Ubuntu doesn't define the hostname variable - this causes shython to crash.
fix: it could run the hostname command, if it couldn't find the hostname variable.
chris@chris-laptop:~$ shython.py
Traceback (most recent call last):
File "/bin/shython.py", line 688, in <module>
Cline=Cmdline()
File "/bin/shython.py", line 22, in __init__
self._ps1dict={"\u":os.getlogin(),'@':'@',"\h":os.environ['HOSTNAME'].split('.')[0],"\W":" "+os.getcwd().split('/')[-1],"\w":" "+os.getcwd(),"\d":time.strftime(' %a %b %d'),"\$":" $" }
File "/usr/lib/python2.5/UserDict.py", line 22, in __getitem__
raise KeyError(key)
KeyError: 'HOSTNAME'
Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
Ubuntu Feisty
This package seems to have become unmaintained, but I have worked a solution to the problem with minor corrections.
line 22 should read:
self._ps1dict={"\u":os.environ['USER'],'@':'@',"\h":gethostname().split('.')[0],"\W":" "+os.getcwd().split('/')[-1],"\w":" "+os.getcwd(),"\d":time.strftime(' %a %b %d'),"\$":" $" }
To make this work, this line needs to be added to the imports. If adding this first, the line above becomes line 23.
from socket import gethostname