Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,69 +1,29 @@
|
|
| 1 |
-
import
|
| 2 |
-
import salesforce
|
| 3 |
-
from salesforce import Salesforce
|
| 4 |
-
import face_recognition
|
| 5 |
-
import cv2
|
| 6 |
-
from PIL import Image
|
| 7 |
|
| 8 |
-
# Salesforce
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
email_password = 'rkgx lepk fykg jbuh'
|
| 16 |
-
email_to = 'ajayaklaram07@gmail.com'
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
# Retrieve records from custom
|
| 22 |
-
|
| 23 |
-
customer_records = sf.query("SELECT Id, Name, AdhardCardPhoto__c, PhoneNumber__c FROM CustomerData__c")
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
| 30 |
-
for record in records:
|
| 31 |
-
|
| 32 |
-
image_response = requests.get(image_url)
|
| 33 |
-
image = face_recognition.load_image_file(BytesIO(image_response.content))
|
| 34 |
-
face_encoding = face_recognition.face_encodings(image)[0]
|
| 35 |
-
known_faces[record['Name']] = face_encoding
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
# Loop through images in uploaded folder
|
| 42 |
-
for file in repo.listdir():
|
| 43 |
-
if file.endswith('.jpg') or file.endswith('.png'):
|
| 44 |
-
image_path = os.path.join(local_folder, file)
|
| 45 |
-
image = face_recognition.load_image_file(image_path)
|
| 46 |
-
face_encodings = face_recognition.face_encodings(image)
|
| 47 |
-
|
| 48 |
-
for face_encoding in face_encodings:
|
| 49 |
-
matches = face_recognition.compare_faces(list(known_faces.values()), face_encoding)
|
| 50 |
-
|
| 51 |
-
if True in matches:
|
| 52 |
-
name = list(known_faces.keys())[matches.index(True)]
|
| 53 |
-
print(f"Face recognized: {name}")
|
| 54 |
-
else:
|
| 55 |
-
print(f"Face unrecognized: Unknown")
|
| 56 |
-
# Send email alert
|
| 57 |
-
import smtplib
|
| 58 |
-
from email.mime.text import MIMEText
|
| 59 |
-
|
| 60 |
-
msg = MIMEText(f"Unknown face detected: {file}")
|
| 61 |
-
msg['Subject'] = 'Unknown Face Detected'
|
| 62 |
-
msg['From'] = email_username
|
| 63 |
-
msg['To'] = email_to
|
| 64 |
-
|
| 65 |
-
server = smtplib.SMTP('(link unavailable)', 587)
|
| 66 |
-
server.starttls()
|
| 67 |
-
server.login(email_username, email_password)
|
| 68 |
-
server.sendmail(email_username, email_to, msg.as_string())
|
| 69 |
-
server.quit()
|
|
|
|
| 1 |
+
from simple_salesforce import Salesforce
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Salesforce credentials
|
| 4 |
+
username = 'your_username'
|
| 5 |
+
password = 'your_password'
|
| 6 |
+
security_token = 'your_security_token'
|
| 7 |
+
domain = 'login' # Use 'test' if using a sandbox
|
| 8 |
|
| 9 |
+
# Connect to Salesforce
|
| 10 |
+
sf = Salesforce(username=username, password=password, security_token=security_token, domain=domain)
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
# Define your custom object API names (replace 'Custom_Object__c' with your actual custom object API names)
|
| 13 |
+
custom_object_1 = 'staff__c'
|
| 14 |
+
custom_object_2 = 'CustomerDat__c'
|
| 15 |
|
| 16 |
+
# Retrieve records from the first custom object
|
| 17 |
+
records_custom_object_1 = sf.query(f"SELECT Name, AdhardCardPhoto__c, pancardPhoto__c, PhoneNumber__c FROM {custom_object_1}")
|
|
|
|
| 18 |
|
| 19 |
+
# Retrieve records from the second custom object
|
| 20 |
+
records_custom_object_2 = sf.query(f"SELECT name, AdhardCard__c,contactNumber__c, pancard__c FROM {custom_object_2}")
|
| 21 |
|
| 22 |
+
# Print retrieved records
|
| 23 |
+
print("Records from Custom Object 1:")
|
| 24 |
+
for record in records_custom_object_1['records']:
|
| 25 |
+
print(record)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
print("\nRecords from Custom Object 2:")
|
| 28 |
+
for record in records_custom_object_2['records']:
|
| 29 |
+
print(record)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|