Advertisement
EdmundC

hub

Sep 30th, 2024 (edited)
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.93 KB | None | 0 0
  1. import os
  2. import sys
  3. import time
  4. import threading
  5.  
  6. def loading_animation():
  7.     """Displays a loading animation as a progress bar."""
  8.     bar_length = 20  # Length of the progress bar
  9.     for i in range(bar_length + 1):
  10.         time.sleep(0.1)  # Simulate loading
  11.         filled_length = int(bar_length * i // bar_length)  # Calculate filled length
  12.         bar = '█' * filled_length + '-' * (bar_length - filled_length)  # Create the bar
  13.         print(f"\r[{bar}] Loading Software", end="")
  14.     print("\r[████████████████████] Loading complete.")
  15.  
  16. def handle_command(command):
  17.     """Handles the commands entered by the user."""
  18.     if command.startswith("/ld"):
  19.         cmd_parts = command.split(" ")
  20.         if len(cmd_parts) == 2:
  21.             project = cmd_parts[1]
  22.             if project == "ping":
  23.                 # Start loading animation in a separate thread
  24.                 loading_thread = threading.Thread(target=loading_animation)
  25.                 loading_thread.start()
  26.                 loading_thread.join()  # Wait for the loading animation to finish
  27.                 print("Launching ping software...")
  28.                 os.execv(sys.executable, ['python'] + ['pingsubsoft.py'])
  29.             elif project == "dev":
  30.                 # Start loading animation in a separate thread
  31.                 loading_thread = threading.Thread(target=loading_animation)
  32.                 loading_thread.start()
  33.                 loading_thread.join()  # Wait for the loading animation to finish
  34.                 print("Launching dev software...")
  35.                 os.execv(sys.executable, ['python'] + ['devsubsoft.py'])
  36.             else:
  37.                 print("Unknown project. Available: ping, dev.")
  38.         else:
  39.             print("Error: Invalid format. Use '/ld project_name'.")
  40.     else:
  41.         print("Unknown command.")
  42.  
  43. def main():
  44.     # ASCII art title
  45.     title = r"""
  46. |__   __|  ____|  __ \|  \/  |_   _| \ | |   /\  | |    
  47.   | |  | |__  | |__) | \ / | | | |  \| |  /  \ | |    
  48.   | |  |  __| |  _  /| |\/| | | | | . ` | / /\ \ | |        
  49.   | |  | |____| | \ \| |  | |_| |_| |\ |/ ____ \| |____
  50.   |_|_ |______|_|_ \_\_|  |_|_____|_| \_/_/    \_\______|
  51.   | |  | | |  | |  _ \                                    
  52.   | |__| | |  | | |_) |                                    
  53.   |  __  | |  | |  _ <                                      
  54.   | |  | | |__| | |_) |                                    
  55.   |_|  |_|\____/|____/                                      
  56. A Mac-User's Linux Dream                                  
  57. Edmund Chenault & GPT 4o                                   """
  58.    
  59.     print(title)  # Now prints the title one line up
  60.     print("\nWelcome to the Terminal Hub!")
  61.    
  62.     while True:
  63.         command = input("> ")
  64.         if command.lower() in ["/quit", "/exit"]:
  65.             break
  66.         handle_command(command)
  67.  
  68. if __name__ == "__main__":
  69.     main()
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement