# Path: alibuild_helpers/cmd.py
# def getstatusoutput(command):
#   """Run command and return its return code and output (stdout and stderr)."""
#   kwargs = {} if sys.version_info.major < 3 else {"encoding": "utf-8"}
#   proc = Popen(command, shell=is_string(command), stdout=PIPE, stderr=STDOUT,
#                universal_newlines=True, **kwargs)
#   merged_output, _ = proc.communicate()
#   # Strip a single trailing newline, if one exists, to match the behaviour of
#   # subprocess.getstatusoutput.
#   if merged_output.endswith("\n"):
#     merged_output = merged_output[:-1]
#   return proc.returncode, merged_output
# 
# Path: alibuild_helpers/log.py
# def dieOnError(err, msg):
#   def __init__(self, fmtstr):
#   def format(self, record):
#   def __init__(self, begin_msg=""):
#   def __call__(self, txt, *args):
#   def erase(self):
#   def end(self, msg="", error=False):
# def log_banner(self, message, *args, **kws):
# def log_success(self, message, *args, **kws):
# class LogFormatter(logging.Formatter):
# class ProgressPrint:


import os, subprocess, sys
from os.path import exists, expanduser
from os import unlink
from alibuild_helpers.cmd import getstatusoutput
from alibuild_helpers.log import debug, banner
    return False
  return True

def askForAnalytics():
  banner("In order to improve user experience, aliBuild would like to gather "
         "analytics about your builds.\nYou can find all the details at:\n\n"
         "  https://github.com/alisw/alibuild/blob/master/ANALYTICS.md\n")
  # raw_input and input are different between python 2 and 3
  try: _input = raw_input
  except NameError: _input = input
  a = _input("Is that ok for you [YES/no]? ")
  if a.strip() and a.strip().lower().startswith("n"):
    debug("User requsted disabling analytics.")
    return disable_analytics()
  return generate_analytics_id()

# Helper function to decide whether or not we should run analytics.
# It's done this way so that we can easily test all the alternatives.
# This is the rationale to enable the analytics:
# - In case user disabled analytics via environment variable or by
#   answering no when prompted the first time. Just run as usual.
# - In case there is already an analytics user id, it means the user
#   already replied yes to the question wether he wants analytics or
#   not, so we proceed with analytics.
# - If we are not running in a tty, run without analytics.
# - In case there is no analytics id, ask wether is ok to have
#   analytics. If no, remember the answer and disable it. If yes,
#   generate a uuid with uuidgen and remember it.
def decideAnalytics(hasDisableFile, hasUuid, isTty, questionCallback):
  if hasDisableFile:

# Path: alibuild_helpers/cmd.py
# def getstatusoutput(command):
#   """Run command and return its return code and output (stdout and stderr)."""
#   kwargs = {} if sys.version_info.major < 3 else {"encoding": "utf-8"}
#   proc = Popen(command, shell=is_string(command), stdout=PIPE, stderr=STDOUT,
#                universal_newlines=True, **kwargs)
#   merged_output, _ = proc.communicate()
#   # Strip a single trailing newline, if one exists, to match the behaviour of
#   # subprocess.getstatusoutput.
#   if merged_output.endswith("\n"):
#     merged_output = merged_output[:-1]
#   return proc.returncode, merged_output
# 
# Path: alibuild_helpers/log.py
# def dieOnError(err, msg):
#   def __init__(self, fmtstr):
#   def format(self, record):
#   def __init__(self, begin_msg=""):
#   def __call__(self, txt, *args):
#   def erase(self):
#   def end(self, msg="", error=False):
# def log_banner(self, message, *args, **kws):
# def log_success(self, message, *args, **kws):
# class LogFormatter(logging.Formatter):
# class ProgressPrint:


# Path: alibuild_helpers/analytics.py
import os, subprocess, sys
from os.path import exists, expanduser
from os import unlink
from alibuild_helpers.cmd import getstatusoutput
from alibuild_helpers.log import debug, banner

    return False
  return True

def askForAnalytics():
  banner("In order to improve user experience, aliBuild would like to gather "
         "analytics about your builds.\nYou can find all the details at:\n\n"
         "  https://github.com/alisw/alibuild/blob/master/ANALYTICS.md\n")
  # raw_input and input are different between python 2 and 3
  try: _input = raw_input
  except NameError: _input = input
  a = _input("Is that ok for you [YES/no]? ")
  if a.strip() and a.strip().lower().startswith("n"):
    debug("User requsted disabling analytics.")
    return disable_analytics()
  return generate_analytics_id()

# Helper function to decide whether or not we should run analytics.
# It's done this way so that we can easily test all the alternatives.
# This is the rationale to enable the analytics:
# - In case user disabled analytics via environment variable or by
#   answering no when prompted the first time. Just run as usual.
# - In case there is already an analytics user id, it means the user
#   already replied yes to the question wether he wants analytics or
#   not, so we proceed with analytics.
# - If we are not running in a tty, run without analytics.
# - In case there is no analytics id, ask wether is ok to have
#   analytics. If no, remember the answer and disable it. If yes,
#   generate a uuid with uuidgen and remember it.
def decideAnalytics(hasDisableFile, hasUuid, isTty, questionCallback):
  if hasDisableFile:

    debug("Analytics previously disabled.")