<commit_before>#!/usr/bin/python
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


import getpass
import os
import re
import subprocess
import sys
import tempfile
import urllib


def Authenticate():
  default_username = getpass.getuser()
  username = os.environ.get('GSDCURL_USERNAME')
  if username is None:
    sys.stderr.write('Username [' + default_username + ']: ')
    username = raw_input()
  if username == '':
    username = default_username + '@google.com'
  elif '@' not in username:
    username = username + '@google.com'
  passwd = os.environ.get('GSDCURL_PASSWORD')
  if passwd is None:
    sys.stderr.write('Password: ')
    passwd = urllib.quote_plus(getpass.getpass(prompt=''))
  cmd = [
      'curl', '--silent', 'https://www.google.com/accounts/ClientLogin',
      '-d', 'Email=' + username,
      '-d', 'Passwd=' + <PASSWORD>,
      '-d', 'accountType=GOOGLE',
      '-d', 'source=Google-gsdcurl-ver1',
      '-d', 'service=cds',
  ]
  p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
  (p_stdout, _) = p.communicate()
  assert p.returncode == 0
  m = re.search('\nAuth=([^\n]+)\n', p_stdout)
  if not m:
    sys.stderr.write('BAD LOGIN\n')
    sys.exit(1)
  auth = m.group(1)
  return auth


def DoCurl(auth, argv):
  (_, cookies) = tempfile.mkstemp(prefix='gsdcookie')
  cmd = [
      'curl', '-L',
      '-b', cookies, '-c', cookies,
      '--header', 'Authorization: GoogleLogin auth=' + auth,
  ] + argv[1:]
  try:
    p = subprocess.Popen(cmd)
    return p.wait()
  finally:
    os.remove(cookies)


def main(argv):
  auth = Authenticate()<commit_msg>Fix gsdcurl to correctly URL-quote a password passed via GSDCURL_PASSWORD<commit_after>#!/usr/bin/python
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


import getpass
import os
import re
import subprocess
import sys
import tempfile
import urllib


def Authenticate():
  default_username = getpass.getuser()
  username = os.environ.get('GSDCURL_USERNAME')
  if username is None:
    sys.stderr.write('Username [' + default_username + ']: ')
    username = raw_input()
  if username == '':
    username = default_username + '@google.com'
  elif '@' not in username:
    username = username + '@google.com'
  passwd = os.environ.get('GSDCURL_PASSWORD')
  if passwd is None:
    sys.stderr.write('Password: ')
    passwd = getpass.getpass(prompt='')
  cmd = [
      'curl', '--silent', 'https://www.google.com/accounts/ClientLogin',
      '-d', 'Email=' + username,
      '-d', 'Passwd=' + urllib.quote_plus(passwd),
      '-d', 'accountType=GOOGLE',
      '-d', 'source=Google-gsdcurl-ver1',
      '-d', 'service=cds',
  ]
  p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
  (p_stdout, _) = p.communicate()
  assert p.returncode == 0
  m = re.search('\nAuth=([^\n]+)\n', p_stdout)
  if not m:
    sys.stderr.write('BAD LOGIN\n')
    sys.exit(1)
  auth = m.group(1)
  return auth


def DoCurl(auth, argv):
  (_, cookies) = tempfile.mkstemp(prefix='gsdcookie')
  cmd = [
      'curl', '-L',
      '-b', cookies, '-c', cookies,
      '--header', 'Authorization: GoogleLogin auth=' + auth,
  ] + argv[1:]
  try:
    p = subprocess.Popen(cmd)
    return p.wait()
  finally:
    os.remove(cookies)


def main(argv):
  auth = Authenticate()
{'fraction_non_alphanumeric': 0.16001157407407407, 'fraction_numerical': 0.005208333333333333, 'mean_word_length': 3.348427672955975, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5773778', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1214, 'n_words': 298}