edgarrmondragon / citric Goto Github PK
View Code? Open in Web Editor NEWA client to the LimeSurvey Remote Control API 2, written in modern Python.
Home Page: https://citric.rtfd.io
License: MIT License
A client to the LimeSurvey Remote Control API 2, written in modern Python.
Home Page: https://citric.rtfd.io
License: MIT License
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_set_group_properties
The current workflow is to create a session object an then a client object from that:
from citric import Client, Session
with Session("http://myls.example.com", "iamadmin", "secret") as session:
client = Client(session)
# call methods on `client` ....
But this is rather cumbersome and the Session
low-level interface should not be exposed so I need to figure out a way to create a client without explicitly instantiating a session.
NA
Use environment variables to set the RPC URL, username and password.
NA
Work towards supporting the recent beta release of Python 3.10.
Documentation site
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_delete_group
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_list_groups
0.0.9
3.8
5.2.13+220207
linux
I have created dummy limesurvey docker under http://127.0.0.1:8082/index.php/admin/remotecontrol
with enabled JSON-RPC
I'm unable to connect using the Citric the authentication method is authdb for user admin
Do you have an
mlewkowicz@L192:~$ ./test.py
Traceback (most recent call last):
File "./test.py", line 7, in <module>
with Client(LS_URL, 'admin', 'AAAAAAAAAA') as client:
File "/home/mlewkowicz/.local/lib/python3.8/site-packages/citric/client.py", line 64, in __init__
self.__session = self.session_class(
File "/home/mlewkowicz/.local/lib/python3.8/site-packages/citric/session.py", line 60, in __init__
self.__key: Optional[str] = self.get_session_key(
File "/home/mlewkowicz/.local/lib/python3.8/site-packages/citric/method.py", line 42, in __call__
return self.__caller(self.__name, *params)
File "/home/mlewkowicz/.local/lib/python3.8/site-packages/citric/session.py", line 95, in rpc
result = self._invoke(self._session, self.url, method, *params)
File "/home/mlewkowicz/.local/lib/python3.8/site-packages/citric/session.py", line 132, in _invoke
res.raise_for_status()
File "/home/mlewkowicz/.local/lib/python3.8/site-packages/requests/models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://127.0.0.1:8082/index.php/admin/remotecontrol
the example file code:
mlewkowicz@L192:~$ cat test.py
#!/bin/env python3
from citric import Client
LS_URL = "http://127.0.0.1:8082/index.php/admin/remotecontrol"
with Client(LS_URL, 'admin', 'AAAAAAAAAA') as client:
surveys = client.list_surveys("admin")
it's the admin account
Improve the projects architecture and module layout
Create a Jupyter notebook with a few code samples.
RPC operations should be (securely) logged
I tried to login to the activated RemoteControl API and received the error saying the internal database authentification is not allowed for this user.
This makes sense, since I am trying to login via LDAP.
My question is:
Is it possible to use citric for LDAP acess to the API?
Best regards,
Matt
Other
Hi @edgarrmondragon,
i might have another use-case where im not sure how to implement it.
I want to export responses for specific tokens in an anonymous survey.
I tried client.session.export_responses_by_token
but i get the error that my survey (which can be called and stuff) does not have the field "token".
Reading the documentation from LS, i am not even sure what token i need to give the function (tokenID? the token to access the survey?)
I was wondering if my problem persists since its an anonymous survey and if you have any thoughts.
Best regards,
Matt
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_delete_question
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_export_timeline
Upload to readthedocs or Github Pages
It's really difficult to get XML-RPC requests right and there's a lack of documentation.
The following causes the API to respond with Fault 623: 'Calling parameters do not match signature'
:
import requests
from xmlrpc.client import dumps, loads
response = {'123456X180X357': 'Long text 1', '123456X180X358': '1', 'token': 'T00000'}
text = dumps((session.key, survey_id, response), methodname="add_response")
r = requests.post(LS_URL, data=text)
loads(r.text)
Add client method for list_users
.
Python 3.6 has reached end of life last month as of December 23rd, 2021.
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_set_question_properties
The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.
Add type annotations.
NA
Add static type checking with mypy
, pytype
or similar
0.0.6
3.9
4.6.3
MacOS
Users without Superadministrator
permission can not use the library because the Session
constructor tries to get the RPCInterface
setting, but it's restricted for them.
>>> import citric
>>> LS_URL = 'http://localhost:8001/index.php/admin/remotecontrol'
>>> with citric.Client(LS_URL, 'restricted-user', 'verysecret') as client:
... with open("./my_survey.lss", "rb") as f:
... client.import_survey(f, survey_name="example")
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/edgarramirez/Code/citric/src/citric/client.py", line 64, in __init__
self.__session = self.session_class(
File "/Users/edgarramirez/Code/citric/src/citric/session.py", line 68, in __init__
if self.get_site_settings("RPCInterface") != "json":
File "/Users/edgarramirez/Code/citric/src/citric/method.py", line 27, in __call__
return self.__caller(self.__name, *params)
File "/Users/edgarramirez/Code/citric/src/citric/session.py", line 103, in rpc
result = self._invoke(self._session, self.url, method, self.key, *params)
File "/Users/edgarramirez/Code/citric/src/citric/session.py", line 149, in _invoke
raise LimeSurveyStatusError(result["status"])
citric.exceptions.LimeSurveyStatusError: Invalid setting
The following set of permissions on a user triggers the error:
When the RPC result comes out as a "OK" status message an error is raised. This is unexpected behaviour since these messages mean the RPC executed fine.
>>> session.delete_survey(356948)
The code above raises LimeSurveyStatusError: OK
when the survey is deleted successfully.
Use Github Actions instead of Travis for CI/CD.
NA
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_add_language
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_get_question_properties
Set up release management and automation
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_set_participant_properties
Add a Docker Compose file to quickly setup a local LimeSurvey server for development.
N/A
New RPC client method
The import_question
allows the user to create a new question from a previously exported .lsq
file.
Method documentation: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_import_question
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_export_statistics
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Location: renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: autoMerge
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_get_language_properties
This issue provides visibility into Renovate updates and their statuses. Learn more
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_delete_language
API is bound to be very stable still.
NA
Add docstrings to code base and test docstring snippets
When the RPC API responds with an error code (500, etc.), raise an HTTPError
instead of causing an error when trying to process the response contents.
>>> session.delete_survey()
Use pyproject.toml
, poetry
and flit
to manage dependencies, builds, version upgrades, etc.
NA
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_set_language_properties
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_get_summary
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_add_survey
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_import_group
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_get_group_properties
Add a Python API to help with auto-completion, type annotations and wrappers for common things like encoding/decoding base64 strings.
NA
New RPC client method
Docs: https://api.limesurvey.org/classes/remotecontrol_handle.html#method_copy_survey
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.