Back to index

unity  6.0.0
unity.py
Go to the documentation of this file.
00001 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
00002 # Copyright 2012 Canonical
00003 # Author: Thomi Richards
00004 #
00005 # This program is free software: you can redistribute it and/or modify it
00006 # under the terms of the GNU General Public License version 3, as published
00007 # by the Free Software Foundation.
00008 #
00009 
00010 from __future__ import absolute_import
00011 
00012 from autopilot.emulators.dbus_handler import session_bus
00013 from dbus import Interface
00014 
00015 # acquire the debugging dbus object
00016 UNITY_BUS_NAME = 'com.canonical.Unity'
00017 DEBUG_PATH = '/com/canonical/Unity/Debug'
00018 LOGGING_IFACE = 'com.canonical.Unity.Debug.Logging'
00019 
00020 
00021 _debug_proxy_obj = session_bus.get_object(UNITY_BUS_NAME, DEBUG_PATH)
00022 _logging_iface = Interface(_debug_proxy_obj, LOGGING_IFACE)
00023 
00024 def start_log_to_file(file_path):
00025     """Instruct Unity to start logging to the given file."""
00026     _logging_iface.StartLogToFile(file_path)
00027 
00028 
00029 def reset_logging():
00030     """Instruct Unity to stop logging to a file."""
00031     _logging_iface.ResetLogging()
00032 
00033 
00034 def set_log_severity(component, severity):
00035     """Instruct Unity to set a log component's severity.
00036 
00037     'component' is the unity logging component name.
00038 
00039     'severity' is the severity name (like 'DEBUG', 'INFO' etc.)
00040 
00041     """
00042     _logging_iface.SetLogSeverity(component, severity)
00043 
00044 
00045 def log_unity_message(severity, message):
00046     """Instruct unity to log a message for us.
00047 
00048     severity: one of ('TRACE', 'DEBUG', 'INFO', 'WARNING', 'ERROR').
00049 
00050     message: The message to log.
00051 
00052     For debugging purposes only! If you want to log a message during an autopilot
00053     test, use the python logging framework instead.
00054 
00055     """
00056     _logging_iface.LogMessage(severity, message)
00057