def migrate(): print("logging in...") client = FrappeClient(HOST, USERNAME, PASSWORD) limit = 100 offset = 0 all_synced = True while (all_synced): employees_list = client.get_list('Employee', fields=['name', 'cnic_no'], filters={ 'name': '024232', 'status': 'Active', "image": ["<", "0"] }, limit_start=offset, limit_page_length=limit) if (len(employees_list) < limit): all_synced = False for employee in employees_list: try: emp = client.get_doc('Employee', employee["name"]) filename = "{0}.jpg".format(employee["cnic_no"]) img_str = get_base64_encoded_image( "source/pictures/{0}".format(filename)) if (img_str): file_path = upload_file(client=client, employee=employee["name"], filename=filename, filedata=img_str) if (file_path): emp = client.get_doc('Employee', employee["name"]) emp["image"] = file_path client.update(emp) except Exception as e: print('Failed to upload file for employee: {0} {1}'.format( employee["name"], e)) continue offset += limit