Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Unified Diff: replay.py

Issue 10829202: Add --append option to replay.py. (Closed) Base URL: https://web-page-replay.googlecode.com/svn/trunk
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « httparchive.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: replay.py
diff --git a/replay.py b/replay.py
index c7d7d539f315ae21169a7e07482398fd6b2ee0dd..890aac730693a216b228df93214366d78269cc24 100755
--- a/replay.py
+++ b/replay.py
@@ -165,6 +165,8 @@ class OptionsWrapper(object):
_CONFLICTING_OPTIONS = (
('record', ('down', 'up', 'delay_ms', 'packet_loss_rate', 'net',
'spdy', 'use_server_delay')),
+ ('append', ('down', 'up', 'delay_ms', 'packet_loss_rate', 'net',
+ 'spdy', 'use_server_delay')), # same as --record
('net', ('down', 'up', 'delay_ms')),
('server', ('server_mode',)),
)
@@ -230,6 +232,8 @@ class OptionsWrapper(object):
def _MassageValues(self):
"""Set options that depend on the values of other options."""
+ if self.append and not self.record:
+ self._options.record = True
for net_choice, values in self._NET_CONFIGS:
if net_choice == self.net:
self._options.down, self._options.up, self._options.delay_ms = values
@@ -279,8 +283,13 @@ def replay(options, replay_filename):
real_dns_lookup = dnsproxy.RealDnsLookup(
name_servers=[platformsettings.get_original_primary_nameserver()])
if options.record:
- http_archive = httparchive.HttpArchive()
- http_archive.AssertWritable(replay_filename)
+ httparchive.HttpArchive.AssertWritable(replay_filename)
+ if options.append and os.path.exists(replay_filename):
+ http_archive = httparchive.HttpArchive.Load(replay_filename)
+ logging.info('Appending to %s (loaded %d existing responses)',
+ replay_filename, len(http_archive))
+ else:
+ http_archive = httparchive.HttpArchive()
else:
http_archive = httparchive.HttpArchive.Load(replay_filename)
logging.info('Loaded %d responses from %s',
@@ -344,6 +353,9 @@ def GetOptionParser():
option_parser.add_option('-r', '--record', default=False,
action='store_true',
help='Download real responses and record them to replay_file')
+ option_parser.add_option('--append', default=False,
+ action='store_true',
+ help='Append responses to replay_file.')
option_parser.add_option('-l', '--log_level', default='debug',
action='store',
type='choice',
« no previous file with comments | « httparchive.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698