Browse Source

save changes

KoljaB 7 tháng trước cách đây
mục cha
commit
f98053f166
2 tập tin đã thay đổi với 12 bổ sung42 xóa
  1. 6 21
      tests/realtimestt_test.py
  2. 6 21
      tests/realtimestt_test_stereomix.py

+ 6 - 21
tests/realtimestt_test.py

@@ -2,27 +2,12 @@ EXTENDED_LOGGING = False
 
 if __name__ == '__main__':
 
-    import subprocess
-    import sys
-
-    def install_rich():
-        subprocess.check_call([sys.executable, "-m", "pip", "install", "rich"])
-
-    try:
-        import rich
-    except ImportError:
-        user_input = input("This demo needs the 'rich' library, which is not installed.\nDo you want to install it now? (y/n): ")
-        if user_input.lower() == 'y':
-            try:
-                install_rich()
-                import rich
-                print("Successfully installed 'rich'.")
-            except Exception as e:
-                print(f"An error occurred while installing 'rich': {e}")
-                sys.exit(1)
-        else:
-            print("The program requires the 'rich' library to run. Exiting...")
-            sys.exit(1)
+    from install_packages import check_and_install_packages
+    check_and_install_packages([
+        {
+            'import_name': 'rich',
+        }
+    ])
 
     if EXTENDED_LOGGING:
         import logging

+ 6 - 21
tests/realtimestt_test_stereomix.py

@@ -2,27 +2,12 @@ EXTENDED_LOGGING = False
 
 def main():
 
-    import subprocess
-    import sys
-
-    def install_rich():
-        subprocess.check_call([sys.executable, "-m", "pip", "install", "rich"])
-
-    try:
-        import rich
-    except ImportError:
-        user_input = input("This demo needs the 'rich' library, which is not installed.\nDo you want to install it now? (y/n): ")
-        if user_input.lower() == 'y':
-            try:
-                install_rich()
-                import rich
-                print("Successfully installed 'rich'.")
-            except Exception as e:
-                print(f"An error occurred while installing 'rich': {e}")
-                sys.exit(1)
-        else:
-            print("The program requires the 'rich' library to run. Exiting...")
-            sys.exit(1)
+    from install_packages import check_and_install_packages
+    check_and_install_packages([
+        {
+            'import_name': 'rich',
+        }
+    ])
 
     if EXTENDED_LOGGING:
         import logging