datamarket 0.8.0__py3-none-any.whl → 0.8.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of datamarket might be problematic. Click here for more details.
- datamarket/interfaces/proxy.py +4 -6
- datamarket/utils/main.py +14 -5
- {datamarket-0.8.0.dist-info → datamarket-0.8.2.dist-info}/METADATA +1 -1
- {datamarket-0.8.0.dist-info → datamarket-0.8.2.dist-info}/RECORD +6 -6
- {datamarket-0.8.0.dist-info → datamarket-0.8.2.dist-info}/LICENSE +0 -0
- {datamarket-0.8.0.dist-info → datamarket-0.8.2.dist-info}/WHEEL +0 -0
datamarket/interfaces/proxy.py
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
# IMPORTS
|
|
3
3
|
|
|
4
4
|
import logging
|
|
5
|
-
import time
|
|
6
5
|
import random
|
|
6
|
+
import time
|
|
7
7
|
|
|
8
8
|
import requests
|
|
9
9
|
from stem import Signal
|
|
@@ -45,7 +45,7 @@ class ProxyInterface:
|
|
|
45
45
|
proxy_url = self.get_proxy_url("127.0.0.1", 9050)
|
|
46
46
|
else:
|
|
47
47
|
current_host, current_port = self.get_random_host_port() if randomize else self.get_current_host_port()
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
user = self.config.get("user")
|
|
50
50
|
password = self.config.get("password")
|
|
51
51
|
use_socks = self.config.get("socks", "false").lower() == "true"
|
|
@@ -67,14 +67,12 @@ class ProxyInterface:
|
|
|
67
67
|
def get_random_host_port(self):
|
|
68
68
|
hosts = self.config["hosts"].split(",") if isinstance(self.config["hosts"], str) else self.config["hosts"]
|
|
69
69
|
host_port_pairs = [hp.split(":") for hp in hosts]
|
|
70
|
-
self.current_index = random.randint(0, len(host_port_pairs) - 1)
|
|
70
|
+
self.current_index = random.randint(0, len(host_port_pairs) - 1) # noqa: S311
|
|
71
71
|
return host_port_pairs[self.current_index]
|
|
72
72
|
|
|
73
73
|
def check_current_ip(self):
|
|
74
74
|
try:
|
|
75
|
-
return requests.get(self.CHECK_IP_URL, proxies=self.proxies).json()[
|
|
76
|
-
"YourFuckingIPAddress"
|
|
77
|
-
]
|
|
75
|
+
return requests.get(self.CHECK_IP_URL, proxies=self.proxies, timeout=30).json()["YourFuckingIPAddress",]
|
|
78
76
|
except Exception as ex:
|
|
79
77
|
logger.error(ex)
|
|
80
78
|
|
datamarket/utils/main.py
CHANGED
|
@@ -25,7 +25,7 @@ logger = logging.getLogger(__name__)
|
|
|
25
25
|
|
|
26
26
|
def get_granular_date(
|
|
27
27
|
granularity: Union[Literal["monthly", "biweekly", "weekly", "daily"], str], tz: str = "Europe/Madrid"
|
|
28
|
-
) ->
|
|
28
|
+
) -> pendulum.DateTime:
|
|
29
29
|
"""
|
|
30
30
|
Returns the most recent date based on the given granularity or a custom cron expression.
|
|
31
31
|
|
|
@@ -52,7 +52,7 @@ def get_granular_date(
|
|
|
52
52
|
|
|
53
53
|
try:
|
|
54
54
|
cron = croniter(cron_pattern, now)
|
|
55
|
-
return cron.get_prev(pendulum.DateTime)
|
|
55
|
+
return cron.get_prev(pendulum.DateTime)
|
|
56
56
|
except Exception as e:
|
|
57
57
|
raise ValueError("Invalid cron expression or granularity specified.") from e
|
|
58
58
|
|
|
@@ -63,19 +63,28 @@ def read_converter(path_str: str):
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
def get_config(config_file: Path, tz: str = "Europe/Madrid"):
|
|
66
|
-
if Path(config_file).suffix == "ini":
|
|
66
|
+
if Path(config_file).suffix == ".ini":
|
|
67
67
|
logger.warning("Using legacy INI config reader. Please migrate to TOML")
|
|
68
68
|
cfg = configparser.RawConfigParser()
|
|
69
69
|
return cfg.read(config_file)
|
|
70
70
|
|
|
71
71
|
add_converter("read", read_converter)
|
|
72
72
|
|
|
73
|
+
today = get_granular_date("daily", tz)
|
|
74
|
+
|
|
73
75
|
config = Dynaconf(
|
|
74
76
|
environments=True,
|
|
75
77
|
env_switcher="SYSTYPE",
|
|
76
78
|
vars={
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
+
"now": today.strftime("%Y-%m-%d %H:%M:%S"),
|
|
80
|
+
"today": today.strftime("%Y-%m-%d"),
|
|
81
|
+
"year": today.strftime("%Y"),
|
|
82
|
+
"month": today.strftime("%m"),
|
|
83
|
+
"day": today.strftime("%d"),
|
|
84
|
+
"biweekly_date": get_granular_date("biweekly", tz).strftime("%Y-%m-%d"),
|
|
85
|
+
"today_stripped": today.strftime("%Y%m%d"),
|
|
86
|
+
"now_stripped": today.strftime("%Y%m%d%H%M%S"),
|
|
87
|
+
"dynaconf_merge": True,
|
|
79
88
|
},
|
|
80
89
|
)
|
|
81
90
|
|
|
@@ -6,18 +6,18 @@ datamarket/interfaces/drive.py,sha256=shbV5jpQVe_KPE-8Idx6Z9te5Zu1SmVfrvSAyd9ZIg
|
|
|
6
6
|
datamarket/interfaces/ftp.py,sha256=9GQgiNBBK7njkv8ytHQaP9YLB9kI5vnUFA5gtz9J7As,1859
|
|
7
7
|
datamarket/interfaces/nominatim.py,sha256=WkPXaug-oH5zJkuE6aXMu4-MEkGYIY7S6TekfZ2FnHY,3658
|
|
8
8
|
datamarket/interfaces/peerdb.py,sha256=kJ3hdzGEACTfA_HM1b_I2rExY0x6ijCq5eOP1WObpLc,21821
|
|
9
|
-
datamarket/interfaces/proxy.py,sha256=
|
|
9
|
+
datamarket/interfaces/proxy.py,sha256=8EJaW8zAMzUMIRLkdAcMkTO9qZXPIubE6vyB5ZXcRtU,3352
|
|
10
10
|
datamarket/interfaces/tinybird.py,sha256=AYrcRGNOCoCt7ojilkWa27POROee9sTCwZ61GGHEPeM,2698
|
|
11
11
|
datamarket/params/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
datamarket/params/nominatim.py,sha256=pBYRfoBkkLBg2INbFymefmYSzaAVujQSpEro5c1hD_I,1143
|
|
13
13
|
datamarket/utils/__init__.py,sha256=8D5a8oKgqd6WA1RUkiKCn4l_PVemtyuckxQut0vDHXM,20
|
|
14
14
|
datamarket/utils/airflow.py,sha256=al0vc0YUikNu3Oy51VSn52I7pMU40akFBOl_UlHa2E4,795
|
|
15
15
|
datamarket/utils/alchemy.py,sha256=SRq6kgh1aANXVShBPgAuglmNhZssPWwWEY503gKSia8,635
|
|
16
|
-
datamarket/utils/main.py,sha256=
|
|
16
|
+
datamarket/utils/main.py,sha256=X5m9OMu8XnYYMEnQxvj8PWrT5MxJCftNv48BwDCfk1w,5533
|
|
17
17
|
datamarket/utils/selenium.py,sha256=IMKlbLzXABFhACnWzhHmB0l2hhVzNwHGZwbo14nEewQ,2499
|
|
18
18
|
datamarket/utils/soda.py,sha256=eZTXFbI1P3WoMd1MM-YjoVTpdjTcDSWuvBb7ViBMhSQ,941
|
|
19
19
|
datamarket/utils/typer.py,sha256=FDF3l6gh3UlAFPsHCtesnekvct2rKz0oFn3uKARBQvE,814
|
|
20
|
-
datamarket-0.8.
|
|
21
|
-
datamarket-0.8.
|
|
22
|
-
datamarket-0.8.
|
|
23
|
-
datamarket-0.8.
|
|
20
|
+
datamarket-0.8.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
21
|
+
datamarket-0.8.2.dist-info/METADATA,sha256=AlcJCKZNiKtQ3S2us0-EkYuKa0Nokyz64O2ZtOu3j3w,6176
|
|
22
|
+
datamarket-0.8.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
23
|
+
datamarket-0.8.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|