OLD | NEW |
(Empty) | |
| 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. |
| 8 |
| 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. |
| 16 |
| 17 |
| 18 # API Usage |
| 19 |
| 20 MozInfo is a python package. Downloading the software and running |
| 21 `python setup.py develop` will allow you to do `import mozinfo` |
| 22 from python. |
| 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. |
| 27 |
| 28 The top level attributes (`os`, `version`, `bits`, `processor`) are |
| 29 available as module globals: |
| 30 |
| 31 if mozinfo.os == 'win': ... |
| 32 |
| 33 In addition, mozinfo exports a dictionary, `mozinfo.info`, that |
| 34 contain these values. mozinfo also exports: |
| 35 |
| 36 - `choices`: a dictionary of possible values for os, bits, and |
| 37 processor |
| 38 - `main`: the console_script entry point for mozinfo |
| 39 - `unknown`: a singleton denoting a value that cannot be determined |
| 40 |
| 41 `unknown` has the string representation `"UNKNOWN"`. unknown will evaluate |
| 42 as `False` in python: |
| 43 |
| 44 if not mozinfo.os: ... # unknown! |
| 45 |
| 46 |
| 47 # Command Line Usage |
| 48 |
| 49 MozInfo comes with a command line, `mozinfo` which may be used to |
| 50 diagnose one's current system. |
| 51 |
| 52 Example output: |
| 53 |
| 54 os: linux |
| 55 version: Ubuntu 10.10 |
| 56 bits: 32 |
| 57 processor: x86 |
| 58 |
| 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. |
OLD | NEW |