def Run(self): self._ParseArgs() if not os.path.isdir(self._outdir): os.makedirs(self._outdir) # Fetch chrome & pyauto binaries print 'Fetching' print self._chrome_zip_url print self._pyautolib_py_url print self._pyautolib_so_url chrome_zip = urllib.urlretrieve(self._chrome_zip_url)[0] pyautolib_py = urllib.urlretrieve(self._pyautolib_py_url)[0] pyautolib_so = urllib.urlretrieve(self._pyautolib_so_url)[0] chrome_unzip_dir = os.path.join(self._outdir, self._chrome_zip_name) if os.path.exists(chrome_unzip_dir): print 'Cleaning', chrome_unzip_dir pyauto_utils.RemovePath(chrome_unzip_dir) pyauto_utils.UnzipFilenameToDir(chrome_zip, self._outdir) # Copy over the binaries to outdir items_to_copy = { pyautolib_py: os.path.join(self._outdir, 'pyautolib.py'), pyautolib_so: os.path.join( self._outdir, { 'linux64': '_pyautolib.so', 'linux32': '_pyautolib.so', 'mac': '_pyautolib.so', 'win': '_pyautolib.pyd' }[self._options.platform]) } unzip_dir_contents = glob.glob(os.path.join(chrome_unzip_dir, '*')) for item in unzip_dir_contents: name = os.path.basename(item) items_to_copy[item] = os.path.join(self._outdir, name) for src, dest in items_to_copy.iteritems(): pyauto_utils.RemovePath(dest) print '%s ==> %s' % (os.path.basename(src), dest) shutil.move(src, dest) pyauto_utils.RemovePath(chrome_unzip_dir) # Final setup (if any) # Create symlink to .framework on Mac if self._options.platform == 'mac': mac_app_name = os.path.basename( [x for x in unzip_dir_contents if x.endswith('.app')][0]) os.chdir(self._outdir) framework = glob.glob( os.path.join(mac_app_name, 'Contents', 'Versions', '*', '*.framework'))[0] print framework dest = os.path.basename(framework) os.path.lexists(dest) and os.remove(dest) print 'Creating symlink "%s"' % dest os.symlink(framework, dest) print 'Prepared binaries in "%s"' % self._outdir
def Run(self): self._ParseArgs() if not os.path.isdir(self._outdir): os.makedirs(self._outdir) get_it2me = self._DoesURLExist(self._it2me_zip_url) # Fetch chrome & pyauto binaries print 'Fetching' print self._chrome_zip_url if get_it2me: print self._it2me_zip_url else: print 'Warning: %s does not exist.' % self._it2me_zip_url print self._pyautolib_py_url print self._pyautolib_so_url print self._chromedriver_url chrome_zip = urllib.urlretrieve(self._chrome_zip_url)[0] if get_it2me: it2me_zip = urllib.urlretrieve(self._it2me_zip_url)[0] pyautolib_py = urllib.urlretrieve(self._pyautolib_py_url)[0] pyautolib_so = urllib.urlretrieve(self._pyautolib_so_url)[0] chromedriver = urllib.urlretrieve(self._chromedriver_url)[0] chrome_unzip_dir = os.path.join(self._outdir, self._chrome_zip_name) if os.path.exists(chrome_unzip_dir): print 'Cleaning', chrome_unzip_dir pyauto_utils.RemovePath(chrome_unzip_dir) pyauto_utils.UnzipFilenameToDir(chrome_zip, self._outdir) if get_it2me: pyauto_utils.UnzipFilenameToDir(it2me_zip, self._outdir) shutil.move(self._outdir + '/remoting-it2me', self._outdir + '/remoting/it2me.webapp') # Copy over the binaries to outdir items_to_copy = { pyautolib_py: os.path.join(self._outdir, 'pyautolib.py'), pyautolib_so: os.path.join(self._outdir, self._pyautolib_so_name), chromedriver: os.path.join(self._outdir, self._chromedriver_name) } unzip_dir_contents = glob.glob(os.path.join(chrome_unzip_dir, '*')) for item in unzip_dir_contents: name = os.path.basename(item) items_to_copy[item] = os.path.join(self._outdir, name) for src, dest in items_to_copy.iteritems(): pyauto_utils.RemovePath(dest) print '%s ==> %s' % (os.path.basename(src), dest) shutil.move(src, dest) pyauto_utils.RemovePath(chrome_unzip_dir) # Final setup (if any) # Set executable bit on chromedriver binary. if not self._options.platform == 'win': os.chmod(items_to_copy[chromedriver], 0700) # Create symlink to .framework on Mac if self._options.platform == 'mac': mac_app_name = os.path.basename([x for x in unzip_dir_contents if x.endswith('.app')][0]) os.chdir(self._outdir) framework = glob.glob(os.path.join( mac_app_name, 'Contents', 'Versions', '*', '*.framework'))[0] print framework dest = os.path.basename(framework) os.path.lexists(dest) and os.remove(dest) print 'Creating symlink "%s"' % dest os.symlink(framework, dest) print 'Prepared binaries in "%s"' % self._outdir