Back to index

enigmail  1.4.3
Classes | Functions
writemozinfo Namespace Reference

Classes

class  JsonValue

Functions

def build_dict
def jsonify
def write_json

Function Documentation

def writemozinfo.build_dict (   env = os.environ)
Build a dict containing data about the build configuration from
the environment.

Definition at line 11 of file writemozinfo.py.

00011 
00012 def build_dict(env=os.environ):
00013     """
00014     Build a dict containing data about the build configuration from
00015     the environment.
00016     """
00017     d = {}
00018     # Check that all required variables are present first.
00019     required = ["TARGET_CPU", "OS_TARGET", "MOZ_WIDGET_TOOLKIT"]
00020     missing = [r for r in required if r not in env]
00021     if missing:
00022         raise Exception("Missing required environment variables: %s" %
00023                         ', '.join(missing))
00024     # os
00025     o = env["OS_TARGET"]
00026     known_os = {"Linux": "linux",
00027                 "WINNT": "win",
00028                 "Darwin": "mac",
00029                 "Android": "android"}
00030     if o in known_os:
00031         d["os"] = known_os[o]
00032     else:
00033         # Allow unknown values, just lowercase them.
00034         d["os"] = o.lower()
00035 
00036     # Widget toolkit, just pass the value directly through.
00037     d["toolkit"] = env["MOZ_WIDGET_TOOLKIT"]
00038     
00039     # processor
00040     p = env["TARGET_CPU"]
00041     # for universal mac builds, put in a special value
00042     if d["os"] == "mac" and "UNIVERSAL_BINARY" in env and env["UNIVERSAL_BINARY"] == "1":
00043         p = "universal-x86-x86_64"
00044     else:
00045         # do some slight massaging for some values
00046         #TODO: retain specific values in case someone wants them?
00047         if p.startswith("arm"):
00048             p = "arm"
00049         elif re.match("i[3-9]86", p):
00050             p = "x86"
00051     d["processor"] = p
00052     # hardcoded list of 64-bit CPUs
00053     if p in ["x86_64", "ppc64"]:
00054         d["bits"] = 64
00055     # hardcoded list of known 32-bit CPUs
00056     elif p in ["x86", "arm", "ppc"]:
00057         d["bits"] = 32
00058     # other CPUs will wind up with unknown bits
00059 
00060     # debug
00061     d["debug"] = 'MOZ_DEBUG' in env and env['MOZ_DEBUG'] == '1'
00062 
00063     # crashreporter
00064     d["crashreporter"] = 'MOZ_CRASHREPORTER' in env and env['MOZ_CRASHREPORTER'] == '1'
00065     return d
00066 
#TODO: replace this with the json module when Python >= 2.6 is a requirement.

Here is the caller graph for this function:

def writemozinfo.jsonify (   d)
Return a JSON string of the dict |d|. Only handles a subset of Python
value types: bool, str, int, None.

Definition at line 82 of file writemozinfo.py.

00082 
00083 def jsonify(d):
00084     """
00085     Return a JSON string of the dict |d|. Only handles a subset of Python
00086     value types: bool, str, int, None.
00087     """
00088     jd = {}
00089     for k, v in d.iteritems():
00090         jd[k] = JsonValue(v)
00091     return repr(jd)

Here is the caller graph for this function:

def writemozinfo.write_json (   file,
  env = os.environ 
)
Write JSON data about the configuration specified in |env|
to |file|, which may be a filename or file-like object.
See build_dict for information about what  environment variables are used,
and what keys are produced.

Definition at line 92 of file writemozinfo.py.

00092 
00093 def write_json(file, env=os.environ):
00094     """
00095     Write JSON data about the configuration specified in |env|
00096     to |file|, which may be a filename or file-like object.
00097     See build_dict for information about what  environment variables are used,
00098     and what keys are produced.
00099     """
00100     s = jsonify(build_dict(env))
00101     if isinstance(file, basestring):
00102         with open(file, "w") as f:
00103             f.write(s)
00104     else:
00105         file.write(s)

Here is the call graph for this function:

Here is the caller graph for this function: