def get_build_directory(self):
        """Returns the location of the correct build to use for reproduction."""

        if self.build_directory:
            return self.build_directory

        self.download_build_data()
        self.build_directory = self.build_dir_name()
        if not self.source_directory:
            message = (
                'This is a %(name)s testcase, please define $%(env_name)s_SRC'
                ' or enter your %(name)s source location here' % {
                    'name': self.name,
                    'env_name': self.name.upper()
                })
            self.source_directory = os.path.expanduser(
                common.ask(
                    message, 'Please enter a valid directory',
                    lambda x: x and os.path.isdir(os.path.expanduser(x))))
        if not self.current:
            self.checkout_source_by_sha()
        self.build_directory = self.out_dir_name()
        self.build_target()

        return self.build_directory
예제 #2
0
def get_verification_header():
  """Prompts the user for & returns a verification token."""

  webbrowser.open(GOOGLE_OAUTH_URL, new=1, autoraise=True)
  verification = common.ask('Please enter your verification code',
                            'Please enter a code', bool)
  return 'VerificationCode %s' % verification
예제 #3
0
  def test_returns_when_correct(self):
    """Tests that the method only returns when the answer fits validation."""

    question = 'Initial Question'
    error_message = 'Please answer correctly'
    validate_fn = lambda x: x == 'correct'

    result = common.ask(question, error_message, validate_fn)
    self.assert_n_calls(4, [self.mock.raw_input])
    self.mock.raw_input.assert_has_calls([
        mock.call('Initial Question: '),
        mock.call('Please answer correctly: ')])
    self.assertEqual(result, 'correct')
예제 #4
0
def get_verification_header():
  """Prompts the user for & returns a verification token."""
  print
  logger.info(('We need to authenticate you in order to get information from '
               'ClusterFuzz.'))
  print

  logger.info('Open: %s', GOOGLE_OAUTH_URL)
  with SuppressOutput():
    webbrowser.open(GOOGLE_OAUTH_URL, new=1, autoraise=True)
  print

  verification = common.ask(
      'Please login using the above URL and get your verification code',
      'Please enter the verification code', bool)
  return 'VerificationCode %s' % verification
예제 #5
0
def get_verification_header():
    """Prompts the user for & returns a verification token."""
    print
    print(
        'We need to authenticate you in order to get information from '
        'ClusterFuzz.')
    print

    print 'Open: %s' % GOOGLE_OAUTH_URL
    with SuppressOutput():
        webbrowser.open(GOOGLE_OAUTH_URL, new=1, autoraise=True)
    print

    verification = common.ask(
        'Please login on the opened webpage and enter your verification code',
        'Please enter a code', bool)
    return 'VerificationCode %s' % verification
def get_or_ask_for_source_location(source_name):
  """Returns the location of the source directory."""

  source_env = '%s_SRC' % source_name.upper()

  if os.environ.get(source_env):
    source_directory = os.environ.get(source_env)
  else:
    message = ('This is a %(name)s testcase, please define %(env_name)s'
               ' or enter your %(name)s source location here' %
               {'name': source_name, 'env_name': source_env})

    source_directory = common.get_valid_abs_dir(
        common.ask(
            message, 'Please enter a valid directory',
            common.get_valid_abs_dir))

  check_gclient_managed(source_directory)
  return source_directory