Ajay98 commited on
Commit
a549a7c
·
verified ·
1 Parent(s): ab37ffb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -62
app.py CHANGED
@@ -1,69 +1,29 @@
1
- import os
2
- import salesforce
3
- from salesforce import Salesforce
4
- import face_recognition
5
- import cv2
6
- from PIL import Image
7
 
8
- # Salesforce Credentials
9
- sf_username = 'ajayalways411@gmail.com'
10
- sf_password = 'Anusha@310819'
11
- sf_token = 'DcroeUKt0Lc4Lpqgzh9dMxEyQ'
 
12
 
13
- # Email Credentials
14
- email_username = 'ajayk999@gmail.com'
15
- email_password = 'rkgx lepk fykg jbuh'
16
- email_to = 'ajayaklaram07@gmail.com'
17
 
18
- # Initialize Salesforce
19
- sf = Salesforce(username=sf_username, password=sf_password, security_token=sf_token)
 
20
 
21
- # Retrieve records from custom objects
22
- staff_records = sf.query("SELECT Id, Name, AdhardCard__c, contactNumber__c, pancard__c FROM Staff__c")
23
- customer_records = sf.query("SELECT Id, Name, AdhardCardPhoto__c, PhoneNumber__c FROM CustomerData__c")
24
 
25
- # Combine records
26
- records = staff_records['records'] + customer_records['records']
27
 
28
- # Create a dictionary to store known faces
29
- known_faces = {}
30
- for record in records:
31
- image_url = record['Image__c']
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
- # Upload folder from local computer
38
- local_folder = '"C:\Users\nikit\OneDrive\Desktop\images"'
39
- repo = Repository(local_folder, 'ajayalways411/facerecognition')
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)