OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Moves Apprtc to the out/ directory, where the browser test can find it. | 6 """Moves Apprtc to the out/ directory, where the browser test can find it. |
7 | 7 |
8 This copy will resolve symlinks on all platforms, which is useful for Apprtc | 8 This copy will resolve symlinks on all platforms, which is useful for Apprtc |
9 since it uses symlinks for its common javascript files (and Windows does not | 9 since it uses symlinks for its common javascript files (and Windows does not |
10 understand those symlinks). | 10 understand those symlinks). |
11 """ | 11 """ |
12 | 12 |
13 import fileinput | |
13 import os | 14 import os |
14 import shutil | 15 import shutil |
16 import sys | |
15 | 17 |
16 import utils | 18 import utils |
17 | 19 |
18 if __name__ == '__main__': | 20 |
19 target_dir = os.path.join('src', 'out', 'webrtc-samples') | 21 def _ConfigureApprtcServerToDeveloperMode(apprtc_dir): |
22 app_yaml_path = os.path.join(apprtc_dir, 'app.yaml') | |
23 if not os.path.exists(app_yaml_path): | |
24 return 'Expected app.yaml at %s.' % os.path.abspath(app_yaml_path) | |
25 | |
26 for line in fileinput.input(app_yaml_path, inplace=True): | |
27 # We can't click past these in the firefox interop test, so | |
28 # disable them. | |
29 line = line.replace('BYPASS_JOIN_CONFIRMATION: false', | |
30 'BYPASS_JOIN_CONFIRMATION: true') | |
31 sys.stdout.write(line) | |
32 | |
33 | |
34 def _CopyApprtcToTargetDir(target_dir, apprtc_subdir): | |
phoglund_chromium
2015/01/29 13:00:14
The more I think about it, this should really be a
kjellander_chromium
2015/01/29 13:11:15
Yeah, our hooks starts growing out of control here
phoglund_chromium
2015/01/29 13:46:24
Hm, yeah. The downloading and syncing stuff should
| |
20 if utils.GetPlatform() is 'win': | 35 if utils.GetPlatform() is 'win': |
21 # Work around the fact that node_modules create ridiculously long paths. | 36 # Work around the fact that node_modules create ridiculously long paths. |
22 # Unfortunately shutil will choke on those on Windows, but not rmdir. | 37 # Unfortunately shutil will choke on those on Windows, but not rmdir. |
23 os.system('rmdir /s /q %s' % target_dir) | 38 os.system('rmdir /s /q %s' % target_dir) |
kjellander_chromium
2015/01/29 13:11:15
Will we catch errors if this fails? It seems like
phoglund_chromium
2015/01/29 13:46:24
Yeah. Actually I realize I can remove this because
| |
24 else: | 39 else: |
25 shutil.rmtree(target_dir, ignore_errors=True) | 40 shutil.rmtree(target_dir, ignore_errors=True) |
26 shutil.copytree('webrtc-samples', | 41 shutil.copytree('webrtc-samples', |
27 target_dir, ignore=shutil.ignore_patterns('.svn', '.git')) | 42 target_dir, ignore=shutil.ignore_patterns('.svn', '.git')) |
28 apprtc_subdir = os.path.join('samples', 'web', 'content', 'apprtc') | |
29 | 43 |
30 # This file is symlinked on windows, so copy it since win doesn't understand | 44 # This file is symlinked on windows, so copy it since win doesn't understand |
31 # symlinks. | 45 # symlinks. |
32 shutil.copyfile(os.path.join('webrtc-samples', 'samples', 'web', | 46 shutil.copyfile(os.path.join('webrtc-samples', 'samples', 'web', |
33 'js', 'adapter.js'), | 47 'js', 'adapter.js'), |
34 os.path.join(target_dir, apprtc_subdir, 'js', 'adapter.js')) | 48 os.path.join(target_dir, apprtc_subdir, 'js', 'adapter.js')) |
49 | |
50 | |
51 def Main(): | |
kjellander_chromium
2015/01/29 13:11:15
nit: the Chromium style guide says the main functi
phoglund_chromium
2015/01/29 13:46:24
Done.
| |
52 target_dir = os.path.join('src', 'out', 'webrtc-samples') | |
53 apprtc_subdir = os.path.join('samples', 'web', 'content', 'apprtc') | |
54 _CopyApprtcToTargetDir(target_dir, apprtc_subdir) | |
55 _ConfigureApprtcServerToDeveloperMode(os.path.join(target_dir, apprtc_subdir)) | |
56 | |
57 if __name__ == '__main__': | |
58 sys.exit(Main()) | |
59 | |
OLD | NEW |