예제 #1
0
        def ParseArgs(args=None):
            defaults = parser.get_default_values()
            for k, v in defaults.__dict__.items():
                if k in self.__dict__ and self.__dict__[k] != None:
                    continue
                self.__dict__[k] = v
            ret = real_parse(args, self)  # pylint: disable=E1121

            if self.verbosity >= 2:
                global_hooks.InstallSpyOnPopenArgs()
                logging.getLogger().setLevel(logging.DEBUG)
            elif self.verbosity:
                logging.getLogger().setLevel(logging.INFO)
            else:
                logging.getLogger().setLevel(logging.WARNING)

            if self.chromium_output_dir:
                os.environ['CHROMIUM_OUTPUT_DIR'] = self.chromium_output_dir

            # Parse remote platform options.
            self.BuildRemotePlatformOptions()

            if self.remote_platform_options.device == 'list':
                if binary_manager.NeedsInit():
                    binary_manager.InitDependencyManager([])
                devices = device_finder.GetDevicesMatchingOptions(self)
                print 'Available devices:'
                for device in devices:
                    print ' ', device.name
                sys.exit(0)

            if self.browser_executable and not self.browser_type:
                self.browser_type = 'exact'
            if self.browser_type == 'list':
                if binary_manager.NeedsInit():
                    binary_manager.InitDependencyManager([])
                devices = device_finder.GetDevicesMatchingOptions(self)
                if not devices:
                    sys.exit(0)
                browser_types = {}
                for device in devices:
                    try:
                        possible_browsers = browser_finder.GetAllAvailableBrowsers(
                            self, device)
                        browser_types[device.name] = sorted([
                            browser.browser_type
                            for browser in possible_browsers
                        ])
                    except browser_finder_exceptions.BrowserFinderException as ex:
                        print >> sys.stderr, 'ERROR: ', ex
                        sys.exit(1)
                print 'Available browsers:'
                if len(browser_types) == 0:
                    print '  No devices were found.'
                for device_name in sorted(browser_types.keys()):
                    print '  ', device_name
                    for browser_type in browser_types[device_name]:
                        print '    ', browser_type
                    if len(browser_types[device_name]) == 0:
                        print '     No browsers found for this device'
                sys.exit(0)

            # Parse browser options.
            self.browser_options.UpdateFromParseResults(self)

            return ret
예제 #2
0
    def ParseArgs(args=None):
      defaults = parser.get_default_values()
      for k, v in defaults.__dict__.items():
        if k in self.__dict__ and self.__dict__[k] != None:
          continue
        self.__dict__[k] = v
      ret = real_parse(args, self)  # pylint: disable=E1121

      if self.verbosity >= 2:
        global_hooks.InstallSpyOnPopenArgs()
        logging.getLogger().setLevel(logging.DEBUG)
      elif self.verbosity:
        logging.getLogger().setLevel(logging.INFO)
      else:
        logging.getLogger().setLevel(logging.WARNING)

      if self.chromium_output_dir:
        os.environ['CHROMIUM_OUTPUT_DIR'] = self.chromium_output_dir

      # Parse remote platform options.
      self.BuildRemotePlatformOptions()

      if self.remote_platform_options.device == 'list':
        if binary_manager.NeedsInit():
          binary_manager.InitDependencyManager([])
        devices = device_finder.GetDevicesMatchingOptions(self)
        print 'Available devices:'
        for device in devices:
          print ' ', device.name
        sys.exit(0)

      if self.browser_executable and not self.browser_type:
        self.browser_type = 'exact'
      if self.browser_type == 'list':
        if binary_manager.NeedsInit():
          binary_manager.InitDependencyManager([])
        devices = device_finder.GetDevicesMatchingOptions(self)
        if not devices:
          sys.exit(0)
        browser_types = {}
        for device in devices:
          try:
            possible_browsers = browser_finder.GetAllAvailableBrowsers(self,
                                                                       device)
            browser_types[device.name] = sorted(
                [browser.browser_type for browser in possible_browsers])
          except browser_finder_exceptions.BrowserFinderException as ex:
            print >> sys.stderr, 'ERROR: ', ex
            sys.exit(1)
        print 'Available browsers:'
        if len(browser_types) == 0:
          print '  No devices were found.'
        for device_name in sorted(browser_types.keys()):
          print '  ', device_name
          for browser_type in browser_types[device_name]:
            print '    ', browser_type
          if len(browser_types[device_name]) == 0:
            print '     No browsers found for this device'
        sys.exit(0)

      # Profiling other periods along with the story_run period leads to running
      # multiple profiling processes at the same time. The effects of performing
      # muliple CPU profiling at the same time is unclear and may generate
      # incorrect profiles so this will not be supported.
      if (len(self.interval_profiling_periods) > 1
          and 'story_run' in self.interval_profiling_periods):
        print 'Cannot specify other periods along with the story_run period.'
        sys.exit(1)

      self.interval_profiler_options = shlex.split(
          self.interval_profiler_options)

      # Parse browser options.
      self.browser_options.UpdateFromParseResults(self)

      return ret