mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-21 21:51:28 +00:00
More attempts for federate
This commit is contained in:
parent
74b5f59684
commit
e5484f0a6d
|
@ -6,6 +6,7 @@ import urllib.parse
|
|||
import os
|
||||
from loguru import logger
|
||||
|
||||
attempts_for_federate = 3
|
||||
auth_file = '.auth.json'
|
||||
if os.path.exists(auth_file):
|
||||
with open('.auth.json', 'rt') as f:
|
||||
|
@ -255,8 +256,15 @@ def federate_search_by_url(object):
|
|||
params = {
|
||||
'object': object
|
||||
}
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/fetches', json=params)
|
||||
for i in range(attempts_for_federate):
|
||||
try:
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/fetches', json=params)
|
||||
r.raise_for_status()
|
||||
break
|
||||
except Exception as Err:
|
||||
logger.error(f'Attempt {i}: {Err}')
|
||||
time.sleep(3)
|
||||
return r.json()
|
||||
|
||||
|
||||
|
@ -266,16 +274,30 @@ def federate_remote_library(fid):
|
|||
params = {
|
||||
'fid': fid
|
||||
}
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/libraries/fetch', json=params)
|
||||
for i in range(attempts_for_federate):
|
||||
try:
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/libraries/fetch', json=params)
|
||||
r.raise_for_status()
|
||||
break
|
||||
except Exception as Err:
|
||||
logger.error(f'Attempt {i}: {Err}')
|
||||
time.sleep(3)
|
||||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def scan_remote_library(uuid):
|
||||
'''Scan remote library'''
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/libraries/{uuid}')
|
||||
for i in range(attempts_for_federate):
|
||||
try:
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/libraries/{uuid}')
|
||||
r.raise_for_status()
|
||||
break
|
||||
except Exception as Err:
|
||||
logger.error(f'Attempt {i}: {Err}')
|
||||
time.sleep(3)
|
||||
return r.json()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue