Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def proxy():
xa.provider.set_proxy("socks5://127.0.0.1:1080")
yield
xa.provider.set_proxy()
def proxy():
xa.provider.set_proxy("socks5://127.0.0.1:1080")
yield
xa.provider.set_proxy()
import sys
sys.path.insert(0, "../")
import xalpha as xa
import pandas as pd
import pytest
import shutil
xa.provider.set_jq_data(debug=True)
@pytest.fixture
def csv_cache():
xa.set_backend(backend="csv", path="./")
yield
xa.set_backend(backend="memory", path="pytest-")
# 防止peb csv 数字位长反复变化
@pytest.fixture
def reset_table():
l = ["./peb-SH000807.csv", "./sw-801180.csv", "./teb-SH000300.csv"]
for f in l:
shutil.copyfile(f, f + ".backup")
yield
def wrapper(*args, **kws):
import xalpha.provider as xp
if getattr(xp, "proxy", None):
kws["proxies"] = {"http": xp.proxy, "https": xp.proxy}
kws["timeout"] = timeout
logger.debug("Using proxy %s" % xp.proxy)
if args:
url = args[0]
else:
url = kws.get("url", "")
headers = kws.get("headers", {})
if (not headers.get("user-agent", None)) and (
not headers.get("User-Agent", None)
):
headers["user-agent"] = "Mozilla/5.0"
kws["headers"] = headers
for count in range(tries):
try:
logger.debug(
def wrapper(*args, **kws):
import xalpha.provider as xp
if getattr(xp, "proxy", None):
kws["proxies"] = {"http": xp.proxy, "https": xp.proxy}
kws["timeout"] = timeout
logger.debug("Using proxy %s" % xp.proxy)
if args:
url = args[0]
else:
url = kws.get("url", "")
headers = kws.get("headers", {})
if (not headers.get("user-agent", None)) and (
not headers.get("User-Agent", None)
):
headers["user-agent"] = "Mozilla/5.0"
kws["headers"] = headers
for count in range(tries):
try:
logger.debug(
"Fetching url: %s . Inside function `%s`"
% (url, inspect.stack()[1].function)
)