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
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 | |
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 | |
pip install grpcio |
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
# syntax=docker/dockerfile:1 | |
FROM python:3.8-slim-buster | |
WORKDIR /app | |
ENV ACCEPT_EULA=Y | |
RUN apt-get update -y && apt-get update \ | |
&& apt-get install -y --no-install-recommends curl gcc g++ gnupg unixodbc-dev |
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 AttrDict(dict): | |
def __init__(self, *args, **kwargs): | |
super(AttrDict, self).__init__(*args, **kwargs) | |
self.__dict__ = self | |
config = AttrDict() | |
# Example | |
config['name'] |
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 boto3 | |
import logging | |
from botocore.exceptions import ClientError | |
class S3Imgs: | |
def __init__(self, aws_access_key_id, aws_secret_access_key, region_name): | |
"""S3 secrests config. |
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 logging | |
from http.client import HTTPConnection | |
def httpclient_logging(): | |
HTTPConnection.debuglevel = 1 | |
requests_log = logging.getLogger("urllib3") | |
requests_log.setLevel(logging.WARNING) |
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 clean_empty_or_none(d): | |
""" | |
Clean empty or None values from dict | |
""" | |
clean = {} | |
for k, v in d.items(): | |
if isinstance(v, dict): | |
nested = clean_empty_or_none(v) | |
if len(nested.keys()) > 0: | |
clean[k] = nested |
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 re | |
def validate_phone(phone): | |
if re.match(r'^\+1?\d{9,15}$', phone): | |
print(f'{phone} is valid number') | |
else: | |
print(f'{phone} is not valid') | |
NewerOlder