PrashanthB461 commited on
Commit
575cce5
·
verified ·
1 Parent(s): 37f7ef0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -19
app.py CHANGED
@@ -157,26 +157,27 @@ def push_report_to_salesforce(violations, score, pdf_path, pdf_file):
157
  pdf_url = f"{CONFIG['PUBLIC_URL_BASE']}{os.path.basename(pdf_path)}" if pdf_path else ""
158
 
159
  record_data = {
160
- "Compliance_Score__c": score,
161
- "Violations_Found__c": len(violations),
162
- "Violations_Details__c": violations_text,
163
- "Status__c": "Pending",
164
- "PDF_Report_URL__c": pdf_url
165
- }
166
- record = sf.Safety_Video_Report__c.create(record_data)
167
- record_id = record["id"]
168
- logger.info(f"Salesforce record created: {record_id}")
 
169
 
170
- if pdf_file:
171
- uploaded_url = upload_pdf_to_salesforce(sf, pdf_file, record_id)
172
- if uploaded_url:
173
- sf.Safety_Video_Report_c.update(record_id, {"PDF_Report_URL_c": uploaded_url})
174
- pdf_url = uploaded_url
175
 
176
- return record_id, pdf_url
177
- except Exception as e:
178
- logger.error(f"Salesforce record creation failed: {e}")
179
- return None, ""
180
 
181
  # ==========================
182
  # Safety Score Calculation
@@ -296,7 +297,7 @@ def gradio_interface(video_file):
296
  violation_name = v["violation"].replace("no_", "").replace("unsafe_", "")
297
  row = f"| {violation_name:<13} | {v['timestamp']:.2f}s | {v['confidence']:.2f} | {v['bounding_box']} |"
298
  rows.append(row)
299
- violation_table = header + separator + "\n".join(rows)
300
 
301
  # Format snapshots as a bullet list
302
  snapshots_text = "No snapshots captured."
 
157
  pdf_url = f"{CONFIG['PUBLIC_URL_BASE']}{os.path.basename(pdf_path)}" if pdf_path else ""
158
 
159
  record_data = {
160
+ "Compliance_Score__c": scorea) {
161
+ "Compliance_Score__c": score,
162
+ "Violations_Found__c": len(violations),
163
+ "Violations_Details__c": violations_text,
164
+ "Status__c": "Pending",
165
+ "PDF_Report_URL__c": pdf_url
166
+ }
167
+ record = sf.Safety_Video_Report__c.create(record_data)
168
+ record_id = record["id"]
169
+ logger.info(f"Salesforce record created: {record_id}")
170
 
171
+ if pdf_file:
172
+ uploaded_url = upload_pdf_to_salesforce(sf, pdf_file, record_id)
173
+ if uploaded_url:
174
+ sf.Safety_Video_Report__c.update(record_id, {"PDF_Report_URL__c": uploaded_url})
175
+ pdf_url = uploaded_url
176
 
177
+ return record_id, pdf_url
178
+ except Exception as e:
179
+ logger.error(f"Salesforce record creation failed: {e}")
180
+ return None, ""
181
 
182
  # ==========================
183
  # Safety Score Calculation
 
297
  violation_name = v["violation"].replace("no_", "").replace("unsafe_", "")
298
  row = f"| {violation_name:<13} | {v['timestamp']:.2f}s | {v['confidence']:.2f} | {v['bounding_box']} |"
299
  rows.append(row)
300
+ violation ladies = header + separator + "\n".join(rows)
301
 
302
  # Format snapshots as a bullet list
303
  snapshots_text = "No snapshots captured."