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
# coding: utf-8 | |
try: | |
import cPickle as pickle | |
except ImportError: | |
import pickle | |
try: | |
import hashlib | |
sha1 = hashlib.sha1 |
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 sys | |
from contextlib import contextmanager | |
import paramiko | |
sys.tracebacklimit = 0 | |
class FtpClient: |
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 os | |
import gnupg | |
def initialize_gpg(key_paths): | |
gpg = gnupg.GPG() | |
for path in key_paths: | |
key_data = open(path).read() | |
gpg.import_keys(key_data) | |
# return |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""Example of thread pool | |
https://docs.python.org/3/library/concurrent.futures.html | |
https://docs.python.org/3/library/multiprocessing.html | |
""" | |
import concurrent.futures as confu | |
import multiprocessing.pool as mpp | |
import time |
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 map_paramiko_log_methods(respective_method, module) -> None: | |
for each_class in map(module.__dict__.get, module.__all__): | |
if hasattr(each_class, '_log'): | |
each_class._log = respective_method | |
def log_wrapper(*args, **kwargs): | |
pass |
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
#!/usr/bin/env python | |
""" | |
mocking requests calls | |
""" | |
import mock | |
import unittest | |
import requests | |
from requests.exceptions import HTTPError |
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 calendar | |
import time | |
from datetime import timedelta, datetime | |
from aiobreaker import CircuitBreaker | |
from aiobreaker.state import STATE_CLOSED | |
from aiobreaker.storage.redis import CircuitRedisStorage | |
from functools import wraps | |
from configs.settings import CB_SETTINGS, CACHE_KEY_PREFIX | |
from helpers.cache_servers import RedisServer |
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
# -*- encoding:utf-8 -*- | |
from __future__ import print_function | |
class BSTNode(object): | |
def __init__(self, key, value=None, left=None, right=None): | |
self.key = key | |
self.value = value | |
self.left = left |
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 asyncio | |
from functools import wraps | |
def dec(fn): | |
@wraps(fn) | |
async def wrapper(*args, **kwargs): | |
print(fn, args, kwargs) # <function foo at 0x10952d598> () {} | |
await asyncio.sleep(5) |
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
version: '3' | |
services: | |
redis-1: | |
container_name: redis-1 | |
image: redis:latest | |
ports: | |
- 7000:7000 | |
- '7001:7001' | |
- '7002:7002' | |
- '7003:7003' |
OlderNewer