This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.mixins import AccessMixin | |
from django.shortcuts import redirect | |
class UserIsStaffRequired(AccessMixin): | |
"""Verify that the current user is staff member.""" | |
def dispatch(self, request, *args, **kwargs): | |
if not request.user.is_authenticated : | |
return self.handle_no_permission() | |
else: | |
if not request.user.is_staff : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mimetypes | |
from django import forms | |
from django.core import validators | |
class CsvFileField(forms.FileField): | |
def validate(self, value): | |
super().validate(value) | |
file_mime = mimetypes.guess_type(value) | |
if file_mime != 'text/csv': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from api_v1.models import Notification | |
class NotificationMiddleware: | |
def __init__(self, get_response): | |
self.get_response = get_response | |
# One-time configuration and initialization. | |
def __call__(self, request): | |
# Code to be executed for each request before | |
# the view (and later middleware) are called. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, escape, url_for, request, redirect, session | |
from werkzeug.utils import secure_filename | |
#Instancier une application Flask | |
app = Flask(__name__) | |
# Set the secret key to some random bytes. Keep this really secret! | |
app.secret_key = b'_5#y2L"F4Q8z\n\xec]/' | |
########################## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import pika | |
import configparser | |
LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) ' | |
'-35s %(lineno) -5d: %(message)s') | |
LOGGER = logging.getLogger(__name__) | |
class RabbitmqManager: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Blueprint, request | |
from werkzeug.utils import secure_filename | |
from pandas import pandas as pd | |
from flask_cors import cross_origin | |
import os | |
import uuid | |
from .. import config | |
bp = Blueprint("process", __name__, url_prefix='/process') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread, Event | |
event = Event() | |
def worker(number, outputs, exit_code): | |
msg = "=== Table de mulitiplication par {}".format(number) | |
outputs.append(msg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FileVideoStream: | |
def __init__(self, path, workers=6, queue_size=128): | |
# Get number of frame | |
self.nb_frame = imutils.video.count_frames(path) | |
# Compute number of frame per workers | |
self.bias = math.ceil(self.nb_frame / workers) | |
# self.stream = cv2.VideoCapture(path) | |
self.streams = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validation_required(validator_function): | |
def decorator(function): | |
async def error(websocket, err): | |
await websocket.send(err) | |
async def wrapper(websocket, data): | |
status, err = validator_function(data) | |
if status: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from keras.preprocessing.image import ImageDataGenerator | |
from keras.models import Sequential | |
from keras.layers import Conv2D, MaxPooling2D, Dropout, Flatten, Dense, Activation, BatchNormalization | |
from sklearn.model_selection import train_test_split | |
import matplotlib.pyplot as plt | |
import os | |
OlderNewer