lint(proxy): lint
This commit is contained in:
parent
08205647a5
commit
8689f1331d
1 changed files with 4 additions and 4 deletions
|
@ -70,7 +70,7 @@ class ProxyMetaAutomation(BaseAutomation):
|
||||||
|
|
||||||
def automate(self, full: bool = False) -> Tuple[bool, str]:
|
def automate(self, full: bool = False) -> Tuple[bool, str]:
|
||||||
# Deprecate orphaned proxies, old proxies and mismatched proxies
|
# Deprecate orphaned proxies, old proxies and mismatched proxies
|
||||||
proxies = Proxy.query.filter(
|
proxies: List[Proxy] = Proxy.query.filter(
|
||||||
Proxy.deprecated.is_(None),
|
Proxy.deprecated.is_(None),
|
||||||
Proxy.destroyed.is_(None),
|
Proxy.destroyed.is_(None),
|
||||||
).all()
|
).all()
|
||||||
|
@ -78,9 +78,9 @@ class ProxyMetaAutomation(BaseAutomation):
|
||||||
if proxy.origin.destroyed is not None:
|
if proxy.origin.destroyed is not None:
|
||||||
proxy.deprecate(reason="origin_destroyed")
|
proxy.deprecate(reason="origin_destroyed")
|
||||||
if proxy.origin_id in current_app.config.get("DAILY_REPLACEMENT_ORIGINS", []):
|
if proxy.origin_id in current_app.config.get("DAILY_REPLACEMENT_ORIGINS", []):
|
||||||
max_age_cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=1, seconds=86400 * random.random())
|
max_age_cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=1, seconds=86400 * random.random()) # nosec: B311
|
||||||
else:
|
else:
|
||||||
max_age_cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=5, seconds=86400 * random.random())
|
max_age_cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=5, seconds=86400 * random.random()) # nosec: B311
|
||||||
if proxy.added < max_age_cutoff:
|
if proxy.added < max_age_cutoff:
|
||||||
proxy.deprecate(reason="max_age_reached")
|
proxy.deprecate(reason="max_age_reached")
|
||||||
if proxy.origin.smart and not PROXY_PROVIDERS[proxy.provider].smart_proxies: # type: ignore[attr-defined]
|
if proxy.origin.smart and not PROXY_PROVIDERS[proxy.provider].smart_proxies: # type: ignore[attr-defined]
|
||||||
|
@ -101,7 +101,7 @@ class ProxyMetaAutomation(BaseAutomation):
|
||||||
create_proxy(pool, origin)
|
create_proxy(pool, origin)
|
||||||
# Destroy expired proxies
|
# Destroy expired proxies
|
||||||
expiry_cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=4)
|
expiry_cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=4)
|
||||||
proxies: List[Proxy] = Proxy.query.filter(
|
proxies = Proxy.query.filter(
|
||||||
Proxy.destroyed.is_(None),
|
Proxy.destroyed.is_(None),
|
||||||
Proxy.deprecated < expiry_cutoff
|
Proxy.deprecated < expiry_cutoff
|
||||||
).all()
|
).all()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue