Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable backend/netcontrol communication #30

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open

Conversation

Ecnama
Copy link

@Ecnama Ecnama commented Oct 18, 2024

Description

This PR enables the backend to send requests to the netcontrol API via http.

Checklist

  • I have tested the changes locally and they work as expected.
  • I have tested the responsiveness of the changes and they work as expected.
  • I have assigned the pull request to the appropriate reviewer(s).
  • I have added labels to the pull request, if necessary.

@Ecnama Ecnama added enhancement New feature or request priority: emergency Back backend thing labels Oct 18, 2024
@Ecnama Ecnama self-assigned this Oct 18, 2024
@Ecnama Ecnama marked this pull request as draft October 18, 2024 18:20
@SkytAsul
Copy link
Member

Besoin de review maintenant ou bien la PR n'est pas terminée ?

@Ecnama
Copy link
Author

Ecnama commented Oct 19, 2024

Alors en théorie c'est terminé, mais les tests passent pas donc je les ai mal modifié j'imagine

@SkytAsul
Copy link
Member

Fix tout est quand c'est bon, marque la PR comme "ready for review"

Copy link
Member

@SkytAsul SkytAsul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En plus de tout ça, à tous les endroits où une méthode de netcontrol est appelée (i.e. netcontrol.connect_user(...) il faut wrap dans un try-except HTTPError et gérer les erreurs correctement.

backend/langate/modules/netcontrol.py Show resolved Hide resolved
Comment on lines 10 to 16
class RequestError(Exception):
"""
Exception raised when a request to the netcontrol API fails.
"""
def __init__(self, message):
self.message = message
super().__init__(self.message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le système d'erreur n'est plus pareil. Il faut supprimer cette classe trop générique.

Comment on lines 63 to 64
if response.json()["error"]:
raise RequestError(response.json()["error"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On utilisera les erreurs HTTP. Remplacer ces lignes par response.raise_for_status() qui lèvera automatiquement une HTTPError si jamais netcontrol a renvoyé une erreur 4xx ou 5xx.

@Ecnama Ecnama marked this pull request as ready for review October 21, 2024 06:10
Base automatically changed from upgrade-version to dev October 23, 2024 08:14
@Ecnama Ecnama removed a link to an issue Oct 25, 2024
@Ecnama Ecnama requested a review from SkytAsul October 26, 2024 14:51
@SkytAsul SkytAsul changed the base branch from dev to netcontrol October 27, 2024 20:51
@SkytAsul
Copy link
Member

SkytAsul commented Oct 27, 2024

Oula y'a un soucis de branches de base là
EDIT: ah OK y'a vraiment tout le backend netcontrol. Vous abusez pas un peu ce genre de PR monstrueuse là 😭

@SkytAsul SkytAsul changed the base branch from netcontrol to dev October 27, 2024 20:53
Copy link
Member

@pixup1 pixup1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs more documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Back backend thing enhancement New feature or request priority: emergency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Communication from backend to netcontrol Create netcontrol interface
3 participants