testing/mozbase/docs/mozinfo.rst

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 :mod:`mozinfo` --- Get system information
michael@0 2 =========================================
michael@0 3
michael@0 4 Throughout `mozmill <https://developer.mozilla.org/en/Mozmill>`_
michael@0 5 and other Mozilla python code, checking the underlying
michael@0 6 platform is done in many different ways. The various checks needed
michael@0 7 lead to a lot of copy+pasting, leaving the reader to wonder....is this
michael@0 8 specific check necessary for (e.g.) an operating system? Because
michael@0 9 information is not consolidated, checks are not done consistently, nor
michael@0 10 is it defined what we are checking for.
michael@0 11
michael@0 12 `mozinfo <https://github.com/mozilla/mozbase/tree/master/mozinfo>`_
michael@0 13 proposes to solve this problem. mozinfo is a bridge interface,
michael@0 14 making the underlying (complex) plethora of OS and architecture
michael@0 15 combinations conform to a subset of values of relevance to
michael@0 16 Mozilla software. The current implementation exposes relevant keys and
michael@0 17 values such as: ``os``, ``version``, ``bits``, and ``processor``. Additionally, the
michael@0 18 service pack in use is available on the windows platform.
michael@0 19
michael@0 20
michael@0 21 API Usage
michael@0 22 ---------
michael@0 23
michael@0 24 mozinfo is a python package. Downloading the software and running
michael@0 25 ``python setup.py develop`` will allow you to do ``import mozinfo``
michael@0 26 from python.
michael@0 27 `mozinfo.py <https://raw.github.com/mozilla/mozbase/master/mozinfo/mozinfo/mozinfo.py>`_
michael@0 28 is the only file contained is this package,
michael@0 29 so if you need a single-file solution, you can just download or call
michael@0 30 this file through the web.
michael@0 31
michael@0 32 The top level attributes (``os``, ``version``, ``bits``, ``processor``) are
michael@0 33 available as module globals::
michael@0 34
michael@0 35 if mozinfo.os == 'win': ...
michael@0 36
michael@0 37 In addition, mozinfo exports a dictionary, ``mozinfo.info``, that
michael@0 38 contain these values. mozinfo also exports:
michael@0 39
michael@0 40 - ``choices``: a dictionary of possible values for os, bits, and
michael@0 41 processor
michael@0 42 - ``main``: the console_script entry point for mozinfo
michael@0 43 - ``unknown``: a singleton denoting a value that cannot be determined
michael@0 44
michael@0 45 ``unknown`` has the string representation ``"UNKNOWN"``.
michael@0 46 ``unknown`` will evaluate as ``False`` in python::
michael@0 47
michael@0 48 if not mozinfo.os: ... # unknown!
michael@0 49
michael@0 50
michael@0 51 Command Line Usage
michael@0 52 ------------------
michael@0 53
michael@0 54 mozinfo comes with a command line program, ``mozinfo`` which may be used to
michael@0 55 diagnose one's current system.
michael@0 56
michael@0 57 Example output::
michael@0 58
michael@0 59 os: linux
michael@0 60 version: Ubuntu 10.10
michael@0 61 bits: 32
michael@0 62 processor: x86
michael@0 63
michael@0 64 Three of these fields, os, bits, and processor, have a finite set of
michael@0 65 choices. You may display the value of these choices using
michael@0 66 ``mozinfo --os``, ``mozinfo --bits``, and ``mozinfo --processor``.
michael@0 67 ``mozinfo --help`` documents command-line usage.
michael@0 68
michael@0 69
michael@0 70 .. automodule:: mozinfo
michael@0 71 :members:

mercurial