Skip to content

Commit 8dd054f

Browse files
Eric YeAutomatedTester
authored andcommitted
Make default option values more robust
1 parent b4e6ed8 commit 8dd054f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

browsermobproxy/server.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,11 @@ def start(self, options=None):
9999
of the log file with resp. keys of `log_path` and `log_file`
100100
"""
101101
if options is None:
102-
options = {
103-
'log_path': os.getcwd(),
104-
'log_file': 'server.log',
105-
'retry_sleep': 0.5,
106-
'retry_count': 60,
107-
}
108-
log_path = options.get('log_path')
109-
log_file = options.get('log_file')
102+
options = {}
103+
log_path = options.get('log_path', os.getcwd())
104+
log_file = options.get('log_file', 'server.log')
105+
retry_sleep = options.get('retry_sleep', 0.5)
106+
retry_count = options.get('retry_count', 60)
110107
log_path_name = os.path.join(log_path, os.path.sep, log_file)
111108
self.log_file = open(log_path_name, 'w')
112109

@@ -122,9 +119,9 @@ def start(self, options=None):
122119
"for a helpful error message.".format(self.log_file))
123120

124121
raise Exception(message)
125-
time.sleep(options.get('retry_sleep'))
122+
time.sleep(retry_sleep)
126123
count += 1
127-
if count == options.get('retry_count'):
124+
if count == retry_count:
128125
self.stop()
129126
raise Exception("Can't connect to Browsermob-Proxy")
130127

0 commit comments

Comments
 (0)