coalib.output.dbus package

Submodules

coalib.output.dbus.BuildDbusService module

class coalib.output.dbus.BuildDbusService.BuildDbusService(dist)

Bases: distutils.cmd.Command

Add a build_dbus command to your setup.py. To use this Command class add a command to call this class:

# For setuptools
setup(
      entry_points={
        "distutils.commands": [
            "build_dbus = "
            "coalib.misc.BuildDbusService:BuildDbusService"
        ]
      }
)

# For distutils
from coalib.misc.BuildDbusService import BuildDbusService
setup(
      cmdclass={'build_dbus': BuildDbusService}
)

You can then use the following setup command to produce a dbus service:

$ python setup.py build_dbus
finalize_options()
initialize_options()
run()
user_options = [('output=', 'O', 'output file')]

coalib.output.dbus.DbusApp module

class coalib.output.dbus.DbusApp.DbusApp(app_id, name='')

Bases: object

Stores data about each client that connects to the DbusServer

create_document(path)

Create a new dbus document.

Parameters:
  • path – The path to the document to be created.
  • object_path – The dbus object path to use as the base for the document object path.
  • object_path – The connection to which the new ddocument object path should be added.
Returns:

a DbusDocument object.

dispose_document(path)

Dispose of the document with the given path. It fails silently if the document does not exist. If there are no more documents in the app, the app is disposed.

Parameters:path – The path to the document.

coalib.output.dbus.DbusDocument module

class coalib.output.dbus.DbusDocument.DbusDocument(doc_id, path='')

Bases: dbus.service.Object

Analyze()

This method analyzes the document and sends back the result

Returns:The output is structure which has 3 items: - The exitcode from the analysis. - List of logs from the analysis. - List of information about each section that contains:
  • The name of the section.
  • Boolean which is true if all bears in the section executed successfully.
  • List of results where each result is a string dictionary which contains: id, origin, message, file, line_nr, severity
FindConfigFile()

This method uses the path of the document to identify a user config file for it

Returns:The config file path
GetConfigFile()

This method gets the config file which is being used

Returns:The config path which is being used
SetConfigFile(config_file)

This method sets the config file to use. It has to be an absolute path, as otherwise it is difficult to find it.

Parameters:config_file – The path fo the config file to use. This has to be an absolute path
Returns:The config path which has been used
interface = 'org.coala_analyzer.v1'
path
static results_to_dbus_struct(section_result, section_name)

Converts the result tuple given by execute_section() - which has dictionaries and classes inside it - into a purely array based format as dbus protocol only allows arrays.

Parameters:
  • section_result – The result tuple given by execute_section() for a section
  • section_name – The name of the section
Returns:

The result for a section in the form of an array which is sendable through dbus.

coalib.output.dbus.DbusServer module

class coalib.output.dbus.DbusServer.DbusServer(bus, path, on_disconnected=None)

Bases: dbus.service.Object

CreateDocument(path, sender=None)

Creates a DbusDocument if it doesn’t exist.

Parameters:
  • path – The path to the document.
  • sender – The client who created the dbus request - this is used as the DbusApp’s name.
Returns:

a DbusDocument object.

DisposeDocument(path, sender=None)

Disposes a DbusDocument if it exists. Fails silently if it does not exist.

Parameters:
  • path – The path to the document.
  • sender – The client who created the dbus request - this is used as the DbusApp’s name to search for the document in.
create_app(appname)

Create a new dbus app with the given appname.

Parameters:appname – The name of the app to be created.
Returns:a DbusApp object.
create_document(app, path)

Create a new dbus document.

Parameters:
  • app – The DbusApp the document is related to.
  • path – The path to the document to be created.
Returns:

a DbusDocument object.

dispose_app(appname)

Dispose of the app with the given name. It fails silently if the app does not exist. If there are no more apps connected to the server, it calls the on_disconnected callback.

Parameters:appname – The name of the app to dispose of.
dispose_document(app, path)

Dispose of the document with the given path. It fails silently if the document does not exist. If there are no more documents in the app, the app is disposed.

Parameters:
  • app – The DbusApp the document is under.
  • path – The path to the document.
get_or_create_app(appname)

Get the dbus app with the given appname. If there does not exist any app with the given name, a new app is created and returned.

Parameters:appname – The name of the app to be created.
Returns:A DbusApp object.
get_or_create_document(app, path)

Get the dbus document with the given path. If there does not exist any document under the DbusApp with the given path, a new document is created and returned.

Parameters:
  • app – The DbusApp the document is under.
  • path – The path to the document to be created.
Returns:

A DbusApp object.

interface = 'org.coala_analyzer.v1'

Module contents

This package holds dbus related objects. Dbus objects are used to communicate between coala and other applications using dbus.

All dbus clients will first connect to the DbusServer, and request the DbusServer to create documents which can be analyzed. The DbusServer internally handles different clients separately so that it is possible for multiple clients to connect simultaneously. Once the client creates a document, the object path of the document is returned and the client can use it to analyze the document (which happens in the DbusDocument.