MCPcopy Index your code
hub / github.com/Sathvik-Rao/ClipCascade / Application

Class Application

ClipCascade_Desktop/src/core/application.py:33–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32
33class Application:
34 def __init__(
35 self,
36 log_file_path=LOG_FILE_NAME,
37 data_file_path=DATA_FILE_NAME,
38 mutex_identifier=MUTEX_NAME,
39 ):
40 try:
41 self.log_file_path = os.path.join(
42 get_program_files_directory(), log_file_path
43 )
44 self.data_file_path = os.path.join(
45 get_program_files_directory(), data_file_path
46 )
47 self.mutex_identifier = mutex_identifier
48
49 if PLATFORM == MACOS or PLATFORM.startswith(LINUX):
50 self.lock_file = None # File(lock) object
51 self.mutex_identifier = os.path.join(
52 get_program_files_directory(), self.mutex_identifier
53 )
54
55 self.config = Config(
56 file_name=self.data_file_path
57 ) # Maintain a single configuration instance for the entire application lifecycle.
58
59 self.request_manager = RequestManager(self.config)
60 self.stomp_manager = STOMPManager(self.config)
61 self.p2p_manager = P2PManager(self.config)
62 self.cipher_manager = CipherManager(self.config)
63 except Exception as e:
64 CustomDialog(
65 f"An error occurred during application initialization: {e}",
66 msg_type="error",
67 ).mainloop()
68
69 def setup_logging(self):
70 LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
71 logging.basicConfig(
72 level=LOG_LEVEL,
73 format=LOG_FORMAT,
74 filename=self.log_file_path,
75 filemode="w",
76 )
77
78 def ensure_single_instance(self):
79 if PLATFORM == WINDOWS:
80 ctypes.windll.kernel32.CreateMutexW(None, False, self.mutex_identifier)
81 if ctypes.windll.kernel32.GetLastError() == 183: # ERROR_ALREADY_EXISTS
82 CustomDialog(
83 "Another instance of ClipCascade is already running.",
84 msg_type="warning",
85 ).mainloop()
86 sys.exit(0)
87 elif PLATFORM == MACOS or PLATFORM.startswith(LINUX):
88 if PLATFORM == MACOS:
89 app_dir = get_program_files_directory()
90 if not os.path.exists(app_dir):

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected