author Mihai Tabara <>
Thu, 09 Mar 2017 16:57:58 +0000
changeset 7370 62d16da877aa0b8c257e39da9b817eac9f115807
parent 3803 03954b53422c6b59c2aceb991d1beb2a77d06210
permissions -rwxr-xr-x
Bug 1344202 - uptake monitoring platforms now have dedicated variable. r=rail MozReview-Commit-ID: 5LtqR2f14Ss

#! /usr/bin/env python

import os
import sys
from optparse import OptionParser

parser = OptionParser()
parser.add_option("-p", "--path", action="store", dest="basepath",
                  help="Path to process")
parser.add_option("-w", "--wait", action="store", type="int", dest="wait",
                  help="Path to process")
(options, args) = parser.parse_args()

if not options.basepath or not os.path.isdir(options.basepath):
    print "Error: path must be specified"

if not options.wait or options.wait < 0:
    print "Error: wait time must be an integer greater than 0"

mod_count = 0
total_count = 0

for root, dirs, files in os.walk(options.basepath):
    for f in files:
        fullpath = os.path.join(root, f)
        total_count += 1

        # leave empty files alone
        if os.path.getsize(fullpath) == 0:

        content = open(fullpath).readlines()

        # bail if this is version=1 snippet
        if 'version=1' in content[0]:

        new_content = [c for c in content if 'promptWaitTime' not in c]
        new_content.append('promptWaitTime=%i' % options.wait)

        if new_content != content:
            fd = open(fullpath,'w')
            mod_count += 1

print "modified %s of %s files" % (mod_count, total_count)