chefmate 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
chefmate-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2025] [Anuj Kumar Sah]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ include README.md
2
+ include LICENSE
@@ -0,0 +1,313 @@
1
+ Metadata-Version: 2.4
2
+ Name: chefmate
3
+ Version: 1.0.0
4
+ Summary: A CodeChef automation CLI tool
5
+ Home-page: https://github.com/Anuj-72/ChefMate
6
+ Author: Anuj Kumar Sah
7
+ Author-email: anujsah282005@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: selenium
15
+ Requires-Dist: webdriver-manager
16
+ Requires-Dist: click
17
+ Requires-Dist: colorama
18
+ Requires-Dist: inquirer
19
+ Requires-Dist: InquirerPy
20
+ Requires-Dist: rich
21
+ Requires-Dist: tabulate
22
+ Requires-Dist: pandas
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: description
27
+ Dynamic: description-content-type
28
+ Dynamic: home-page
29
+ Dynamic: license-file
30
+ Dynamic: requires-dist
31
+ Dynamic: requires-python
32
+ Dynamic: summary
33
+
34
+ # ChefMate
35
+
36
+ ChefMate is an automation tool designed to simplify and streamline your CodeChef contest participation. It leverages browser automation (using Selenium and ChromeDriver) along with a versatile command-line interface (CLI) to handle tasks such as logging in, contest management, problem scraping, solution submissions, and demo test case validations. ChefMate also helps set up directories and template files so that you can focus on solving problems quickly and efficiently.
37
+
38
+ ---
39
+
40
+ ## Table of Contents
41
+
42
+ - [Introduction](#introduction)
43
+ - [Features](#features)
44
+ - [Architecture and Code Structure](#architecture-and-code-structure)
45
+ - [Browser Manager (`browser_manager.py`)](#browser-manager)
46
+ - [Core Functionality (`chefmate_core.py`)](#core-functionality)
47
+ - [Command Line Interface (`cli.py`)](#command-line-interface)
48
+ - [Configuration Management (`config.py`)](#configuration-management)
49
+ - [Installation](#installation)
50
+ - [Usage](#usage)
51
+ - [Setup](#setup)
52
+ - [Login and Logout](#login-and-logout)
53
+ - [Contest and Problem Management](#contest-and-problem-management)
54
+ - [Testing and Submissions](#testing-and-submissions)
55
+ - [Interactive Mode](#interactive-mode)
56
+ - [Dependencies](#dependencies)
57
+ - [Troubleshooting](#troubleshooting)
58
+ - [Future Improvements](#future-improvements)
59
+ - [License](#license)
60
+
61
+ ---
62
+
63
+ ## Introduction
64
+
65
+ ChefMate is built to help competitive programmers who participate in CodeChef contests. By automating several routine tasks (such as logging in, opening contest pages, fetching problems, and managing solution submissions), ChefMate removes friction from the contest environment. With its modular design, the tool offers easy configurability and a friendly CLI interface, making the CodeChef contest experience smoother and more productive.
66
+
67
+ ---
68
+
69
+ ## Features
70
+
71
+ - **Browser Management:**
72
+ - Detects and prevents conflicts with existing Chrome sessions.
73
+ - Initializes a ChromeDriver with custom profiles and directories.
74
+ - Configurable options to bypass common Chrome logging and automation detections.
75
+
76
+ - **Automated Contest Interaction:**
77
+ - Logs into CodeChef and navigates to the contest dashboard.
78
+ - Opens contest pages and scrapes problem links and details.
79
+ - Provides an interactive problem tracker to monitor submission statuses.
80
+
81
+ - **Solution Management:**
82
+ - Creates and manages solution directories for contests.
83
+ - Generates template solution files in your preferred programming language.
84
+ - Facilitates opening solution files in your favorite code editor.
85
+
86
+ - **Submission and Testing:**
87
+ - Automates the process of selecting the language from the CodeChef UI.
88
+ - Loads solutions from files and submits them via the browser.
89
+ - Runs sample test cases to verify outputs before actual submission.
90
+ - Displays detailed verdict tables and highlights errors.
91
+
92
+ - **Command-Line Interface (CLI):**
93
+ - Offers a range of commands (setup, login, logout, contest, submit, check, interactive mode).
94
+ - Provides an intuitive interactive mode with a clear menu-driven experience.
95
+ - Uses libraries such as Click and InquirerPy for enhanced user interaction.
96
+
97
+ - **Configuration Management:**
98
+ - Manages user settings (username, password, solution paths, preferred language, Chrome profile, editor preferences) through a JSON configuration file stored in the user's home directory.
99
+ - Ensures persistence and easy updates of user configuration.
100
+
101
+ ---
102
+
103
+ ## Architecture and Code Structure
104
+
105
+ ChefMate’s code is organized into four main modules:
106
+
107
+ ### Browser Manager
108
+
109
+ **File:** `browser_manager.py`
110
+
111
+ - **Purpose:**
112
+ Manages the Chrome browser session using Selenium WebDriver.
113
+ - **Key Functions:**
114
+ - **Initialization:** Sets up the ChromeDriver with options such as user-data-dir and profile-directory for isolated sessions.
115
+ - **Conflict Detection:** Checks if a Chrome instance is already running and prompts the user accordingly.
116
+ - **Session Management:** Provides methods to initialize, operate, and close the browser session.
117
+ - **Highlights:**
118
+ Uses `webdriver_manager` to ensure the correct ChromeDriver is installed and employs custom options to reduce unwanted automation flags.
119
+
120
+ ### Core Functionality
121
+
122
+ **File:** `chefmate_core.py`
123
+
124
+ - **Purpose:**
125
+ Acts as the primary interface to ChefMate functionality. It integrates browser automation with the CodeChef website.
126
+ - **Components:**
127
+ - **Login/Logout:**
128
+ Automates the CodeChef login procedure including form filling, waiting for dashboard elements, and handling potential errors.
129
+ - **Contest Handling:**
130
+ Opens a contest page, scrapes all available problem links, and dynamically creates a problem tracker.
131
+ - **Solution Handling:**
132
+ Searches for or prompts for the correct solution file. Generates solution templates based on the preferred programming language.
133
+ - **Submission and Testing:**
134
+ Provides mechanisms to load code into the CodeChef code editor, submit solutions, and analyze output results by parsing verdict tables.
135
+ - **Interactive Utilities:**
136
+ Functions like typewriter text effects, dashboard redirection, and dynamic problem tracking to enhance the user experience.
137
+
138
+ ### Command Line Interface
139
+
140
+ **File:** `cli.py`
141
+
142
+ - **Purpose:**
143
+ Provides a user-friendly CLI to interact with ChefMate.
144
+ - **Features:**
145
+ - **CLI Commands:**
146
+ Implements commands using Click. Commands include `setup`, `login`, `logout`, `check`, `submit`, `contest`, and `interactive`.
147
+ - **Interactive Mode:**
148
+ An extended menu-driven interface built using InquirerPy that lets users select among different operational modes such as logging in, solving problems, or reconfiguring settings.
149
+ - **UI Enhancements:**
150
+ Uses the Rich library for improved terminal output, such as styled tables and animated loaders.
151
+
152
+ ### Configuration Management
153
+
154
+ **File:** `config.py`
155
+
156
+ - **Purpose:**
157
+ Handles persistent configurations for ChefMate by reading from and writing to a JSON file.
158
+ - **Details:**
159
+ - **Default Configuration:**
160
+ Automatically creates a configuration file in the user's home directory (`~/.chefmate/config.json`) if it does not exist.
161
+ - **Dynamic Updates:**
162
+ Offers methods to get, set, and update various settings including username, password, preferred language, solution file paths, and Chrome user data directories.
163
+ - **Robustness:**
164
+ Includes error handling to recreate a default configuration if the current configuration file is corrupted.
165
+
166
+ ---
167
+
168
+ ## Installation
169
+
170
+ 1. **Clone the Repository:**
171
+
172
+ ```bash
173
+ git clone https://github.com/yourusername/chefmate.git
174
+ cd chefmate
175
+ ```
176
+
177
+ 2. **Set Up a Python Virtual Environment (Optional but Recommended):**
178
+
179
+ ```bash
180
+ python -m venv venv
181
+ source venv/bin/activate # Linux/Mac
182
+ venv\Scripts\activate # Windows
183
+ ```
184
+
185
+ 3. **Install Dependencies:**
186
+
187
+ ChefMate relies on several Python packages. Install them using:
188
+
189
+ ```bash
190
+ pip install -r requirements.txt
191
+ ```
192
+
193
+ > **Note:** Dependencies include libraries like Selenium, webdriver-manager, Click, InquirerPy, Rich, and Colorama. Make sure your environment meets the prerequisites for Selenium and ChromeDriver.
194
+
195
+ ---
196
+
197
+ ## Usage
198
+
199
+ ### Setup
200
+
201
+ Run the setup command to configure ChefMate with your CodeChef credentials, preferred language, editor, and solution file path:
202
+
203
+ ```bash
204
+ python cli.py setup
205
+ ```
206
+
207
+ ### Login and Logout
208
+
209
+ To login to CodeChef, use:
210
+
211
+ ```bash
212
+ python cli.py login
213
+ ```
214
+
215
+ And to logout:
216
+
217
+ ```bash
218
+ python cli.py logout
219
+ ```
220
+
221
+ ### Contest and Problem Management
222
+
223
+ - **Opening a Contest:**
224
+ Launch a contest by providing the contest ID and your division using:
225
+
226
+ ```bash
227
+ python cli.py contest
228
+ ```
229
+
230
+ - **Automatic Problem Scraping:**
231
+ ChefMate will automatically identify and open all the contest problem tabs and display a problem tracker.
232
+
233
+ ### Testing and Submissions
234
+
235
+ - **Check Demo Test Cases:**
236
+ Validate your solution using sample test cases:
237
+
238
+ ```bash
239
+ python cli.py check --problem 1
240
+ ```
241
+
242
+ - **Submitting a Solution:**
243
+ To submit your solution for a given problem:
244
+
245
+ ```bash
246
+ python cli.py submit --problem 1
247
+ ```
248
+
249
+ - **Solving Problems (Template Generation & File Management):**
250
+ ChefMate automatically generates solution template files in a designated contest directory for you to edit. It opens the selected file in your preferred text editor.
251
+
252
+ ### Interactive Mode
253
+
254
+ ChefMate also offers an interactive mode that provides a dynamic menu for operations. Launch it with:
255
+
256
+ ```bash
257
+ python cli.py interactive
258
+ ```
259
+
260
+ In this mode, you can choose among several actions such as login, logout, opening contests, checking demo cases, submitting solutions, and reconfiguring settings.
261
+
262
+ ---
263
+
264
+ ## Dependencies
265
+
266
+ - **Selenium:** For browser automation and web interactions.
267
+ - **webdriver-manager:** To handle ChromeDriver installation and updates.
268
+ - **Click & InquirerPy:** For building the CLI and interactive prompts.
269
+ - **Rich & Colorama:** For styled terminal outputs and color support.
270
+ - **Pandas & Tabulate:** For generating and displaying submission verdict tables.
271
+
272
+ Make sure you have the latest version of Google Chrome installed to ensure compatibility with ChromeDriver.
273
+
274
+ ---
275
+
276
+ ## Troubleshooting
277
+
278
+ - **Chrome Profile in Use:**
279
+ If you receive an error indicating that the Chrome profile is already being used, ensure that all Chrome windows are closed before starting ChefMate.
280
+
281
+ - **Solution File Issues:**
282
+ If ChefMate cannot locate your solution file, double-check the path in the configuration (or re-run the `setup` command).
283
+
284
+ - **Configuration Errors:**
285
+ If the configuration file is corrupted, ChefMate will automatically generate a new default configuration in `~/.chefmate/config.json`.
286
+
287
+ - **Network/Slow Load Problems:**
288
+ For slow networks, ChefMate includes retries during login and test case checks. If problems persist, try restarting your browser or re-running the command.
289
+
290
+ ---
291
+
292
+ ## Future Improvements
293
+
294
+ - **Enhanced Error Reporting:**
295
+ Additional debugging information for failures during submissions and test case validations.
296
+ - **Multi-Language Support:**
297
+ Extending support for more languages and custom code editor integration.
298
+ - **GUI Implementation:**
299
+ A graphical user interface for those who prefer not to use the CLI.
300
+ - **Extended Contest Support:**
301
+ Integration with more competitive programming sites.
302
+
303
+ ---
304
+
305
+ ## License
306
+
307
+ ChefMate is open source software released under the [MIT License](LICENSE).
308
+
309
+ ---
310
+
311
+ ChefMate is designed with flexibility and practicality in mind to reduce the repetitive tasks of contest participation, leaving you free to concentrate on solving problems and improving your competitive programming skills.
312
+
313
+ Happy Coding!
@@ -0,0 +1,280 @@
1
+ # ChefMate
2
+
3
+ ChefMate is an automation tool designed to simplify and streamline your CodeChef contest participation. It leverages browser automation (using Selenium and ChromeDriver) along with a versatile command-line interface (CLI) to handle tasks such as logging in, contest management, problem scraping, solution submissions, and demo test case validations. ChefMate also helps set up directories and template files so that you can focus on solving problems quickly and efficiently.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ - [Introduction](#introduction)
10
+ - [Features](#features)
11
+ - [Architecture and Code Structure](#architecture-and-code-structure)
12
+ - [Browser Manager (`browser_manager.py`)](#browser-manager)
13
+ - [Core Functionality (`chefmate_core.py`)](#core-functionality)
14
+ - [Command Line Interface (`cli.py`)](#command-line-interface)
15
+ - [Configuration Management (`config.py`)](#configuration-management)
16
+ - [Installation](#installation)
17
+ - [Usage](#usage)
18
+ - [Setup](#setup)
19
+ - [Login and Logout](#login-and-logout)
20
+ - [Contest and Problem Management](#contest-and-problem-management)
21
+ - [Testing and Submissions](#testing-and-submissions)
22
+ - [Interactive Mode](#interactive-mode)
23
+ - [Dependencies](#dependencies)
24
+ - [Troubleshooting](#troubleshooting)
25
+ - [Future Improvements](#future-improvements)
26
+ - [License](#license)
27
+
28
+ ---
29
+
30
+ ## Introduction
31
+
32
+ ChefMate is built to help competitive programmers who participate in CodeChef contests. By automating several routine tasks (such as logging in, opening contest pages, fetching problems, and managing solution submissions), ChefMate removes friction from the contest environment. With its modular design, the tool offers easy configurability and a friendly CLI interface, making the CodeChef contest experience smoother and more productive.
33
+
34
+ ---
35
+
36
+ ## Features
37
+
38
+ - **Browser Management:**
39
+ - Detects and prevents conflicts with existing Chrome sessions.
40
+ - Initializes a ChromeDriver with custom profiles and directories.
41
+ - Configurable options to bypass common Chrome logging and automation detections.
42
+
43
+ - **Automated Contest Interaction:**
44
+ - Logs into CodeChef and navigates to the contest dashboard.
45
+ - Opens contest pages and scrapes problem links and details.
46
+ - Provides an interactive problem tracker to monitor submission statuses.
47
+
48
+ - **Solution Management:**
49
+ - Creates and manages solution directories for contests.
50
+ - Generates template solution files in your preferred programming language.
51
+ - Facilitates opening solution files in your favorite code editor.
52
+
53
+ - **Submission and Testing:**
54
+ - Automates the process of selecting the language from the CodeChef UI.
55
+ - Loads solutions from files and submits them via the browser.
56
+ - Runs sample test cases to verify outputs before actual submission.
57
+ - Displays detailed verdict tables and highlights errors.
58
+
59
+ - **Command-Line Interface (CLI):**
60
+ - Offers a range of commands (setup, login, logout, contest, submit, check, interactive mode).
61
+ - Provides an intuitive interactive mode with a clear menu-driven experience.
62
+ - Uses libraries such as Click and InquirerPy for enhanced user interaction.
63
+
64
+ - **Configuration Management:**
65
+ - Manages user settings (username, password, solution paths, preferred language, Chrome profile, editor preferences) through a JSON configuration file stored in the user's home directory.
66
+ - Ensures persistence and easy updates of user configuration.
67
+
68
+ ---
69
+
70
+ ## Architecture and Code Structure
71
+
72
+ ChefMate’s code is organized into four main modules:
73
+
74
+ ### Browser Manager
75
+
76
+ **File:** `browser_manager.py`
77
+
78
+ - **Purpose:**
79
+ Manages the Chrome browser session using Selenium WebDriver.
80
+ - **Key Functions:**
81
+ - **Initialization:** Sets up the ChromeDriver with options such as user-data-dir and profile-directory for isolated sessions.
82
+ - **Conflict Detection:** Checks if a Chrome instance is already running and prompts the user accordingly.
83
+ - **Session Management:** Provides methods to initialize, operate, and close the browser session.
84
+ - **Highlights:**
85
+ Uses `webdriver_manager` to ensure the correct ChromeDriver is installed and employs custom options to reduce unwanted automation flags.
86
+
87
+ ### Core Functionality
88
+
89
+ **File:** `chefmate_core.py`
90
+
91
+ - **Purpose:**
92
+ Acts as the primary interface to ChefMate functionality. It integrates browser automation with the CodeChef website.
93
+ - **Components:**
94
+ - **Login/Logout:**
95
+ Automates the CodeChef login procedure including form filling, waiting for dashboard elements, and handling potential errors.
96
+ - **Contest Handling:**
97
+ Opens a contest page, scrapes all available problem links, and dynamically creates a problem tracker.
98
+ - **Solution Handling:**
99
+ Searches for or prompts for the correct solution file. Generates solution templates based on the preferred programming language.
100
+ - **Submission and Testing:**
101
+ Provides mechanisms to load code into the CodeChef code editor, submit solutions, and analyze output results by parsing verdict tables.
102
+ - **Interactive Utilities:**
103
+ Functions like typewriter text effects, dashboard redirection, and dynamic problem tracking to enhance the user experience.
104
+
105
+ ### Command Line Interface
106
+
107
+ **File:** `cli.py`
108
+
109
+ - **Purpose:**
110
+ Provides a user-friendly CLI to interact with ChefMate.
111
+ - **Features:**
112
+ - **CLI Commands:**
113
+ Implements commands using Click. Commands include `setup`, `login`, `logout`, `check`, `submit`, `contest`, and `interactive`.
114
+ - **Interactive Mode:**
115
+ An extended menu-driven interface built using InquirerPy that lets users select among different operational modes such as logging in, solving problems, or reconfiguring settings.
116
+ - **UI Enhancements:**
117
+ Uses the Rich library for improved terminal output, such as styled tables and animated loaders.
118
+
119
+ ### Configuration Management
120
+
121
+ **File:** `config.py`
122
+
123
+ - **Purpose:**
124
+ Handles persistent configurations for ChefMate by reading from and writing to a JSON file.
125
+ - **Details:**
126
+ - **Default Configuration:**
127
+ Automatically creates a configuration file in the user's home directory (`~/.chefmate/config.json`) if it does not exist.
128
+ - **Dynamic Updates:**
129
+ Offers methods to get, set, and update various settings including username, password, preferred language, solution file paths, and Chrome user data directories.
130
+ - **Robustness:**
131
+ Includes error handling to recreate a default configuration if the current configuration file is corrupted.
132
+
133
+ ---
134
+
135
+ ## Installation
136
+
137
+ 1. **Clone the Repository:**
138
+
139
+ ```bash
140
+ git clone https://github.com/yourusername/chefmate.git
141
+ cd chefmate
142
+ ```
143
+
144
+ 2. **Set Up a Python Virtual Environment (Optional but Recommended):**
145
+
146
+ ```bash
147
+ python -m venv venv
148
+ source venv/bin/activate # Linux/Mac
149
+ venv\Scripts\activate # Windows
150
+ ```
151
+
152
+ 3. **Install Dependencies:**
153
+
154
+ ChefMate relies on several Python packages. Install them using:
155
+
156
+ ```bash
157
+ pip install -r requirements.txt
158
+ ```
159
+
160
+ > **Note:** Dependencies include libraries like Selenium, webdriver-manager, Click, InquirerPy, Rich, and Colorama. Make sure your environment meets the prerequisites for Selenium and ChromeDriver.
161
+
162
+ ---
163
+
164
+ ## Usage
165
+
166
+ ### Setup
167
+
168
+ Run the setup command to configure ChefMate with your CodeChef credentials, preferred language, editor, and solution file path:
169
+
170
+ ```bash
171
+ python cli.py setup
172
+ ```
173
+
174
+ ### Login and Logout
175
+
176
+ To login to CodeChef, use:
177
+
178
+ ```bash
179
+ python cli.py login
180
+ ```
181
+
182
+ And to logout:
183
+
184
+ ```bash
185
+ python cli.py logout
186
+ ```
187
+
188
+ ### Contest and Problem Management
189
+
190
+ - **Opening a Contest:**
191
+ Launch a contest by providing the contest ID and your division using:
192
+
193
+ ```bash
194
+ python cli.py contest
195
+ ```
196
+
197
+ - **Automatic Problem Scraping:**
198
+ ChefMate will automatically identify and open all the contest problem tabs and display a problem tracker.
199
+
200
+ ### Testing and Submissions
201
+
202
+ - **Check Demo Test Cases:**
203
+ Validate your solution using sample test cases:
204
+
205
+ ```bash
206
+ python cli.py check --problem 1
207
+ ```
208
+
209
+ - **Submitting a Solution:**
210
+ To submit your solution for a given problem:
211
+
212
+ ```bash
213
+ python cli.py submit --problem 1
214
+ ```
215
+
216
+ - **Solving Problems (Template Generation & File Management):**
217
+ ChefMate automatically generates solution template files in a designated contest directory for you to edit. It opens the selected file in your preferred text editor.
218
+
219
+ ### Interactive Mode
220
+
221
+ ChefMate also offers an interactive mode that provides a dynamic menu for operations. Launch it with:
222
+
223
+ ```bash
224
+ python cli.py interactive
225
+ ```
226
+
227
+ In this mode, you can choose among several actions such as login, logout, opening contests, checking demo cases, submitting solutions, and reconfiguring settings.
228
+
229
+ ---
230
+
231
+ ## Dependencies
232
+
233
+ - **Selenium:** For browser automation and web interactions.
234
+ - **webdriver-manager:** To handle ChromeDriver installation and updates.
235
+ - **Click & InquirerPy:** For building the CLI and interactive prompts.
236
+ - **Rich & Colorama:** For styled terminal outputs and color support.
237
+ - **Pandas & Tabulate:** For generating and displaying submission verdict tables.
238
+
239
+ Make sure you have the latest version of Google Chrome installed to ensure compatibility with ChromeDriver.
240
+
241
+ ---
242
+
243
+ ## Troubleshooting
244
+
245
+ - **Chrome Profile in Use:**
246
+ If you receive an error indicating that the Chrome profile is already being used, ensure that all Chrome windows are closed before starting ChefMate.
247
+
248
+ - **Solution File Issues:**
249
+ If ChefMate cannot locate your solution file, double-check the path in the configuration (or re-run the `setup` command).
250
+
251
+ - **Configuration Errors:**
252
+ If the configuration file is corrupted, ChefMate will automatically generate a new default configuration in `~/.chefmate/config.json`.
253
+
254
+ - **Network/Slow Load Problems:**
255
+ For slow networks, ChefMate includes retries during login and test case checks. If problems persist, try restarting your browser or re-running the command.
256
+
257
+ ---
258
+
259
+ ## Future Improvements
260
+
261
+ - **Enhanced Error Reporting:**
262
+ Additional debugging information for failures during submissions and test case validations.
263
+ - **Multi-Language Support:**
264
+ Extending support for more languages and custom code editor integration.
265
+ - **GUI Implementation:**
266
+ A graphical user interface for those who prefer not to use the CLI.
267
+ - **Extended Contest Support:**
268
+ Integration with more competitive programming sites.
269
+
270
+ ---
271
+
272
+ ## License
273
+
274
+ ChefMate is open source software released under the [MIT License](LICENSE).
275
+
276
+ ---
277
+
278
+ ChefMate is designed with flexibility and practicality in mind to reduce the repetitive tasks of contest participation, leaving you free to concentrate on solving problems and improving your competitive programming skills.
279
+
280
+ Happy Coding!
File without changes
@@ -0,0 +1,70 @@
1
+ # browser_manager.py
2
+ import os
3
+ import subprocess
4
+ from colorama import Fore
5
+ from selenium import webdriver
6
+ from selenium.webdriver.chrome.service import Service
7
+ from webdriver_manager.chrome import ChromeDriverManager
8
+ from selenium.common.exceptions import WebDriverException
9
+
10
+ class BrowserManager:
11
+ """Manages browser session and web interactions"""
12
+
13
+ def __init__(self, config):
14
+ self.config = config
15
+ self.driver = None
16
+
17
+ def is_chrome_running(self):
18
+ """Check if Chrome is currently running (Windows only)"""
19
+ try:
20
+ tasks = subprocess.run(['tasklist'], capture_output=True, text=True).stdout.lower()
21
+ return 'chrome.exe' in tasks
22
+ except Exception:
23
+ return False # fallback safely
24
+
25
+ def initialize_driver(self):
26
+ """Initialize and configure Chrome WebDriver"""
27
+
28
+ if self.is_chrome_running():
29
+ print(f"{Fore.RED} Chrome is already running. Please close all Chrome windows before starting ChefMate.\n")
30
+ return False
31
+
32
+ options = webdriver.ChromeOptions()
33
+ options.add_experimental_option('excludeSwitches', ['enable-logging', 'enable-automation'])
34
+ options.add_experimental_option('useAutomationExtension', False)
35
+ options.add_argument('--log-level=3')
36
+
37
+ # Setup isolated profile directory
38
+ user_data_dir = self.config.get("chrome_user_data_dir")
39
+ if not user_data_dir:
40
+ user_data_dir = os.path.join(os.getcwd(), "chefmate_profile")
41
+ os.makedirs(user_data_dir, exist_ok=True)
42
+ options.add_argument(f"--user-data-dir={user_data_dir}")
43
+
44
+ profile = self.config.get("chrome_profile", "Default")
45
+ options.add_argument(f"--profile-directory={profile}")
46
+
47
+ # Optional: prevent common crash issues
48
+ options.add_argument("--no-sandbox")
49
+ options.add_argument("--disable-dev-shm-usage")
50
+ options.add_experimental_option("detach", True)
51
+
52
+ try:
53
+ self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
54
+ self.driver.execute_cdp_cmd(
55
+ "Page.addScriptToEvaluateOnNewDocument",
56
+ {"source": "Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"}
57
+ )
58
+ return True
59
+ except WebDriverException as e:
60
+ if "user data directory is already in use" in str(e):
61
+ print(f"{Fore.RED} Chrome profile is already being used. Close all Chrome windows and try again.\n")
62
+ else:
63
+ print(f"{Fore.RED} Error initializing Chrome: {e}\n")
64
+ return False
65
+
66
+ def close(self):
67
+ """Close the browser"""
68
+ if self.driver:
69
+ self.driver.quit()
70
+ self.driver = None