<commit_before>import os
import platform
import urllib
import urllib2
import glob
import time
import sys
import subprocess
import string

def get_timestamp():
  print(time.time())

def install_dumpling():
  try:
    if (not os.path.isfile(dumplingPath)):
      url = "https://dumpling.azurewebsites.net/api/client/dumpling.py"
      scriptPath = os.path.dirname(os.path.realpath(__file__))
      downloadLocation = scriptPath + "/dumpling.py"
      response = urllib2.urlopen(url)
      if response.getcode() == 200:
        with open(downloadLocation, 'w') as f:
          f.write(response.read())
        subprocess.call([sys.executable, downloadLocation, "install", "--update"])
      else:
        raise urllib2.URLError("HTTP Status Code" + str(result.getcode()))

    subprocess.call([sys.executable, dumplingPath, "install"])
  except urllib2.HTTPError, e:
    print("Dumpling cannot be installed due to: " + str(e).replace(':', '')) # Remove : to avoid looking like error format
  except  urllib2.URLError, e:
    print(e.reason)
  except:
    print("An unexpected error was encountered while installing dumpling.py: " + sys.exc_info()[0])

def ensure_installed():
  if (not os.path.isfile(dumplingPath)):
    print("Dumpling has not been installed yet. Please run \"DumplingHelper.py install_dumpling\" before collect_dumps.")
    return False
  else:
    return True

def find_latest_dump(folder, startTimeStr):
  startTime = float(startTimeStr)
  globPattern = "/*";

  # Outside of Windows, core files are generally dumped into the executable's directory,
  # so it may have many other files in it. Filter those out.
  if sys.platform != "win32":
    globPattern = "/*core*"

  allFiles = glob.glob(folder + globPattern);
  if allFiles:
    latestFile = max(allFiles, key=os.path.getmtime)
    latestTime = os.path.getmtime(latestFile)
    if (latestTime > startTime):
      return latestFile
  return None

def collect_dump(exitcodeStr, folder, startTimeStr, projectName, incpaths):
  exitcode = int(exitcodeStr)

  if (exitcode == 0):
    sys.exit(exitcode)
<commit_msg>using traceback (#1972)<commit_after>import os
import platform
import urllib
import urllib2
import glob
import time
import sys
import subprocess
import string
import traceback

def get_timestamp():
  print(time.time())

def install_dumpling():
  try:
    if (not os.path.isfile(dumplingPath)):
      url = "https://dumpling.azurewebsites.net/api/client/dumpling.py"
      scriptPath = os.path.dirname(os.path.realpath(__file__))
      downloadLocation = scriptPath + "/dumpling.py"
      response = urllib2.urlopen(url)
      if response.getcode() == 200:
        with open(downloadLocation, 'w') as f:
          f.write(response.read())
        subprocess.call([sys.executable, downloadLocation, "install", "--update"])
      else:
        raise urllib2.URLError("HTTP Status Code" + str(result.getcode()))

    subprocess.call([sys.executable, dumplingPath, "install"])
  except urllib2.HTTPError, e:
    print("Dumpling cannot be installed due to: " + str(e).replace(':', '')) # Remove : to avoid looking like error format
  except  urllib2.URLError, e:
    print(e.reason)
  except:
    print("An unexpected error was encountered while installing dumpling.py: " + traceback.format_exc())

def ensure_installed():
  if (not os.path.isfile(dumplingPath)):
    print("Dumpling has not been installed yet. Please run \"DumplingHelper.py install_dumpling\" before collect_dumps.")
    return False
  else:
    return True

def find_latest_dump(folder, startTimeStr):
  startTime = float(startTimeStr)
  globPattern = "/*";

  # Outside of Windows, core files are generally dumped into the executable's directory,
  # so it may have many other files in it. Filter those out.
  if sys.platform != "win32":
    globPattern = "/*core*"

  allFiles = glob.glob(folder + globPattern);
  if allFiles:
    latestFile = max(allFiles, key=os.path.getmtime)
    latestTime = os.path.getmtime(latestFile)
    if (latestTime > startTime):
      return latestFile
  return None

def collect_dump(exitcodeStr, folder, startTimeStr, projectName, incpaths):
  exitcode = int(exitcodeStr)

  if (exitcode == 0):
    sys.exit(exitcode)

{'fraction_non_alphanumeric': 0.11642857142857142, 'fraction_numerical': 0.0064285714285714285, 'mean_word_length': 3.8792102206736354, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2894466', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1315, 'n_words': 356}