Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

beebox / crossover   deb

Repository URL to install this package:

Version: 18.5.0-1 

/ opt / cxoffice / lib / python / cxulog.py

# (c) Copyright 2012-2013. CodeWeavers, Inc.
#
# Handles usage logging

import os
import cxlog
import cxproduct


#####
#
# Usage logging
#
#####

def log_usage(s):
    """Append a string to the usage log."""
    cxconfig = cxproduct.get_config()
    if cxconfig['CrossOver'].get('ReportWineUsage', 1):
        # - Collect data if ReportWineUsage is either unset or '1'.
        #   Note that the collected data will only be sent by the reporting
        #   tool if that flag is '1'. The goal is just to not lose the data
        #   while the user makes up his mind.
        # - Delete all collected data if ReportWineUsage is '0', but not here,
        #   the wine script handles that.
        try:
            try:
                logfile_path = os.path.join(cxproduct.get_user_dir(), "usage.log")
                logfile = os.open(logfile_path, os.O_APPEND | os.O_WRONLY | os.O_CREAT)
                os.write(logfile, s)
            except OSError, e:
                cxlog.warn("I/O error trying to log '%s' to '%s': %s" % (s, logfile_path, e.strerror))
        finally:
            os.close(logfile)
    return