mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 07:21: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
|
import os
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
attempts_for_federate = 3
|
||||||
auth_file = '.auth.json'
|
auth_file = '.auth.json'
|
||||||
if os.path.exists(auth_file):
|
if os.path.exists(auth_file):
|
||||||
with open('.auth.json', 'rt') as f:
|
with open('.auth.json', 'rt') as f:
|
||||||
|
@ -255,8 +256,15 @@ def federate_search_by_url(object):
|
||||||
params = {
|
params = {
|
||||||
'object': object
|
'object': object
|
||||||
}
|
}
|
||||||
r = current_instance.s.post(
|
for i in range(attempts_for_federate):
|
||||||
f'https://{current_instance.instance}/api/v1/federation/fetches', json=params)
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,16 +274,30 @@ def federate_remote_library(fid):
|
||||||
params = {
|
params = {
|
||||||
'fid': fid
|
'fid': fid
|
||||||
}
|
}
|
||||||
r = current_instance.s.post(
|
for i in range(attempts_for_federate):
|
||||||
f'https://{current_instance.instance}/api/v1/federation/libraries/fetch', json=params)
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def scan_remote_library(uuid):
|
def scan_remote_library(uuid):
|
||||||
'''Scan remote library'''
|
'''Scan remote library'''
|
||||||
r = current_instance.s.post(
|
for i in range(attempts_for_federate):
|
||||||
f'https://{current_instance.instance}/api/v1/federation/libraries/{uuid}')
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue