示例#1
0
def export(request):
    dbsession = DBSession()
    root = dbsession.query(MyModel).filter(MyModel.name==u'root').first()
    auth = _get_basicauth_credentials(request)

    data = parseData(folderbase=REDIRECTIONS_PATH)

    entorns = [dict(id=int(a),entorn=data['entorns'][a]) for a in data['entorns'].keys()]
    instances = [data['instancies'][a] for a in data['instancies'].keys()]

    json_data_list = []
    for ins in instances:
        if len(ins['urls'])>0:
            url = ins['urls'][0]['gwurl'].replace('https','http')
        json_data = dict(url=url,
                         zeoport=ins['zeoport'],
                         debugport=ins['debugport'],
                         mountpoint=ins['mountpoint'],
                         plonesite=ins['plonesite'],
                         title=ins['title'],
                         entorn=ins['entorn'],
                         )
        json_data_list.append(json_data)

    response = Response(json.dumps(json_data_list))
    response.content_type = 'application/json'
    return response
示例#2
0
def main(request):
    dbsession = DBSession()
    root = dbsession.query(MyModel).filter(MyModel.name==u'root').first()
    auth = _get_basicauth_credentials(request)
    if auth:
        rsaparam = '-i ~/rsa/%(login)s.rsa' %  (auth)
    else:
        rsaparam = ''
    data = parseData(folderbase=REDIRECTIONS_PATH)

    entorns = [dict(id=int(a),entorn=data['entorns'][a]) for a in data['entorns'].keys()]
    instancies = [data['instancies'][a] for a in data['instancies'].keys()]
    
    returndict = {'root':root, 'project':'Genweb Manager','rsaparam':rsaparam}
    returndict['entorns']=sorted(entorns,key=lambda entorn:entorn['id'])
    returndict['instancies']=sorted(instancies,key=lambda instancia:instancia['title'])
    return returndict
示例#3
0
def purge(request):
    dbsession = DBSession()
    root = dbsession.query(MyModel).filter(MyModel.name==u'root').first()
    
    import telnetlib

    telnetport = request.GET.get('telnetport',None)
        
    value = {'result':False}

    if telnetport:
      try:   
          tn = telnetlib.Telnet('sylar.upc.es',int(telnetport))
          tn.write("purge.url .*\n") 
          tn.close()        
          value['result']=True
      except:
          pass

    response = Response(json.dumps(value))
    response.content_type = 'application/json'
    return response