Ver código fonte

다시 urllib.request로 회귀

잉여개발기 (SPDV) 2 anos atrás
pai
commit
98e4f45d22
4 arquivos alterados com 20 adições e 44 exclusões
  1. 9 18
      emergency_tool.py
  2. 8 15
      route/main_sys_update.py
  3. 2 10
      route/tool/func.py
  4. 1 1
      version.json

+ 9 - 18
emergency_tool.py

@@ -190,24 +190,15 @@ elif what_i_do == '19':
                 break
     elif platform.system() == 'Windows':
         os.system('rd /s /q route')
-
-        url = 'https://github.com/opennamu/opennamu/archive/' + up_data + '.zip'
-        local_filename = 'update.zip'
-
-        response = requests.get(url, stream = True)
-        if response.status_code == 200:
-            with open(local_filename, 'wb') as f:
-                for chunk in response.iter_content(chunk_size = 1024 * 1024):
-                    if chunk:
-                        f.write(chunk)
-            
-            zipfile.ZipFile('update.zip').extractall('')
-            ok = os.system('xcopy /y /s /r opennamu-' + up_data + ' .')
-            if ok == 0:
-                os.system('rd /s /q opennamu-' + up_data)
-                os.system('del update.zip')
-            else:
-                print('Error : update failed')
+        
+        urllib.request.urlretrieve('https://github.com/opennamu/opennamu/archive/' + up_data + '.zip', 'update.zip')
+        
+        zipfile.ZipFile('update.zip').extractall('')
+        
+        ok = os.system('xcopy /y /s /r opennamu-' + up_data + ' .')
+        if ok == 0:
+            os.system('rd /s /q opennamu-' + up_data)
+            os.system('del update.zip')
         else:
             print('Error : update failed')
 elif what_i_do == '20':

+ 8 - 15
route/main_sys_update.py

@@ -35,23 +35,16 @@ def main_sys_update():
             elif platform.system() == 'Windows':
                 os.system('rd /s /q route')
 
-                url = 'https://github.com/opennamu/opennamu/archive/' + up_data + '.zip'
-                local_filename = 'update.zip'
-
-                response = requests.get(url, stream = True)
-                if response.status_code == 200:
-                    with open(local_filename, 'wb') as f:
-                        for chunk in response.iter_content(chunk_size = 1024 * 1024):
-                            if chunk:
-                                f.write(chunk)
+                urllib.request.urlretrieve('https://github.com/opennamu/opennamu/archive/' + up_data + '.zip', 'update.zip')
                     
-                    zipfile.ZipFile('update.zip').extractall('')
-                    ok = os.system('xcopy /y /s /r opennamu-' + up_data + ' .')
-                    if ok == 0:
-                        os.system('rd /s /q opennamu-' + up_data)
-                        os.system('del update.zip')
+                zipfile.ZipFile('update.zip').extractall('')
+                
+                ok = os.system('xcopy /y /s /r opennamu-' + up_data + ' .')
+                if ok == 0:
+                    os.system('rd /s /q opennamu-' + up_data)
+                    os.system('del update.zip')
 
-                        return redirect(conn, '/restart')
+                    return redirect(conn, '/restart')
             
             print('Error : update failed')
 

+ 2 - 10
route/tool/func.py

@@ -697,18 +697,10 @@ def set_init_always(conn, ver_num):
         if os.path.exists(exe_path):
             os.remove(exe_path)
         
-        # https://raw.githubusercontent.com/openNAMU/GopenNAMU/beta/route_go/bin/main.amd64.bin
-        url = 'https://raw.githubusercontent.com/openNAMU/GopenNAMU/' + up_data + '/route_go/bin/' + exe_type
         print('Download ' + up_data + ' ' + exe_type)
 
-        response = requests.get(url, stream = True)
-        if response.status_code == 200:
-            with open(exe_path, 'wb') as f:
-                for chunk in response.iter_content(chunk_size = 1024 * 1024):
-                    if chunk:
-                        f.write(chunk)
-        else:
-            print('Connect error')
+        # https://raw.githubusercontent.com/openNAMU/GopenNAMU/beta/route_go/bin/main.amd64.bin
+        urllib.request.urlretrieve('https://raw.githubusercontent.com/openNAMU/GopenNAMU/' + up_data + '/route_go/bin/' + exe_type, exe_path)
         
         if platform.system() == 'Linux':
             os.system('chmod +x ./route_go/bin/' + exe_type)

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.5.0-v136",
+        "r_ver" : "v3.5.0-v137",
         "c_ver" : "20240513",
         "s_ver" : "20240426"
     }