Exemplo n.º 1
0
def update():
    #update function updates only coordinates of objact that is already in db but to do that it has to know id
    # of object to identyfie it so it updates only existing objects.
    Cat = raw_input('Name of catalogue: ')
    r = requests.get('http://127.0.0.1:8000/endpoint/catalogueInfo',params={'catalogue':Cat,'format':'json'})
    length = int(json.loads(r.text)['size'])
    it = int(json.loads(r.text)['count']) - 1
    print(str(round(float(it)/float(length),4)*100) + ' %')
    while it < length:
        it +=1
        Status = status_code_raw()
        if Status == 200:
            try:
                Data = Composer(Cat, it)
                print(Data.__unicode__())
                PK = PKGet(Data.__unicode__()).send()
                coors = Data.get_data()['data']['declination']
                print(PK, ' ', coors)
                C = CoorsSender(coors,PK)
                C.send()
            except StandardError:
                pass
        else:
            print('Server not reachable')
            break
Exemplo n.º 2
0
def run():
    # Function Updates all data for given object in db but object is recognized by it's coordinates
    #  so to update coordinates you have to use update function
    Cat = raw_input('Name of catalogue: ')
    r = requests.get('http://127.0.0.1:8000/endpoint/catalogueInfo',params={'catalogue':Cat,'format':'json'})
    length = int(json.loads(r.text)['size'])
    it = int(json.loads(r.text)['count'])
    print(str(round(float(it)/float(length),4)*100) + ' %')
    while it < length:
        it +=1
        Status = status_code_raw()
        if Status == 200:
            try:
                Data = Composer(Cat, it)
                print(Data.__unicode__())

                LocalSender(Data.get_data()).send()
            except StandardError:
                pass
        else:
            print('Server not reachable')
            break