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