示例#1
0
def do_get():
    if query_revision is not None:
        with CellProfilerContext():
            datetime_version, git_hash = get_version_and_githash(
                query_revision)
            buildstatus = is_built(version=datetime_version, git_hash=git_hash)
        print "Content-Type: application/json\r"
        print "\r"
        print json.dumps({
            GIT_HASH: git_hash,
            DATETIME_VERSION: datetime_version,
            IS_BUILT: buildstatus
        })
        return
    else:
        print "Content-Type: text/plain\r"
        print "\r"
        print """API for BuildCellProfiler.py

GET /?revision=<revision> HTTP/1.1

Look up the GIT hash and datetime version of a revision.

<revision> - a GIT treeish reference (tag, GIT hash, branch)

returns a JSON-encoded dictionary: 
{
    %(GIT_HASH)s:"<git-hash>",
    %(DATETIME_VERSION)s:"<datetime-version>",
    %(IS_BUILT)s:<true/false>,
}
<git-hash> - the full GIT hash of the reference 
<datetime-version> - the UTC time of the checkin in the format YYYYMMDDHHMMSS.

The value for %(IS_BUILT)s is true if the version of CellProfiler has been
built.

PUT /?revision=<revision> HTTP/1.1

(optional JSON dictionary = 
 {%(EMAIL)s:<email>:%(QUEUE)s:<queue>:%(PROJECT)s:<project>})

<email> - send user email when built
<queue> - run build on this queue
<project> - charge to this project

returns the same JSON-encoded dictionary as for GET
""" % globals()
def do_get():
    if query_revision is not None:
        with CellProfilerContext():
            datetime_version, git_hash = get_version_and_githash(query_revision)
            buildstatus = is_built(version=datetime_version, git_hash=git_hash)
        print "Content-Type: application/json\r"
        print "\r"
        print json.dumps(
            { GIT_HASH: git_hash, 
              DATETIME_VERSION: datetime_version,
              IS_BUILT: buildstatus
              })
        return
    else:
        print "Content-Type: text/plain\r"
        print "\r"
        print """API for BuildCellProfiler.py

GET /?revision=<revision> HTTP/1.1

Look up the GIT hash and datetime version of a revision.

<revision> - a GIT treeish reference (tag, GIT hash, branch)

returns a JSON-encoded dictionary: 
{
    %(GIT_HASH)s:"<git-hash>",
    %(DATETIME_VERSION)s:"<datetime-version>",
    %(IS_BUILT)s:<true/false>,
}
<git-hash> - the full GIT hash of the reference 
<datetime-version> - the UTC time of the checkin in the format YYYYMMDDHHMMSS.

The value for %(IS_BUILT)s is true if the version of CellProfiler has been
built.

PUT /?revision=<revision> HTTP/1.1

(optional JSON dictionary = 
 {%(EMAIL)s:<email>:%(QUEUE)s:<queue>:%(PROJECT)s:<project>})

<email> - send user email when built
<queue> - run build on this queue
<project> - charge to this project

returns the same JSON-encoded dictionary as for GET
""" % globals()
def do_put():
    datetime_version, git_hash = get_version_and_githash(query_revision)
    buildstatus = is_built(version=datetime_version, git_hash=git_hash)
    options = {}
    if not buildstatus:
        try:
            options = json.load(sys.stdin)
            assert isinstance(options, dict)
        except:
            pass
        with CellProfilerContext():
            build_cellprofiler(
                version=datetime_version,
                git_hash=git_hash,
                queue_name=options.get(QUEUE, None),
                group_name=options.get(PROJECT, None),
                email_address=options.get(EMAIL, None),
            )

    print "Content-Type: application/json\r"
    print "\r"
    print json.dumps({GIT_HASH: git_hash, DATETIME_VERSION: datetime_version, IS_BUILT: buildstatus})
示例#4
0
def do_put():
    datetime_version, git_hash = get_version_and_githash(query_revision)
    buildstatus = is_built(version=datetime_version, git_hash=git_hash)
    options = {}
    if not buildstatus:
        try:
            options = json.load(sys.stdin)
            assert isinstance(options, dict)
        except:
            pass
        with CellProfilerContext():
            build_cellprofiler(version=datetime_version,
                               git_hash=git_hash,
                               queue_name=options.get(QUEUE, None),
                               group_name=options.get(PROJECT, None),
                               email_address=options.get(EMAIL, None))

    print "Content-Type: application/json\r"
    print "\r"
    print json.dumps({
        GIT_HASH: git_hash,
        DATETIME_VERSION: datetime_version,
        IS_BUILT: buildstatus
    })