Skip to content

Feature/jubin reverse engineer lab - #1

Open
GW-Bootcamp-ADSI-F6-G1 wants to merge 3 commits into
hollali:mainfrom
GW-Bootcamp-ADSI-F6-G1:feature/jubin_reverse_engineer_lab
Open

Feature/jubin reverse engineer lab#1
GW-Bootcamp-ADSI-F6-G1 wants to merge 3 commits into
hollali:mainfrom
GW-Bootcamp-ADSI-F6-G1:feature/jubin_reverse_engineer_lab

Conversation

@GW-Bootcamp-ADSI-F6-G1

@GW-Bootcamp-ADSI-F6-G1 GW-Bootcamp-ADSI-F6-G1 commented Jul 21, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • Bug Fixes

    • Fixed product quantity resets when clearing a bill.
    • Corrected email modal behavior.
    • Fixed Hair Spray quantities appearing incorrectly on printed bills.
    • Improved bill searches to show an error only after the full search completes.
    • Enhanced bill printing across Windows and non-Windows systems, including temporary file cleanup.
  • Style

    • Updated the application window title and displayed version heading.

Auto Commit Bot and others added 3 commits July 21, 2026 02:20
Added v1.0 to the main heading label to track the application version visually.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bump version in heading label from v1.0 to v1.1 for testing git push functionality.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Billing GUI updates

Layer / File(s) Summary
Entry reset behavior
main.py
clear() now deletes entry contents before inserting zero defaults for grocery and drink fields.
Bill communication and lookup
main.py
Email modal-loop handling, cross-platform temporary-file printing, and post-scan invalid bill reporting are updated.
Bill output and window presentation
main.py
Hair Spray output uses hairsprayEntry, and the main window title and displayed version heading are changed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and reads like a branch name, so it does not clearly describe the billing app changes. Use a concise, descriptive title that names the main change, such as billing GUI and print/email flow fixes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
main.py (1)

141-161: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Race condition on file deletion and deprecated temporary file usage.

tempfile.mktemp() has been deprecated since Python 2.3 due to security risks (race conditions). Additionally, on Windows, os.startfile(..., 'print') delegates printing to an external application asynchronously. If os.remove(file) is called immediately afterwards on line 161, the file is often deleted before the print spooler has a chance to read it, causing printing to fail silently or display a "file not found" error in the external program.

Replace mktemp with mkstemp and defer the file deletion on Windows to give the spooler time to process it.

🐛 Proposed fix
-        file = tempfile.mktemp('.txt')
-        with open(file, 'w') as f:
-            f.write(textarea.get(1.0, END))
+        fd, file_path = tempfile.mkstemp(suffix='.txt')
+        with os.fdopen(fd, 'w') as f:
+            f.write(textarea.get(1.0, END))
         
         system = platform.system()
         if system == "Windows":
-            os.startfile(file, 'print')
+            os.startfile(file_path, 'print')
+            
+            # Windows printing is async; defer cleanup and ignore errors if still locked
+            def cleanup():
+                try:
+                    os.remove(file_path)
+                except OSError:
+                    pass
+            textarea.after(5000, cleanup)
         else:  # macOS, Linux, and other Unix-like systems
             try:
-                subprocess.run(['lpr', file], check=True)
+                subprocess.run(['lpr', file_path], check=True)
             except subprocess.CalledProcessError:
                 messagebox.showerror('Error', 'Printing failed. No default printer found.')
             except FileNotFoundError:
                 messagebox.showerror('Error', 'Printing system (lpr) not found.')
-        
-        # Clean up the temporary file
-        os.remove(file)
+            finally:
+                # Clean up synchronously for Linux/macOS
+                try:
+                    os.remove(file_path)
+                except OSError:
+                    pass
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@main.py` around lines 141 - 161, Update print_bill to use tempfile.mkstemp
instead of tempfile.mktemp, close the returned file descriptor before writing,
and track the generated path. Preserve the existing Unix cleanup after lpr
completes, but on Windows defer os.remove until the asynchronous os.startfile
print operation has had time to consume the file.
🧹 Nitpick comments (1)
main.py (1)

168-172: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a context manager for file handling and simplify text insertion.

If an exception occurs while reading the file or inserting text, f.close() won't be executed, leading to a leaked file descriptor. Using a with statement ensures the file is safely closed in all cases. Additionally, reading the entire file contents at once is more concise and performant than iterating line by line.

♻️ Proposed refactor
-            f=open(f'bills/{i}','r')
-            textarea.delete(1.0,END)
-            for data in f:
-                textarea.insert(END,data)
-            f.close()
+            with open(f'bills/{i}', 'r') as f:
+                textarea.delete(1.0, END)
+                textarea.insert(END, f.read())
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@main.py` around lines 168 - 172, Update the file-reading block to use a
context manager around open so the file is closed even when reading or textarea
insertion fails, and replace the line-by-line loop with a single read of the
file contents passed to textarea.insert. Remove the manual f.close() call while
preserving the existing textarea clearing and display behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@main.py`:
- Around line 141-161: Update print_bill to use tempfile.mkstemp instead of
tempfile.mktemp, close the returned file descriptor before writing, and track
the generated path. Preserve the existing Unix cleanup after lpr completes, but
on Windows defer os.remove until the asynchronous os.startfile print operation
has had time to consume the file.

---

Nitpick comments:
In `@main.py`:
- Around line 168-172: Update the file-reading block to use a context manager
around open so the file is closed even when reading or textarea insertion fails,
and replace the line-by-line loop with a single read of the file contents passed
to textarea.insert. Remove the manual f.close() call while preserving the
existing textarea clearing and display behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa94fc85-29f8-480d-8089-e59dd7ac9711

📥 Commits

Reviewing files that changed from the base of the PR and between 04cc777 and 892f41a.

📒 Files selected for processing (1)
  • main.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant