This file contains 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 itertools import chain | |
import boto3 | |
from django.conf import settings | |
from tqdm import tqdm | |
sts = boto3.client( | |
service_name='sts', | |
aws_access_key_id=settings.AWS_STS_ACCESS_KEY_ID, |
This file contains 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 StringIteratorIO(io.TextIOBase): | |
""" | |
Creates file-like object from any string iterator (read-only, unicode only, no buffer) | |
""" | |
def __init__(self, iter: t.Iterator[str]): | |
self._iter = iter | |
self._left = '' | |
def readable(self): |
This file contains 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
processes = {} | |
pipe_r, pipe_w = os.pipe() | |
proc = subprocess.Popen( | |
[...], | |
stdout=pipe_w, | |
stderr=pipe_w | |
) | |
processes[proc] = pipe_r, pipe_w | |
def handle_output(processes: Dict[subprocess.Popen, Tuple[int, int]], timeout: float = 0): # int here - result from |
This file contains 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
#!python | |
# pylint: skip-file | |
import datetime | |
import json | |
import os | |
import pathlib | |
import threading | |
import signal | |
import sys | |
from collections import defaultdict |
This file contains 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 ax_format(ax): | |
ax.grid(which='minor', axis='x', dashes=(5, 5), linewidth=.5) | |
ax.grid(which='minor', axis='y', dashes=(5, 5), linewidth=.5) | |
ax.tick_params(axis='both', which='major', labelsize=14) | |
ax.tick_params(axis='both', which='minor', labelsize=8) | |
ax.xaxis.set_minor_formatter(tk.FormatStrFormatter("%.0f")) | |
ax.minorticks_on() | |
ax.legend() |
This file contains 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
@OpenAPI( | |
methods=['POST'], | |
request_model=SignupRequest, | |
request_mime_type=RequestBodyFormat.form_data, | |
responses={ | |
200: t.Union[SignupSuccessResponse, FormErrorResponse] | |
}, | |
error_response_callback=signup_error_response | |
) | |
def signup(request: HttpRequest, data: SignupRequest) -> HttpResponse: |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 time | |
from django.conf import settings | |
from django.db.backends import utils | |
truncate = 1000 | |
try: | |
import sqlparse | |
sqlparse_format_kwargs_defaults = dict( | |
reindent_aligned=True, | |
truncate_strings=500, |
This file contains 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 __future__ import absolute_import, unicode_literals | |
from django.conf import settings | |
from rest_framework import serializers as s | |
class ContextRequired(s.Field): | |
""" | |
Specify required data in serializer context |
This file contains 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 __future__ import absolute_import, unicode_literals, division, print_function | |
import logging | |
import os | |
import sentry_sdk | |
import six | |
import ujson as json | |
import jsonschema |
NewerOlder