1
Throughout [mozmill](https://developer.mozilla.org/en/Mozmill)
2
and other Mozilla python code, checking the underlying
3
platform is done in many different ways. The various checks needed
4
lead to a lot of copy+pasting, leaving the reader to wonder....is this
5
specific check necessary for (e.g.) an operating system? Because
6
information is not consolidated, checks are not done consistently, nor
7
is it defined what we are checking for.
9
[MozInfo](https://github.com/mozilla/mozbase/tree/master/mozinfo)
10
proposes to solve this problem. MozInfo is a bridge interface,
11
making the underlying (complex) plethora of OS and architecture
12
combinations conform to a subset of values of relavence to
13
Mozilla software. The current implementation exposes relavent key,
14
values: `os`, `version`, `bits`, and `processor`. Additionally, the
15
service pack in use is available on the windows platform.
20
MozInfo is a python package. Downloading the software and running
21
`python setup.py develop` will allow you to do `import mozinfo`
23
[mozinfo.py](https://github.com/mozilla/mozbase/blob/master/mozinfo/mozinfo.py)
24
is the only file contained is this package,
25
so if you need a single-file solution, you can just download or call
26
this file through the web.
28
The top level attributes (`os`, `version`, `bits`, `processor`) are
29
available as module globals:
31
if mozinfo.os == 'win': ...
33
In addition, mozinfo exports a dictionary, `mozinfo.info`, that
34
contain these values. mozinfo also exports:
36
- `choices`: a dictionary of possible values for os, bits, and
38
- `main`: the console_script entry point for mozinfo
39
- `unknown`: a singleton denoting a value that cannot be determined
41
`unknown` has the string representation `"UNKNOWN"`. unknown will evaluate
44
if not mozinfo.os: ... # unknown!
49
MozInfo comes with a command line, `mozinfo` which may be used to
50
diagnose one's current system.
59
Three of these fields, os, bits, and processor, have a finite set of
60
choices. You may display the value of these choices using
61
`mozinfo --os`, `mozinfo --bits`, and `mozinfo --processor`.
62
`mozinfo --help` documents command-line usage.