<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.

"""Bugdroid Git implementation for the Skia repositories.

Execute the script with the following command:
python bugdroid_git.py --repo /storage/skia-repos/skia
"""

import logging
import optparse
import os
import sys
import time

from bugdroid import Bugdroid

# Set the PYTHONPATH for this script to include skia_slave_scripts.utils.
sys.path.append(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir,
                 os.pardir, 'slave', 'skia_slave_scripts', 'utils'))
import shell_utils


# Time to sleep between repository polls.
SLEEP_BETWEEN_POLLS = 60
# The user BugDroid is run as
BUGDROID_USER = '<EMAIL>'


def main():
  parser = optparse.OptionParser()
  parser.add_option('-a', '--allowed-projects', action='append',
                    default=['skia'],
                    dest='trackers',
                    help='issue trackers that can be updated')
  parser.add_option('-e', '--default-project', dest='default_tracker',
                    help='the issue tracker to update if no project name is '
                         'given in the BUG= line', default='skia')
  parser.add_option('-v', '--version', dest='version_string',
                    help='the version string to be printed in the log.',
                    default='1.0')
  parser.add_option('-r', '--repo', dest='repo_location',
                    help='the complete path to the git repository bugdroid '
                         'should track.')
  (options, _args) = parser.parse_args()

  # Validate arguments.
  repo_location = options.repo_location
  if not repo_location or not os.path.exists(repo_location):
    raise Exception('Must specify a valid path to a repository using --repo')

  # Configure the logger
  folder_path = os.path.dirname(os.path.abspath(__file__))
  log_file_path = os.path.join(folder_path, 'bugdroid_log.txt')
  logging.basicConfig(filename=log_file_path, level=logging.DEBUG, maxBytes=10)

  logging.debug('===========================================')
  logging.debug(time.strftime('Bugdroid starting: %Y-%m-%d %H:%M:%S'))
  logging.debug('Current bugdroid version %s' % options.version_string)

  # Find and use the .bugdroid_password file from the toplevel buildbot dir.
  parent = os.path.dirname(os.path.abspath(__file__))
  password_path = os.path.join(parent, os.pardir, os.pardir,
                               '.bugdroid_password')
  if os.path.exists(password_path):
    logging.debug('Using the local password file: %s' % password_path)
    password = open(password_path, 'r').readline().strip()
  else:
    logging.debug('No password file present, aborting!')
    return 1
  bugger = Bugdroid(BUGDROID_USER, password)
  if not bugger.login():
    logging.debug('Login failed, aborting.')
    return 1

  # Keep going till the process is killed by a Keyboard Interrupt.
  try:
    while True:
      # Change cwd to the repo_location.
      os.chdir(repo_location)

      # Do a git fetch on the specified repository.<commit_msg>Add --log-file-name to bugdroid_git.py<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.

"""Bugdroid Git implementation for the Skia repositories.

Execute the script with the following command:
python bugdroid_git.py --repo /storage/skia-repos/skia \
                       --log-file-name skia-bugdroid-log.txt
"""

import logging
import optparse
import os
import sys
import time

from bugdroid import Bugdroid

# Set the PYTHONPATH for this script to include skia_slave_scripts.utils.
sys.path.append(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir,
                 os.pardir, 'slave', 'skia_slave_scripts', 'utils'))
import shell_utils


# Time to sleep between repository polls.
SLEEP_BETWEEN_POLLS = 60
# The user BugDroid is run as
BUGDROID_USER = '<EMAIL>'


def main():
  parser = optparse.OptionParser()
  parser.add_option('-a', '--allowed-projects', action='append',
                    default=['skia'],
                    dest='trackers',
                    help='issue trackers that can be updated')
  parser.add_option('-e', '--default-project', dest='default_tracker',
                    help='the issue tracker to update if no project name is '
                         'given in the BUG= line', default='skia')
  parser.add_option('-v', '--version', dest='version_string',
                    help='the version string to be printed in the log.',
                    default='1.0')
  parser.add_option('-r', '--repo', dest='repo_location',
                    help='the complete path to the git repository bugdroid '
                         'should track.')
  parser.add_option('-l', '--log-file-name', dest='log_file_name',
                    help='the name of the bugdroid log file, it will be '
                         'created in the same directory as this file.')
  (options, _args) = parser.parse_args()

  # Validate arguments.
  repo_location = options.repo_location
  if not repo_location or not os.path.exists(repo_location):
    raise Exception('Must specify a valid path to a repository using --repo')

  # Configure the logger
  folder_path = os.path.dirname(os.path.abspath(__file__))
  log_file_path = os.path.join(folder_path, options.log_file_name)
  logging.basicConfig(filename=log_file_path, level=logging.DEBUG, maxBytes=10)

  logging.debug('===========================================')
  logging.debug(time.strftime('Bugdroid starting: %Y-%m-%d %H:%M:%S'))
  logging.debug('Current bugdroid version %s' % options.version_string)

  # Find and use the .bugdroid_password file from the toplevel buildbot dir.
  parent = os.path.dirname(os.path.abspath(__file__))
  password_path = os.path.join(parent, os.pardir, os.pardir,
                               '.bugdroid_password')
  if os.path.exists(password_path):
    logging.debug('Using the local password file: %s' % password_path)
    password = open(password_path, 'r').readline().strip()
  else:
    logging.debug('No password file present, aborting!')
    return 1
  bugger = Bugdroid(BUGDROID_USER, password)
  if not bugger.login():
    logging.debug('Login failed, aborting.')
    return 1

  # Keep going till the process is killed by a Keyboard Interrupt.
  try:
    while True:
      # Change cwd to the repo_location.
      os.chdir(repo_location)

      # Do a git fetch on the specified repository.
{'fraction_non_alphanumeric': 0.1232753449310138, 'fraction_numerical': 0.003599280143971206, 'mean_word_length': 3.0739156994502137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1987967', 'n_tokens_mistral': 2047, 'n_tokens_neox': 1957, 'n_words': 581}