<commit_before># Copyright 2011 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import prelaunch_client
import os
import sys

def run(prelaunch=False):
  """Called by bootstrapper when the environment is ready to run."""
  if sys.argv[1] != '--main-name':
    raise Exception("launched wrong: expected --main-name <mainname> as first argument")
  main_name = sys.argv[2]
  del sys.argv[1:3] # remove the --main-name argument

  thirdpartydir = os.path.join(os.path.dirname(__file__), "../third_party")
  tracedir = os.path.join(thirdpartydir, "py_trace_event")

  # A recent change to py_trace_event leaves an old trace_event dir with .pyc files
  # hanging around. This prevents importing the new trace_event. Clobber it if it is found.
  tracedir_old_style_traceevent = os.path.join(tracedir, "trace_event")
  if os.path.exists(tracedir) and os.path.exists(tracedir_old_style_traceevent) and os.path.isdir(tracedir_old_style_traceevent):
    for root, dirs, files in os.walk(tracedir_old_style_traceevent, False, None, False):
      for f in files:
        os.unlink(os.path.join(root, f))
      for d in dirs:
        os.rmdir(os.path.join(root, d))
    os.rmdir(tracedir_old_style_traceevent)

  # Import trace event as usual.
  sys.path.append(tracedir)
  try:
    __import__("trace_event")
  except:
    print "Could not find py_trace_event. Did you forget 'git submodule update --init'"
    sys.exit(255)

  # Add paths for other third party modules
  sys.path.append(os.path.join(thirdpartydir, "python-daemon/daemon"))

  mod = __import__(main_name, {}, {}, True)
  import optparse<commit_msg>Print a helpful message if bootstrapping fails due to missing python-daemon.<commit_after># Copyright 2011 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import prelaunch_client
import os
import sys

def run(prelaunch=False):
  """Called by bootstrapper when the environment is ready to run."""
  if sys.argv[1] != '--main-name':
    raise Exception("launched wrong: expected --main-name <mainname> as first argument")
  main_name = sys.argv[2]
  del sys.argv[1:3] # remove the --main-name argument

  thirdpartydir = os.path.join(os.path.dirname(__file__), "../third_party")
  tracedir = os.path.join(thirdpartydir, "py_trace_event")

  # A recent change to py_trace_event leaves an old trace_event dir with .pyc files
  # hanging around. This prevents importing the new trace_event. Clobber it if it is found.
  tracedir_old_style_traceevent = os.path.join(tracedir, "trace_event")
  if os.path.exists(tracedir) and os.path.exists(tracedir_old_style_traceevent) and os.path.isdir(tracedir_old_style_traceevent):
    for root, dirs, files in os.walk(tracedir_old_style_traceevent, False, None, False):
      for f in files:
        os.unlink(os.path.join(root, f))
      for d in dirs:
        os.rmdir(os.path.join(root, d))
    os.rmdir(tracedir_old_style_traceevent)

  # Import trace event.
  sys.path.append(tracedir)
  try:
    __import__("trace_event")
  except:
    print "Could not find py_trace_event. Did you forget 'git submodule update --init'?"
    sys.exit(255)

  # Import python-daemon.
  sys.path.append(os.path.join(thirdpartydir, "python-daemon/daemon"))
  try:
    __import__("daemon")
  except:
    print "Could not find python-daemon. Did you forget 'git submodule update --init'?"
    sys.exit(255)

  mod = __import__(main_name, {}, {}, True)
  import optparse
{'fraction_non_alphanumeric': 0.10088415325323057, 'fraction_numerical': 0.007481296758104738, 'mean_word_length': 4.077100115074798, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '1019885', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1372, 'n_words': 460}