lindsay-stevens/limesurveyrc2api

Problem with import API

Closed this issue · 6 comments

Hello
i still have an issue importing Api subpackage even when installing manually the archive master
image
may @plascual knows more about it in its fork ?
Thank for your help
regards
Amaury

@AmauryVanEspen I've updated the PyPI package, it should install properly now (per #16). Also, there is a typo in the code screenshot, it should be from limesurveyrc2api.limesurvey import LimeSurvey not from limesurveyrc2api.limesurvey import Api.

Hello @lindsay-stevens
thank you for update,
i've fixed the typo from sample code,
then still facing some issue, it seems, related to the package

  
from limesurveyrc2api.limesurvey import LimeSurvey
import base64  # para encodear la subida de surveys


# Authentication
user = LIME_USER
key = LIME_KEY
url = LIME_API_URL

# Build the API
lime = LimeSurvey(url, user, key)

# SET TOKEN BASE and Survey
sid = LIME_SID
token = LIME_TOKEN_BASE

# GET data - token
export_res_token = lime.export_responses_by_token(sid, token)

# Insert in db
export_res = export_res_token

## Add Response
response_to_add = {}

# export_res export_res = lime.export_responses_by_token('999729', 'qdgb2bkiqgqwtvu')
if export_res is not None:
    decoded_string = base64.b64decode(export_res)
    with open("Output.json", "w") as text_file:
        text_file.write(decoded_string)

# get json object of surveys on the lime url
survey_res = lime.list_surveys(user)

# one can simply import json_normalize from pandas to normalize the json object
# from pandas.io.json import json_normalize
# survey_res_list = json_normalize(survey_res)

may could it be related to the get_session_key or something else,
undortunately, do not understand what the init() does that is not fulfiled properly

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-11-fe5802016243>](https://localhost:8080/#) in <module>
     11 
     12 # Build the API
---> 13 lime = LimeSurvey(url, user, key)
     14 
     15 # SET TOKEN BASE and Survey

TypeError: __init__() takes 3 positional arguments but 4 were given

There is still a typo in the code shared above. The LimeSurvey constructor takes only 2 input arguments: url and username. There is no key input argument. The correct usage is shown in the README.

When copying code into a GitHub comment, put it between 3 backticks so that it is formatted (see docs).

i'm going to dig a bit more, it seems the issue comes from something else, related to some missing function,
this function does not exist in your current package,

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-18-918f6135f6e4>](https://localhost:8080/#) in <module>
     18 
     19 # GET data - token
---> 20 export_res_token = lime.export_responses_by_token(sid, token)
     21 
     22 # Insert in db

AttributeError: 'LimeSurvey' object has no attribute 'export_responses_by_token

It seems like the code above was copied from "Hot Examples", which I am not associated with. That example code seems to be using fabiore/lime-py-api, which I am also not associated with.

you're right @lindsay-stevens
it comes from https://github.com/TaiSHiNet/lime-py-api by TaiSHiNet
sorry for mismatch