Ejemplo n.º 1
0
def CreateTrackerDirIfNeeded():
    """Looks up or creates the gsutil tracker file directory.

  This is the configured directory where gsutil keeps its resumable transfer
  tracker files. This function creates it if it doesn't already exist.

  Returns:
    The pathname to the tracker directory.
  """
    tracker_dir = config.get(
        'GSUtil', 'resumable_tracker_dir',
        os.path.join(GetGsutilStateDir(), 'tracker-files'))
    CreateDirIfNeeded(tracker_dir)
    return tracker_dir
Ejemplo n.º 2
0
def CheckAndMaybePromptForAnalyticsEnabling():
    """Asks a user to opt-in to data collection if a UUID file does not exist.

  If the user agrees, generates a UUID file. Will not prompt if part of SDK.
  """
    disable_prompt = boto.config.get_value('GSUtil',
                                           'disable_analytics_prompt')
    if not os.path.exists(
            _UUID_FILE_PATH) and not disable_prompt and not os.environ.get(
                'CLOUDSDK_WRAPPER'):
        enable_analytics = raw_input('\n' + textwrap.fill(
            'gsutil developers rely on user feedback to make improvements to the '
            'tool. Would you like to send anonymous usage statistics to help '
            'improve gsutil? [y/N]') + ' ')
        if enable_analytics.lower()[0] == 'y':
            CreateDirIfNeeded(os.path.dirname(_UUID_FILE_PATH))
            with open(_UUID_FILE_PATH, 'w') as f:
                cid = uuid.uuid4().hex
                f.write(cid)