GithubHelp home page GithubHelp logo

edgarrmondragon / citric Goto Github PK

View Code? Open in Web Editor NEW
23.0 5.0 8.0 2.55 MB

A client to the LimeSurvey Remote Control API 2, written in modern Python.

Home Page: https://citric.rtfd.io

License: MIT License

Python 100.00%
limesurvey python survey

citric's Introduction

Hi there ๐Ÿ‘‹

GitHub stats

Top Langs

citric's People

Contributors

dependabot[bot] avatar edgarrmondragon avatar edgarrmondragon[bot] avatar fossabot avatar github-actions[bot] avatar pre-commit-ci[bot] avatar pyup-bot avatar renovate-bot avatar renovate[bot] avatar vianhazman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

citric's Issues

Create a client without first creating a session

  • Citric version:
  • Python version:
  • Operating System:

Description

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.

What I Did

NA

[Bug]: Unable to retrive session key by using the Citric

Citric Version

0.0.9

Python Version

3.8

LimeSurvey Version

5.2.13+220207

Operating System

linux

Description

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

Code

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")

Permissions Matrix

it's the admin account

Add logging

RPC operations should be (securely) logged

LDAP Login

  • Citric version: 0.0.5
  • Python version: 3.9
  • Operating System: Debian 11

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

export_responses_by_token for anonymous surveys

Feature Type

Other

Description

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

Remove XML-RPC support

  • Citric version:
  • Python version:
  • Operating System:

Description

It's really difficult to get XML-RPC requests right and there's a lack of documentation.

What I Did

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)

Initial Update

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

  • Citric version: 0.0.1
  • Python version: NA
  • Operating System: NA

Description

Add type annotations.

What I Did

NA

[Bug]: `LimeSurveyStatusError: Invalid setting` raised for users without Superadmin permission

Citric Version

0.0.6

Python Version

3.9

LimeSurvey Version

4.6.3

Operating System

MacOS

Description

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.

Code

>>> 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

Permissions Matrix

The following set of permissions on a user triggers the error:

Screen Shot 2022-01-27 at 23 18 18

Don't raise exceptions on status "OK"

  • Citric version: master
  • Python version: 3.8
  • Operating System: Ubuntu 20.04

Description

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.

What I Did

>>> session.delete_survey(356948)

The code above raises LimeSurveyStatusError: OK when the survey is deleted successfully.

Migrate to Github Actions

  • Limette version: NA
  • Python version: NA
  • Operating System: NA

Description

Use Github Actions instead of Travis for CI/CD.

What I Did

NA

Docker Compose

  • Limette version: any
  • Python version: any
  • Operating System: any

Description

Add a Docker Compose file to quickly setup a local LimeSurvey server for development.

What I Did

N/A

Action Required: Fix Renovate Configuration

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

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.


  • Check this box to trigger a request for Renovate to run again on this repository

Revamp and get a more stable API

  • Citric version: 0.0.1
  • Python version: NA
  • Operating System: NA

Description

API is bound to be very stable still.

What I Did

NA

Handle HTTP errors

  • Citric version: master
  • Python version: 3.8
  • Operating System: Ubuntu 20.04

Description

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.

What I Did

>>> session.delete_survey()

Use pyproject.toml

  • Limette version: all
  • Python version: all
  • Operating System: all

Description

Use pyproject.toml, poetry and flit to manage dependencies, builds, version upgrades, etc.

What I Did

NA

Python API

  • Citric version: NA
  • Python version: NA
  • Operating System: NA

Description

Add a Python API to help with auto-completion, type annotations and wrappers for common things like encoding/decoding base64 strings.

What I Did

NA

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.