@@ -52,10 +52,14 @@ class GitOverCdnClient:
5252 def __init__ (self , url , folder , source = 'origin' , branch = 'master' , git = 'git' ):
5353 """
5454 Args:
55- url: http://127.0.0.1:22251/pack/LmeSzinc_AzurLaneAutoScript_master/
55+ url (str | list[str]) : http://127.0.0.1:22251/pack/LmeSzinc_AzurLaneAutoScript_master/
5656 folder: D:/AzurLaneAutoScript
5757 """
58- self .url = url .strip ('/' )
58+ if isinstance (url , str ):
59+ self .urls = [url .strip ('/' )]
60+ else :
61+ self .urls = [u .strip ('/' ) for u in url ]
62+ self .url = self .urls [0 ]
5963 self .folder = folder .replace ('\\ ' , '/' )
6064 self .source = source
6165 self .branch = branch
@@ -100,29 +104,31 @@ def session(self):
100104
101105 @cached_property
102106 def latest_commit (self ) -> str :
103- try :
107+ for url_base in self .urls :
108+ self .url = url_base
104109 url = self .urlpath ('/latest.json' )
105110 self .logger .info (f'Fetch url: { url } ' )
106- resp = self .session .get (url , timeout = 3 )
107- except Exception as e :
108- self .logger .error (f'Failed to get remote commit: { e } ' )
109- return ''
110-
111- if resp .status_code == 200 :
112111 try :
113- info = json .loads (resp .text )
114- commit = info ['commit' ]
115- self .logger .attr ('LatestCommit' , commit )
116- return commit
117- except json .JSONDecodeError :
118- self .logger .error (f'Failed to get remote commit, response is not a json: { resp .text } ' )
119- return ''
120- except KeyError :
121- self .logger .error (f'Failed to get remote commit, key "commit" is not found: { resp .text } ' )
122- return ''
123- else :
124- self .logger .error (f'Failed to get remote commit, status={ resp .status_code } , text={ resp .text } ' )
125- return ''
112+ resp = self .session .get (url , timeout = 3 )
113+ except Exception as e :
114+ self .logger .error (f'Failed to get remote commit: { e } ' )
115+ continue
116+
117+ if resp .status_code == 200 :
118+ try :
119+ info = json .loads (resp .text )
120+ commit = info ['commit' ]
121+ self .logger .attr ('LatestCommit' , commit )
122+ return commit
123+ except json .JSONDecodeError :
124+ self .logger .error (f'Failed to get remote commit, response is not a json: { resp .text } ' )
125+ except KeyError :
126+ self .logger .error (f'Failed to get remote commit, key "commit" is not found: { resp .text } ' )
127+ else :
128+ self .logger .error (f'Failed to get remote commit, status={ resp .status_code } , text={ resp .text } ' )
129+
130+ self .url = self .urls [0 ]
131+ return ''
126132
127133 def download_pack (self ):
128134 try :
0 commit comments