Example #1
0
def update_tool(req):
    """ update the tool from github """
    import datetime,time,dbhash,re
    from subprocess import Popen, PIPE
    (pwd, name,ip) = get_env(req)
    t = datetime.datetime.now()
    d = time.mktime(t.timetuple())
    rev = dbhash.open('%s/cg/rev.db'%ui.__BASE__,'w')
    allow,delta = False,0
    if rev.has_key('_update_'):
        delta = d - float(rev['_update_'])
        if delta > 120:
            rev['_update_'],allow = '%s'%d,True
    if not rev.has_key('_update_'):
        rev['_update_'] = '%s'%d
    rev.close()
    req.content_type = 'text/plain'  
    if not allow:
        return 'Error: Time since last update is %d secondes; should be greater than 2 minutes!'%int(delta)
    cmd = 'cd %s/..; rm -rf ConnectedGraph; git clone git://github.com/pelinquin/ConnectedGraph.git; cd ConnectedGraph; git submodule update --init'%pwd
    out,err = Popen((cmd), shell=True,stdout=PIPE, stderr=PIPE).communicate()
    o = 'Application Updating from %s %s...\n'%ui.get_id_pkg(req)
    if err:
        o += 'Error:%s\n'%err
    else:
        o += 'Message:%s\nUpdate OK\n'%out
    return o 
Example #2
0
def run_server(req=None):
    if req:
        req.content_type = 'text/plain'
    n,o = 0,''
    n1,o1 = utest(set_node,'node')
    n2,o2 = utest(set_type,'type')
    #...
    o += o1 + o2
    o += '%s tests cases\n'%(n1+n2)
    if req:
        o += 'Git Commit: %s %s'%ui.get_id_pkg(req)
    return o