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

Side by Side Diff: tests/selenium/unpack_firefox.py

Issue 201046: This makes selenium in Firefox work on the Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/selenium/selenium.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
3 import sys
4 import os
5 import shutil
6 import subprocess
7
8 script_dir = os.path.normpath(os.path.dirname(os.path.abspath(__file__)))
9 o3d_dir = os.path.dirname(os.path.dirname(script_dir))
10 src_dir = os.path.dirname(o3d_dir)
11 third_party_dir = os.path.join(src_dir, 'third_party')
12 internal_dir = os.path.join(src_dir, 'o3d-internal')
13 gflags_dir = os.path.join(third_party_dir, 'gflags', 'python')
14 sys.path.append(gflags_dir)
15
16 import gflags
17
18 # Command line flags
19 FLAGS = gflags.FLAGS
20 gflags.DEFINE_boolean("cleanup", False,
21 "If this is set, then the script cleans up "
22 "instead of unpacking.")
23 gflags.DEFINE_string("plugin_path", "", "This is the path to the plugin.")
24 gflags.DEFINE_string("product_path", "",
25 "This is the path to the built products.")
26
27 if sys.platform != "darwin":
28 print "This script is only for use on Mac OS X"
29 sys.exit(-1)
30
31 def Cleanup(dir):
32 shutil.rmtree(dir, ignore_errors=True)
33
34 def InstallInternal(internal_firefox_dir, firefox_dir):
35 firefox_app = os.path.join(firefox_dir, 'Firefox.app')
36 firefox_tgz = os.path.join(internal_firefox_dir, 'firefox.tgz')
37 print "Unpacking Firefox in '%s' to staging area." % firefox_tgz
38 os.mkdir(firefox_dir)
39 subprocess.call(['tar', '-C', firefox_dir, 'xfz', firefox_tgz])
40 dest_plugin_path = os.path.join(firefox_app, 'Contents', 'MacOS',
41 'plugins',
42 os.path.basename(FLAGS.plugin_path))
43 os.symlink(FLAGS.plugin_path, dest_plugin_path)
44 return 0
45
46 def Install(firefox_dir):
47 # No hermetic version, look for Firefox.app in /Applications
48 source_app = '/Applications/Firefox.app'
49 print "Copying Firefox in '%s' to staging area." % source_app
50
51 if not os.path.exists(source_app):
52 print "Unable to find Firefox in %s, is it installed?" % source_app
53 sys.exit(-1)
54
55 firefox_app = os.path.join(firefox_dir, 'Firefox.app')
56 dest_plugin_path = os.path.join(firefox_app, 'Contents', 'MacOS',
57 'plugins',
58 os.path.basename(FLAGS.plugin_path))
59 os.mkdir(firefox_dir)
60 subprocess.call(['ditto', source_app, firefox_app])
61 os.symlink(FLAGS.plugin_path, dest_plugin_path)
62 return 0
63
64 def main(args):
65 internal_firefox_dir = os.path.join(internal_dir, 'firefox')
66 if not os.path.exists(FLAGS.plugin_path):
67 print "Plugin '%s' is missing." % FLAGS.plugin_path
68 sys.exit(-1)
69
70 if not os.path.exists(FLAGS.product_path):
71 print "Product path '%s' is missing." % FLAGS.product_path
72 sys.exit(-1)
73
74 # Cleanup any residual stuff.
75 firefox_dir = os.path.join(FLAGS.product_path, 'selenium_firefox')
76 Cleanup(firefox_dir)
77
78 if not FLAGS.cleanup:
79 # if we have a hermetic version of Firefox, then use it.
80 if os.path.exists(internal_firefox_dir):
81 sys.exit(InstallInternal(internal_firefox_dir, firefox_dir))
82 # Otherwise, we just copy what the user has installed.
83 else:
84 if not FLAGS.cleanup:
85 sys.exit(Install(firefox_dir))
86 sys.exit(0)
87
88 if __name__ == "__main__":
89 bare_args = FLAGS(sys.argv)
90 main(bare_args)
OLDNEW
« no previous file with comments | « tests/selenium/selenium.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698