فهرست منبع

add forced update to emergency tool

잉여개발기 (SPDV) 3 سال پیش
والد
کامیت
0b628a0d0b
1فایلهای تغییر یافته به همراه33 افزوده شده و 1 حذف شده
  1. 33 1
      emergency_tool.py

+ 33 - 1
emergency_tool.py

@@ -1,5 +1,10 @@
 # Load
 import time
+import os
+import platform
+import urllib
+import zipfile
+
 from route.tool.func import *
 
 while True:
@@ -40,6 +45,7 @@ print('15. Give owner')
 print('16. Delete 2FA password')
 print('17. Change markup')
 print('18. Change wiki access password')
+print('19. Forced update')
 
 print('----')
 what_i_do = input('Select : ')
@@ -222,6 +228,32 @@ elif what_i_do == '18':
     wiki_access_password = input('Password : ')
 
     curs.execute(db_change("update other set data = ? where name = 'wiki_access_password'"), [wiki_access_password])
+elif what_i_do == '19':
+    print('----')
+    up_data = input('Insert branch (beta) [stable, beta, dev] : ')
+
+    if not up_data in ['stable', 'beta', 'dev']:
+        up_data = 'beta'
+
+    if platform.system() == 'Linux':
+        ok = []
+
+        ok += [os.system('git remote rm origin')]
+        ok += [os.system('git remote add origin https://github.com/opennamu/opennamu.git')]
+        ok += [os.system('git fetch origin ' + up_data)]
+        ok += [os.system('git reset --hard origin/' + up_data)]
+        if (ok[0] and ok[1] and ok[2] and ok[3]) != 0:
+            print('Error : update failed')
+    elif platform.system() == 'Windows':
+        os.system('rd /s /q route')
+        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')
 else:
     raise ValueError(what_i_do)
 
@@ -229,4 +261,4 @@ if data_db_load == 'Y':
     conn.commit()
 
 print('----')
-print('OK')
+print('OK')