Now starting AppRTC server up in "developer mode".

We don't have a way to click on the new join confirmation buttons from
Firefox; therefore we'll start the server in a special mode where the
join buttons are disabled.

We can't do this with an URL parameter since the purpose of the buttons
is to prevent embedding services to get users to auto-join.

B=None
R=kjellander@chromium.org

Review URL: https://codereview.chromium.org/872143005

git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/webrtc/webrtc.DEPS@293859 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/build_apprtc_closure.py b/build_apprtc_closure.py
index 4dae3c3..1a1f2ee 100755
--- a/build_apprtc_closure.py
+++ b/build_apprtc_closure.py
@@ -27,7 +27,7 @@
 
     for line in fileinput.input(package_json, inplace=True):
       if not 'phantomjs' in line:
-        print line
+        sys.stdout.write(line)
 
 
 def main():
diff --git a/copy_apprtc.py b/copy_apprtc.py
index 5a9a3c9..538e50f 100755
--- a/copy_apprtc.py
+++ b/copy_apprtc.py
@@ -10,25 +10,45 @@
 understand those symlinks).
 """
 
+import fileinput
 import os
 import shutil
+import sys
 
 import utils
 
-if __name__ == '__main__':
-  target_dir = os.path.join('src', 'out', 'webrtc-samples')
-  if utils.GetPlatform() is 'win':
-    # Work around the fact that node_modules create ridiculously long paths.
-    # Unfortunately shutil will choke on those on Windows, but not rmdir.
-    os.system('rmdir /s /q %s' % target_dir)
-  else:
-    shutil.rmtree(target_dir, ignore_errors=True)
+
+def _ConfigureApprtcServerToDeveloperMode(apprtc_dir):
+  app_yaml_path = os.path.join(apprtc_dir, 'app.yaml')
+  if not os.path.exists(app_yaml_path):
+    return 'Expected app.yaml at %s.' % os.path.abspath(app_yaml_path)
+
+  for line in fileinput.input(app_yaml_path, inplace=True):
+    # We can't click past these in the firefox interop test, so
+    # disable them.
+    line = line.replace('BYPASS_JOIN_CONFIRMATION: false',
+                        'BYPASS_JOIN_CONFIRMATION: true')
+    sys.stdout.write(line)
+
+
+def _CopyApprtcToTargetDir(target_dir, apprtc_subdir):
+  shutil.rmtree(target_dir, ignore_errors=True)
   shutil.copytree('webrtc-samples',
                   target_dir, ignore=shutil.ignore_patterns('.svn', '.git'))
-  apprtc_subdir = os.path.join('samples', 'web', 'content', 'apprtc')
 
   # This file is symlinked on windows, so copy it since win doesn't understand
   # symlinks.
   shutil.copyfile(os.path.join('webrtc-samples', 'samples', 'web',
                                'js', 'adapter.js'),
                   os.path.join(target_dir, apprtc_subdir, 'js', 'adapter.js'))
+
+
+def main():
+  target_dir = os.path.join('src', 'out', 'webrtc-samples')
+  apprtc_subdir = os.path.join('samples', 'web', 'content', 'apprtc')
+  _CopyApprtcToTargetDir(target_dir, apprtc_subdir)
+  _ConfigureApprtcServerToDeveloperMode(os.path.join(target_dir, apprtc_subdir))
+
+if __name__ == '__main__':
+  sys.exit(main())
+