import json from gradio_client import Client from pgsoft.pgdate.date_utils import beijing def call_logger(log_info, caller, hf_token) -> None: ####################### # logging ####################### calling_start = beijing() print(f"calling logger starts at {beijing()}") ################################################# urls = [ "https://hubei-hunan-logger.hf.space", "https://hubei-hunan-logger2.hf.space", ] for url in urls: try: client = Client( url, hf_token=hf_token, verbose=False, ) client.submit(json.dumps(log_info), caller) print(f"[logging to {url}] OK") except Exception as e: print(f"[logging to {url}] error: {e}") ################################################# calling_end = beijing() timecost = calling_end.timestamp() - calling_start.timestamp() print(f"calling logger ends at {calling_end}, costs {timecost:.2f}s") def call_clouddisk(service, arg, hf_token) -> str | None: ########################## # upload or download game ########################## urls = [ "https://pgsoft-clouddisk.hf.space", # "https://pgsoft-clouddisk2.hf.space", ] for url in urls: try: client = Client( url, hf_token=hf_token, verbose=False, ) res = client.predict(service, arg, api_name="/predict") print("[call_clouddisk] OK") return res except Exception as e: print(f"[call_clouddisk] {type(e)}: {e}") return None