#
# Copyright (c) 2005-2007 rPath, Inc.
#
# All Rights Reserved
#

import sys

statuses = {
    'UNKNOWN'  : -1,
    'WAITING'  : 0,
    'RUNNING'  : 100,
    'BUILT'    : 200,
    'FINISHED' : 300,
    'FAILED'   : 301,
    'ERROR'    : 301,
    'NO_JOB'   : 401
    }

sys.modules[__name__].__dict__.update(statuses)
statusNames = dict([(statuses[x[0]], x[0].capitalize().replace('_', ' ')) \
                        for x in statuses.iteritems()])

stautsCodeNames = dict([(x[1], 'STATUS_' + x[0].replace('_', '')) \
                            for x in statuses.iteritems()])

STATUSES = statuses.keys()

statusCodeNames = {
    UNKNOWN:  "STATUS_UNKNOWN",
    WAITING: "STATUS_WAITING",
    RUNNING: "STATUS_RUNNING",
    FINISHED: "STATUS_FINISHED",
    DELETED: "STATUS_DELETED",
    ERROR: "STATUS_ERROR",
    NOJOB: "STATUS_NOJOB",
}

# code generator run by make to generate javascript constants
# should only be run by the makefile in mint/web/content/javascript
def codegen():
    s = "// this Javascript was generated by mint/jobstatus.py\n"
    s += "// do not edit or check into source control\n"

    s += "var statusNames = {"
    i = []
    for k, v in statusNames.items():
        i.append("    '%d':  '%s'" % (k, v,))
    s += ", ".join(i)
    s += "};"

    for k, v in statusCodeNames.items():
        s += "var %s = %d;\n" % (v, k,)
    return s


if __name__ == "__main__": #pragma: no cover
    import sys
    if len(sys.argv) > 1 and sys.argv[1] == "--genjs":
        print codegen()
        sys.exit(0)
    else:
        sys.exit(1)

#
# Copyright (c) 2005-2007 rPath, Inc.
#
# All Rights Reserved
#

import sys

statuses = {
    'UNKNOWN'  : -1,
    'WAITING'  : 0,
    'RUNNING'  : 100,
    'BUILT'    : 200,
    'FINISHED' : 300,
    'FAILED'   : 301,
    'ERROR'    : 301,
    'NO_JOB'   : 401
    }

sys.modules[__name__].__dict__.update(statuses)
statusNames = dict([(statuses[x[0]], x[0].capitalize().replace('_', ' ')) \
                        for x in statuses.iteritems()])

statusCodeNames = dict([(x[1], 'STATUS_' + x[0].replace('_', '')) \
                            for x in statuses.iteritems()])

STATUSES = statuses.keys()

# code generator run by make to generate javascript constants
# should only be run by the makefile in mint/web/content/javascript
def codegen():
    s = "// this Javascript was generated by mint/jobstatus.py\n"
    s += "// do not edit or check into source control\n"

    s += "var statusNames = {"
    i = []
    for k, v in statusNames.items():
        i.append("    '%d':  '%s'" % (k, v,))
    s += ", ".join(i)
    s += "};"

    for k, v in statusCodeNames.items():
        s += "var %s = %d;\n" % (v, k,)
    return s


if __name__ == "__main__": #pragma: no cover
    import sys
    if len(sys.argv) > 1 and sys.argv[1] == "--genjs":
        print codegen()
        sys.exit(0)
    else:
        sys.exit(1)

remove bogus settings. fix typo.