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