rita před 2 roky
rodič
revize
3c722a17f0
1 změnil soubory, kde provedl 28 přidání a 20 odebrání
  1. 28 20
      manage.py

+ 28 - 20
manage.py

@@ -16,16 +16,18 @@ import stat
 import time
 
 
-app, db, mqtt, socketio = create_app()
+# app, db, mqtt, socketio = create_app() # Rita 0428
+app, db, mqtt = create_app()
 thread = None
 thread_lock = Lock()
 
-@socketio.on('connect_event', namespace='/test_conn')
-def connected_msg(msg):
-    print("connect success")
-    print(msg)
-    socketio.emit('stdout', 'success', namespace='/test_conn')
-    print(socketio)
+# Rita 0428
+# @socketio.on('connect_event', namespace='/test_conn')
+# def connected_msg(msg):
+#     print("connect success")
+#     print(msg)
+#     socketio.emit('stdout', 'success', namespace='/test_conn')
+#     print(socketio)
 
 D = {"item_name":0, "command":0}
 
@@ -398,12 +400,13 @@ def add_server_views():
     username = session['uname']
     L = []
     if request.method == 'GET':
-        os.system('git clone -b sh --single-branch http://60.250.156.230:3000/Automatic_build_system/Automatically_install_files.git C:\\Users\\USER\\Rita\\operating\\sixthproject\\new')
-        with open('../new/coffeesystem.sh', encoding='utf-8') as f:
+        os.system('git clone -b sh --single-branch http://60.250.156.230:3000/Automatic_build_system/Automatically_install_files.git /home/gs1802/BBend-Test-JWT/newSH')
+        # os.system('git clone -b sh --single-branch http://60.250.156.230:3000/Automatic_build_system/Automatically_install_files.git C:\\Users\\USER\\Rita\\operating\\sixthproject\\new')
+        with open('/home/gs1802/BBend-Test-JWT/newSH/coffeesystem.sh', encoding='utf-8') as f:
             D['command'] = f.read().split('\n')
-        # print("D['command']: ", D['command'])
+        print("D['command']: ", D['command'])
         
-        shutil.rmtree('../new', onerror=remove_readonly)
+        shutil.rmtree('/home/gs1802/BBend-Test-JWT/newSH', onerror=remove_readonly)
         sl(3)
 
         L2= []
@@ -417,7 +420,7 @@ def add_server_views():
 
         # 0407 測試中暫時註解
         # with open('/home/benson/Project/new/Item.txt') as f:
-        with open('../Item.txt') as f:
+        with open('Item.txt') as f:
             D['item_name'] = f.read().split('\n')
             for item in D['item_name']:
                 L.append('.'.join(item.split('.')[1:]))         # 拿掉 '.'.join 的話會變成 [['python3', '8'], ['python3-pip'],
@@ -454,22 +457,25 @@ def add_server_views():
                         username=loginname,
                         password=password)
             # 假如帳號密碼正確沒有被捕捉到異常,傳送訊息給前端
-            socketio.emit('user-confirm', 'pass', namespace='/test_conn')
+            # socketio.emit('user-confirm', 'pass', namespace='/test_conn')
 
             # content = D['item_name'] + D['command']
             with open('../ItemFile.csv', 'w', newline='') as csvFile:
                 csvWriter = csv.writer(csvFile)
                 csvWriter.writerow(['Command', 'Install Content', 'Time', 'Status'])
             
-            # # # Rita TEST
+            # # # # Rita TEST
             # D['command'] = [
             #     # 'cd /home/使用者;pwd;sudo git clone -b git_repo --single-branch http://60.250.156.230:3000/Automatic_build_system/git_mysql.git', 
             #     # 'cd /home/使用者/git_mysql/;pwd;sudo mv gogs.tar.gz /home/使用者/;sudo mv repo.tar.gz /home/使用者/',
             #     # 'cd /home/使用者;pwd;sudo tar -zxvf /home/使用者/gogs.tar.gz;sudo tar -zxvf /home/使用者/repo.tar.gz ;sudo mv /home/使用者/git_mysql/app.ini /home/使用者/gogs/custom/conf/',
             #     # 'sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/sh.git'
-            #     'cd /home/' + username + '/gogs/custom/conf/;' + \
-            #     'pwd;' + \
-            #     'sed -i "s/使_用_者/使用者/g" app.ini'
+
+            #     # 'cd /home/' + username + '/gogs/custom/conf/;' + \
+            #     # 'pwd;' + \
+            #     # 'sed -i "s/使_用_者/使用者/g" app.ini'
+
+            #     'cd /home/使用者;pwd;sudo tar -zxvf /home/使用者/gogs.tar.gz;sudo tar -zxvf /home/使用者/repo.tar.gz ;sudo mv /home/使用者/git_mysql/app.ini /home/使用者/gogs/custom/conf/'
             # ]
 
             for command in D['command']:
@@ -543,7 +549,7 @@ def add_server_views():
                                             # 'error: \n' + error, 
                                             execution_time, 
                                             'error'])
-                    socketio.emit('stderr', error, namespace='/test_conn')
+                    # socketio.emit('stderr', error, namespace='/test_conn')
                     # 判斷若此 command 符合 Automatic_Build_System 的 Key, 則改變狀態
                     for key, value in Automatic_Build_System.items():
                         if key in command:
@@ -557,7 +563,7 @@ def add_server_views():
                                             'success: \n' + success + '\nerror: \n' + error, 
                                             execution_time, 
                                             'success'])
-                    socketio.emit('stdout', success, namespace='/test_conn')
+                    # socketio.emit('stdout', success, namespace='/test_conn')
                     # 判斷若此 command 符合 Automatic_Build_System 的 Key, 則改變狀態
                     for key, value in Automatic_Build_System.items():
                         if key in command:
@@ -661,4 +667,6 @@ def shutdown_session(exception=None):
 if __name__ == '__main__':
     # Rita 0406 socketio.run(app, debug=True, host='0.0.0.0', port=5014)
     # Rita 0406 app.run(debug=True, host='0.0.0.0', port=5014)
-    socketio.run(app, debug=True, host='0.0.0.0', port=5014)
+    # print("===== BBend =====")
+    # socketio.run(app, debug=True, host='0.0.0.0', port=5014)
+    app.run(debug=True, host='0.0.0.0', port=5014)