35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# reference the ZK Soap PHP namespace
|
|
from ZKFingerprint import Fingerprint, UserAttendanceEncoder, UserAttendanceEncoderCSV
|
|
import json
|
|
|
|
# initial
|
|
machine = Fingerprint('10.35.7.12', '80', '0')
|
|
|
|
# get machine status
|
|
print("Machine Status : "+machine.getStatus()) # connected | disconnected
|
|
|
|
# get all log data
|
|
#print(machine.getAttendance()) # return List of Attendance Log
|
|
|
|
# get all log data with date
|
|
print(machine.getAttendance('all', '2022-05-01')) # return List of Attendance Log
|
|
|
|
# get all log data with date range
|
|
#print(machine.getAttendance('all', '2022-05-01', '2022-05-10')) # return List of Attendance Log
|
|
|
|
# get specific pin log data
|
|
#print(machine.getAttendance('1')) # return List of Attendance Log
|
|
# OR List
|
|
#print(machine.getAttendance(['1', '2'])) # return List of Attendance Log
|
|
|
|
# get exported json format
|
|
user_attendance_data = machine.getAttendance()
|
|
json_data = json.dumps(user_attendance_data, cls=UserAttendanceEncoder, indent=4)
|
|
file_path = 'user_attendance2.json'
|
|
with open(file_path, 'w') as file:
|
|
file.write(json_data)
|
|
|
|
print(f"JSON data for user attendance saved to {file_path}")
|
|
|
|
UserAttendanceEncoderCSV.encode_to_csv(user_attendance_data, 'user_attendance.txt')
|
|
print("Data written to user_attendance.txt") |