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 | |
import logging | |
from multiprocessing import Process | |
g_proxy_addr = '' | |
g_proxy_port = 0 | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) |
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 project.strategies import container as strategies_container | |
from project.schemas import ScorePlayload | |
from altron.http import response, abort | |
from flask import request | |
@app.route('/strategies/<strategy>') | |
def get_strategy(strategy): | |
if strategies_container.has(strategy): | |
strategy = strategies_container.get(strategy) | |
else: | |
error = 'Неизвестное имя стратегии: ' + strategy |
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 -*- | |
import urllib.request | |
import os | |
import gzip | |
import lxml.etree | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import time | |
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
import functools | |
import itertools | |
import time | |
def timing(f): | |
def wrap(*args): | |
time1 = time.time() | |
ret = f(*args) | |
time2 = time.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
import asyncio | |
import json | |
import itertools | |
import sys | |
import time | |
MSG = dict( | |
job_id='1111111111111', | |
job_type='my_type', |
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 struct | |
import socket | |
def ip2int(addr): | |
return struct.unpack("!I", socket.inet_aton(addr))[0] | |
def int2ip(addr): | |
return socket.inet_ntoa(struct.pack("!I", addr)) |
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 mac_in_range(first_mac, last_mac, checking_mac): | |
first_int = int(first_mac.translate(None, ":.- "), 16) | |
last_int = int(last_mac.translate(None, ":.- "), 16) | |
checking_int = int(checking_mac.translate(None, ":.- "), 16) | |
if checking_int > first_int and checking_int < last_int: | |
return True | |
else: | |
return False | |
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 -*- | |
import ConfigParser | |
def parse_conf(conf_file_path): | |
""" | |
Функция парсинга конфиг файла | |
одноименные ключи будут затерты, будет взят последний | |
:param conf_file_path: путь до файла | |
: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
необходимо реализовать функцию, которая: | |
- на вход получает список, содержащий int элементы, в произвольной последовательности | |
- возвращает строку содержащую элементы списка через запятую, при этом | |
- следующие друг за другом элементы заменяются "-" | |
пример доктест скрипта для функции (предположим, что вы назвалии ее foo): | |
doctest: | |
>>> l = [10,7,8,9,1,2,3,5,99] | |
>>> s = foo(l) |
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
1) Что выведет следующий код: | |
>>> a = dict(one=1, two=2, three=3) | |
>>> keys = a.keys() | |
>>> a['four']=4 | |
>>> print(keys) | |
2) Что выведет следующий код: | |
>>> def f(*args, **kwargs): |
NewerOlder