Do not choke on missing ENV vars

This commit is contained in:
Marcin Kulik
2014-02-13 23:19:23 +01:00
parent 4d8700093e
commit 615986dc61
2 changed files with 4 additions and 4 deletions

View File

@@ -8,9 +8,9 @@ class Asciicast(object):
def __init__(self, env=os.environ): def __init__(self, env=os.environ):
self.command = None self.command = None
self.title = None self.title = None
self.shell = env['SHELL'] self.shell = env.get('SHELL', '/bin/sh')
self.term = env['TERM'] self.term = env.get('TERM')
self.username = env['USER'] self.username = env.get('USER')
@property @property
def meta_data(self): def meta_data(self):

View File

@@ -13,7 +13,7 @@ class Recorder(object):
def record(self, cmd, title): def record(self, cmd, title):
duration, stdout = timer.timeit(self.pty_recorder.record_command, duration, stdout = timer.timeit(self.pty_recorder.record_command,
cmd or self.env['SHELL']) cmd or self.env.get('SHELL', '/bin/sh'))
asciicast = Asciicast() asciicast = Asciicast()
asciicast.title = title asciicast.title = title