frappe / biometric-attendance-sync-tool Goto Github PK
View Code? Open in Web Editor NEWA simple tool for syncing Biometric Attendance data with your ERPNext server
License: GNU General Public License v3.0
A simple tool for syncing Biometric Attendance data with your ERPNext server
License: GNU General Public License v3.0
Hello Team,
I am trying to use the biometric attendance sync tool to take auto attendance for my local ERPNext instance. I am able to fetch the data from my ZKTeco device; however, I am unable to push the data into ERPNext.
The error log shows a ModuleNotFoundError. I have run bench setup requirements
to make sure that I have the correct modules, but the problem still persists. I have gone through almost all the relevant topics in the forum, but unfortunately, could not find a solution.
I am attaching my error log and logs log for a better understanding. Please note that I'm using version 14, OS Ubuntu 22.04 LTS.
What am I missing here? TIA
Error Log: error.log
Logs log: logs.log
Dear Guys,
I am setting threshold for half day is 6.5 hrs through Bio-metric Auto Attendance . Its works fine in attendance. The employee applied the leave successfully for half day. After the leave approval process, usually the attendance record should be updated on that day.
The leave application made by employee though his login, the attendance record was not updated even leave approved by the Approver.
If the leave application made by either HR user or HR Manager, the attendance record updated successfully.
Pls help me to solve this issue. Thank you
2022-11-17 15:17:04,430 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "1", "ip": "172.16.16.51", "punch_direction": null, "clear_from_device_on_fetch": false}
Traceback (most recent call last):
File "C:\biometric-attendance-sync-tool\venv\lib\site-packages\zk\base.py", line 248, in __send_command
self.__sock.send(top)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "erpnext_sync.py", line 148, in get_all_attendance_from_device
conn = zk.connect()
File "C:\biometric-attendance-sync-tool\venv\lib\site-packages\zk\base.py", line 373, in connect
cmd_response = self.__send_command(const.CMD_CONNECT)
File "C:\biometric-attendance-sync-tool\venv\lib\site-packages\zk\base.py", line 260, in __send_command
raise ZKNetworkError(str(e))
zk.exception.ZKNetworkError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "erpnext_sync.py", line 61, in main
pull_process_and_push_data(device, device_attendance_logs)
File "erpnext_sync.py", line 88, in pull_process_and_push_data
device_attendance_logs = get_all_attendance_from_device(device['ip'], device_id=device['device_id'], clear_from_device_on_fetch=device['clear_from_device_on_fetch'])
File "erpnext_sync.py", line 169, in get_all_attendance_from_device
raise Exception('Device fetch failed.')
Exception: Device fetch failed.
Traceback (most recent call last):
File "push_to_erpnext.py", line 3, in
import requests
ModuleNotFoundError: No module named 'requests'
what is the solution to fix this?
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mn9t21xp/PyQt5/
shift_type_device_mapping = [
{'shift_type_name': ['Shift1'], 'related_device_id': ['test_1','test_2']}
]
the above example is the expected output. But currently, the output has two objects each having one device id and the same shift.
When running the erpnext_sync.py script, the data is fetched every time from the import start date.
This causes the cache memory of the logs directory is getting filled.
Instead of this, what we have to do in the erpnext_sync.py script to fetch only that days data?
And after fetching the data, we have to clear the cache memory automatically.
HR
ERPNext: v13.35.3 (version-13)
Frappe Framework: v13.35.2 (version-13)
manual install
logs directory of biometric-attendance-sync-tool-1.0 is getting filled.
Hello Team,
cat error.log
2020-12-22 08:32:17,318 ERROR 192.168.1.55 exception when fetching from device...
Traceback (most recent call last):
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 249, in __send_command
self.__tcp_data_recv = self.__sock.recv(response_size + 8)
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "erpnext_sync.py", line 138, in get_all_attendance_from_device
conn = zk.connect()
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 373, in connect
cmd_response = self.__send_command(const.CMD_CONNECT)
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 260, in __send_command
raise ZKNetworkError(str(e))
zk.exception.ZKNetworkError: [Errno 104] Connection reset by peer
2020-12-22 08:32:17,324 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "SHOWROOM", "ip": "192.168.1.55", "punch_direction": "AUTO", "clear_from_device_on_fetch": false}
Traceback (most recent call last):
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 249, in __send_command
self.__tcp_data_recv = self.__sock.recv(response_size + 8)
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "erpnext_sync.py", line 138, in get_all_attendance_from_device
conn = zk.connect()
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 373, in connect
cmd_response = self.__send_command(const.CMD_CONNECT)
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 260, in __send_command
raise ZKNetworkError(str(e))
zk.exception.ZKNetworkError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "erpnext_sync.py", line 51, in main
pull_process_and_push_data(device, device_attendance_logs)
File "erpnext_sync.py", line 78, in pull_process_and_push_data
device_attendance_logs = get_all_attendance_from_device(device['ip'], device_id=device['device_id'], clear_from_device_on_fetch=device['clear_from_device_on_fetch'])
File "erpnext_sync.py", line 159, in get_all_attendance_from_device
raise Exception('Device fetch failed.')
Exception: Device fetch failed.
2020-12-22 08:32:20,014 ERROR Error during ERPNext API Call. 1 1605798758.0 WORKSHOP IN Traceback (most recent call last):
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/app.py", line 64, in application
response = frappe.api.handle()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/api.py", line 58, in handle
return frappe.handler.handle()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/handler.py", line 30, in handle
data = execute_cmd(cmd)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/handler.py", line 70, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 1107, in call
return fn(*args, **newargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 70, in add_log_based_on_employee_field
doc.insert()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 238, in insert
self.run_before_save_methods()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 930, in run_before_save_methods
self.run_method("validate")
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 831, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 1116, in composer
return composed(self, method, *args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 1099, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 825, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 15, in validate
self.validate_duplicate_log()
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 26, in validate_duplicate_log
.format("
" + doc_link))
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 409, in throw
msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 388, in msgprint
_raise_exception()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 342, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: This employee already has a log with the same timestamp.
Employee Checkin EMP-CKIN-12-2020-000021
2020-12-22 08:32:20,016 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "WORKSHOP", "ip": "192.168.1.56", "punch_direction": "AUTO", "clear_from_device_on_fetch": false}
Traceback (most recent call last):
File "erpnext_sync.py", line 51, in main
pull_process_and_push_data(device, device_attendance_logs)
File "erpnext_sync.py", line 129, in pull_process_and_push_data
raise Exception('API Call to ERPNext Failed.')
Exception: API Call to ERPNext Failed.
2020-12-22 08:32:34,150 ERROR Error during ERPNext API Call. 1 1607936331.0 ADMIN IN Traceback (most recent call last):
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/app.py", line 64, in application
response = frappe.api.handle()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/api.py", line 58, in handle
return frappe.handler.handle()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/handler.py", line 30, in handle
data = execute_cmd(cmd)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/handler.py", line 70, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 1107, in call
return fn(*args, **newargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 70, in add_log_based_on_employee_field
doc.insert()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 238, in insert
self.run_before_save_methods()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 930, in run_before_save_methods
self.run_method("validate")
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 831, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 1116, in composer
return composed(self, method, *args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 1099, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 825, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 15, in validate
self.validate_duplicate_log()
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 26, in validate_duplicate_log
.format("
" + doc_link))
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 409, in throw
msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 388, in msgprint
_raise_exception()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 342, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: This employee already has a log with the same timestamp.
Employee Checkin EMP-CKIN-12-2020-000300
2020-12-22 08:32:34,151 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "ADMIN", "ip": "192.168.1.57", "punch_direction": "AUTO", "clear_from_device_on_fetch": false}
Traceback (most recent call last):
File "erpnext_sync.py", line 51, in main
pull_process_and_push_data(device, device_attendance_logs)
File "erpnext_sync.py", line 129, in pull_process_and_push_data
raise Exception('API Call to ERPNext Failed.')
Exception: API Call to ERPNext Failed.
2020-12-22 08:32:49,211 ERROR 192.168.1.55 exception when fetching from device...
Traceback (most recent call last):
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 249, in __send_command
self.__tcp_data_recv = self.__sock.recv(response_size + 8)
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "erpnext_sync.py", line 138, in get_all_attendance_from_device
conn = zk.connect()
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 373, in connect
cmd_response = self.__send_command(const.CMD_CONNECT)
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 260, in __send_command
raise ZKNetworkError(str(e))
zk.exception.ZKNetworkError: [Errno 104] Connection reset by peer
2020-12-22 08:32:49,213 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "SHOWROOM", "ip": "192.168.1.55", "punch_direction": "AUTO", "clear_from_device_on_fetch": false}
Traceback (most recent call last):
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 249, in __send_command
self.__tcp_data_recv = self.__sock.recv(response_size + 8)
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "erpnext_sync.py", line 138, in get_all_attendance_from_device
conn = zk.connect()
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 373, in connect
cmd_response = self.__send_command(const.CMD_CONNECT)
File "/home/ubuntu/biometric-attendance-sync-tool/biovenv/lib/python3.7/site-packages/zk/base.py", line 260, in __send_command
raise ZKNetworkError(str(e))
zk.exception.ZKNetworkError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "erpnext_sync.py", line 51, in main
pull_process_and_push_data(device, device_attendance_logs)
File "erpnext_sync.py", line 78, in pull_process_and_push_data
device_attendance_logs = get_all_attendance_from_device(device['ip'], device_id=device['device_id'], clear_from_device_on_fetch=device['clear_from_device_on_fetch'])
File "erpnext_sync.py", line 159, in get_all_attendance_from_device
raise Exception('Device fetch failed.')
Exception: Device fetch failed.
2020-12-22 08:32:51,910 ERROR Error during ERPNext API Call. 1 1605798758.0 WORKSHOP IN Traceback (most recent call last):
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/app.py", line 64, in application
response = frappe.api.handle()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/api.py", line 58, in handle
return frappe.handler.handle()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/handler.py", line 30, in handle
data = execute_cmd(cmd)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/handler.py", line 70, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 1107, in call
return fn(*args, **newargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 70, in add_log_based_on_employee_field
doc.insert()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 238, in insert
self.run_before_save_methods()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 930, in run_before_save_methods
self.run_method("validate")
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 831, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 1116, in composer
return composed(self, method, *args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 1099, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 825, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 15, in validate
self.validate_duplicate_log()
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 26, in validate_duplicate_log
.format("
" + doc_link))
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 409, in throw
msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 388, in msgprint
_raise_exception()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 342, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: This employee already has a log with the same timestamp.
Employee Checkin EMP-CKIN-12-2020-000021
2020-12-22 08:32:51,911 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "WORKSHOP", "ip": "192.168.1.56", "punch_direction": "AUTO", "clear_from_device_on_fetch": false}
Traceback (most recent call last):
File "erpnext_sync.py", line 51, in main
pull_process_and_push_data(device, device_attendance_logs)
File "erpnext_sync.py", line 129, in pull_process_and_push_data
raise Exception('API Call to ERPNext Failed.')
Exception: API Call to ERPNext Failed.
2020-12-22 08:33:16,322 ERROR Error during ERPNext API Call. 1 1607936331.0 ADMIN IN Traceback (most recent call last):
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/app.py", line 64, in application
response = frappe.api.handle()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/api.py", line 58, in handle
return frappe.handler.handle()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/handler.py", line 30, in handle
data = execute_cmd(cmd)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/handler.py", line 70, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 1107, in call
return fn(*args, **newargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 70, in add_log_based_on_employee_field
doc.insert()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 238, in insert
self.run_before_save_methods()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 930, in run_before_save_methods
self.run_method("validate")
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 831, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 1116, in composer
return composed(self, method, *args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 1099, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/model/document.py", line 825, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 15, in validate
self.validate_duplicate_log()
File "/home/frappe/benches/bench-version-13-f2-35/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py", line 26, in validate_duplicate_log
.format("
" + doc_link))
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 409, in throw
msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 388, in msgprint
_raise_exception()
File "/home/frappe/benches/bench-version-13-f2-35/apps/frappe/frappe/init.py", line 342, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: This employee already has a log with the same timestamp.
Employee Checkin EMP-CKIN-12-2020-000300
2020-12-22 08:33:16,323 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "ADMIN", "ip": "192.168.1.57", "punch_direction": "AUTO", "clear_from_device_on_fetch": false}
Traceback (most recent call last):
File "erpnext_sync.py", line 51, in main
pull_process_and_push_data(device, device_attendance_logs)
File "erpnext_sync.py", line 129, in pull_process_and_push_data
raise Exception('API Call to ERPNext Failed.')
Exception: API Call to ERPNext Failed.
ubuntu@ubuntu:~/biometric-attendance-sync-tool/logs$
Good day All
I'm facing an issue When booting up the python files "attendance-sync.py" to start the connection between the ZKTeco device and the ERPNext, it won't start the connection due to an error in the "json.decoder" file in the Python App inside the Middle-Man PC
I keep facing "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" error every time I try to start the service.
P.S: I don't have the ZKTeco software as I never needed to, also, both the ZKTeco and the PC are online and in the same network and pinging correctly.
before this error happened, the connection was working perfectly as I followed the instructions in Biometric Attendance Sync Tool (For ERPNext) GitHub page, and it was fetching the data accordingly and correctly and without any delay.
Please help me find a solution to my problem
Let me know if you need more info regarding the issue
2022-10-29 16:08:02,248 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "1", "ip": "172.16.16.219", "punch_direction": "", "clear_from_device_on_fetch": ""}
Traceback (most recent call last):
File "C:\biometric-attendance-sync-tool-v1.0-win64\biometric-attendance-sync-tool-v1.0-win64\erpnext_sync.py", line 51, in main
pull_process_and_push_data(device, device_attendance_logs)
File "C:\biometric-attendance-sync-tool-v1.0-win64\biometric-attendance-sync-tool-v1.0-win64\erpnext_sync.py", line 129, in pull_process_and_push_data
raise Exception('API Call to ERPNext Failed.')
Exception: API Call to ERPNext Failed.
2022-10-29 16:09:03,328 ERROR Error during ERPNext API Call. 2 1667018015.0 1 Traceback (most recent call last):
File "apps/frappe/frappe/handler.py", line 72, in execute_cmd
method = get_attr(cmd)
File "apps/frappe/frappe/handler.py", line 258, in get_attr
method = frappe.get_attr(cmd)
File "apps/frappe/frappe/init.py", line 1575, in get_attr
return getattr(get_module(modulename), methodname)
File "apps/frappe/frappe/init.py", line 1323, in get_module
return importlib.import_module(modulename)
File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'erpnext.hr.doctype.employee_checkin.employee_checkin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 69, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 54, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 45, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 74, in execute_cmd
frappe.throw(_("Failed to get method for command {0} with {1}").format(cmd, e))
File "apps/frappe/frappe/init.py", line 522, in throw
msgprint(
File "apps/frappe/frappe/init.py", line 490, in msgprint
_raise_exception()
File "apps/frappe/frappe/init.py", line 442, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: Failed to get method for command erpnext.hr.doctype.employee_checkin.employee_checkin.add_log_based_on_employee_field with No module named 'erpnext.hr.doctype.employee_checkin.employee_checkin'
2022-10-29 16:09:03,328 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "1", "ip": "172.16.16.219", "punch_direction": "", "clear_from_device_on_fetch": ""}
Traceback (most recent call last):
File "C:\biometric-attendance-sync-tool-v1.0-win64\biometric-attendance-sync-tool-v1.0-win64\erpnext_sync.py", line 51, in main
pull_process_and_push_data(device, device_attendance_logs)
File "C:\biometric-attendance-sync-tool-v1.0-win64\biometric-attendance-sync-tool-v1.0-win64\erpnext_sync.py", line 129, in pull_process_and_push_data
raise Exception('API Call to ERPNext Failed.')
Exception: API Call to ERPNext Failed.
FileNotFoundError: [Errno 2] No such file or directory: '/opt/erp/apps/biometric-attendance-sync-tool/setup.py'
I checked, and there is no setup.py
If Is there the same file listed as install.py?
In some attendance , it shows working hours, checkin & check out time of the employee if he/she is present. But in some attendance it doesnt shows nothing the above mentioned, only shows the shift type and present. Actually this may not be an issue. please share me the idea of why this occurs.
/home/aruna/Downloads/IMG-20221121-WA0003.jpg
/home/aruna/Downloads/IMG-20221121-WA0005.jpg
When we click on 'set config' button on GUI it removes 'ERPNEXT_VERSION' and punch direction 'IN/OUT' from local_config.py
Anyone tried this script for CAMS Machines?
Thank you so much for the script, but I'm often getting error:
Traceback (most recent call last):
File "push_to_erpnext.py", line 12, in <module>
from zk import ZK, const
ModuleNotFoundError: No module named 'zk'
I've installed the script in root directory, logs show it worked until midnight. I've then installed the script in bench directory, and logs tell me
Traceback (most recent call last):
File "push_to_erpnext.py", line 59, in main
update_shift_last_sync_timestamp(config.shift_type_device_mapping)
File "push_to_erpnext.py", line 212, in update_shift_last_sync_timestamp
if min_pull_timestamp > sync_current_timestamp:
TypeError: '>' not supported between instances of 'datetime.datetime' and 'NoneType'
Is there a further configuration that I'm missing?
Hi @karthikeyan5 ,
This is certainly a FrappeCloud marketplace worthy, where you can attract more users and support subscriptions for your app. Here is the video tutorial on how can you make an application for publishing an app FC marketplace.
https://youtu.be/qwv1grkU5fQ?t=206
Will be great to see you guys getting traction from FC marketplace. Do give a thought. When ready, @NagariaHussain can assist with reviews from our end.
File "erpnext_sync.py", line 52
status.set(f'{device["device_id"]}_push_timestamp', str(datetime.datetime.now()))
What happend here?
When I run command python3 erpnext_sync.py
its showing below error.
Traceback (most recent call last):
File "/home/sigma/frappe-bench/biometric-attendance-sync-tool/erpnext_sync.py", line 319, in
status = pickledb.load('/'.join([config.LOGS_DIRECTORY, 'status.json']), True)
File "/home/sigma/frappe-bench/biometric-attendance-sync-tool/venv/lib/python3.10/site-packages/pickledb.py", line 43, in load
return PickleDB(location, auto_dump, sig)
File "/home/sigma/frappe-bench/biometric-attendance-sync-tool/venv/lib/python3.10/site-packages/pickledb.py", line 54, in init
self.load(location, auto_dump)
File "/home/sigma/frappe-bench/biometric-attendance-sync-tool/venv/lib/python3.10/site-packages/pickledb.py", line 85, in load
self._loaddb()
File "/home/sigma/frappe-bench/biometric-attendance-sync-tool/venv/lib/python3.10/site-packages/pickledb.py", line 102, in _loaddb
self.db = json.load(open(self.loco, 'rt'))
File "/usr/lib/python3.10/json/init.py", line 293, in load
return loads(fp.read(),
File "/usr/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
"_server_messages": "["{"message": "No Employee found for the given employee field value. 'attendance_device_id': HR-ERP-109", "indicator": "red", "raise_exception": 1}"]"
Error While installing the Biometric in Windows while running this command.
Note: I tried with Administrator also getting the same error
python erpnext_sync_win.py install
im getting this error
Installing service ERPNextBiometricPushService
copying host exe 'C:\Users\my-user\erp_biometric\env\Lib\site-packages\win32\pythonservice.exe' -> 'C:\Users\my-user\erp_biometric\env\pythonservice.exe'
copying helper dll 'C:\Users\my-user\erp_biometric\env\Lib\site-packages\pywin32_system32\pywintypes311.dll' -> 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\pywintypes311.dll'
Error installing service: Access is denied. (5)
Here the another forum link
getting below error
2023-04-12 16:46:16,561 ERROR Error during ERPNext API Call. 617 1677643252.0 Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 66, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 54, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 45, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/init.py", line 1607, in call
return fn(*args, **newargs)
TypeError: add_log_based_on_employee_field() missing 2 required positional arguments: 'employee_field_value' and 'timestamp'
the API mentioned in the given documents is an old one.. the new API we are calling is api/method/hrms.hr.doctype.employee_checkin.employee_checkin.add_log_based_on_employee_field
Module
HR
Version
ERPNext: v14.20.3 (HEAD)
Frappe Framework: v14.31.0 (version-14)
Frappe HR: v14.2.1 (HEAD)
Any plan to update the windows executable file?
https://github.com/frappe/biometric-attendance-sync-tool/releases
I receive error below when i ran the exe file
2023-06-26 14:38:00,597 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "1", "ip": "192.168.1.201", "punch_direction": "", "clear_from_device_on_fetch": ""} Traceback (most recent call last): File "C:\Users\Lenovo\Downloads\biometric-attendance-sync-tool-v1.0-win64\biometric-attendance-sync-tool-v1.0-win64\erpnext_sync.py", line 51, in main pull_process_and_push_data(device, device_attendance_logs) File "C:\Users\Lenovo\Downloads\biometric-attendance-sync-tool-v1.0-win64\biometric-attendance-sync-tool-v1.0-win64\erpnext_sync.py", line 129, in pull_process_and_push_data raise Exception('API Call to ERPNext Failed.') Exception: API Call to ERPNext Failed.
Scenario:
1
& 2
logs
folder is deleted or either one of the device is unreachable.For example, there are 2 employees in 2 different locations/ devices with same User ID.
John Doe
in Location/ Device ID 1
with User ID 29
.
Sarah Doe
in Location/ Device ID 2
with same User ID 29
.
Now, if we add another device config to the JSON array in local_config.py
with a different IP address:
devices = [
{'device_id':'1','ip':'123.45.67.89', 'punch_direction': 'AUTO', 'clear_from_device_on_fetch': False},
{'device_id':'2','ip':'321.54.76.98', 'punch_direction': 'AUTO', 'clear_from_device_on_fetch': False}
]
Running erpnext_sync.py
will also push new record of Sarah Doe
with device id 2
.
Expected Behavior:
device id 1
records should have been checked against the new records of device id 2
for same User ID.
User ID should be checked against all Device ID before pushing to ERPNext.
Actual Behavior:
old records from device id 1
are pushed again to ERPNext as new records with device id 2
with same User ID.
Possible Discussion
A sample of attendance_success_log_2.log
:
{"uid": 1235, "user_id": "29", "timestamp": "2023-04-12 16:30:48", "status": 2, "punch": 1}
For status: 2
is presumably device_id: 2
, could we check for duplicate user_id
against all status
and reject those to get pushed to ERPNext.
may I know how to run cronjob for fetching attendance every minute?
I tried as below
crontab -l
* * * * * cd /home/username/frappe-bench/biometric-attendance-sync-tool && source venv/bin/activate && python3 erpnext_sync.py
but its not working.
Update: It's working now.
umar@PC:~$ crontab -l
#!/usr/bin/python3
* * * * * /usr/bin/python3 -c 'from erpnext_sync import main; main()'
Now my question is about schedule time, what is correct way to run this script every minute or @reboot?
2023-06-01 15:14:28,198 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "2", "ip": "192.158.1.50", "punch_direction": null, "clear_from_device_on_fetch": false}
Traceback (most recent call last):
File "C:\Users\rehan\OneDrive\Desktop\biometric-attendance-sync-tool-master-papl\erpnext_sync.py", line 149, in get_all_attendance_from_device
conn = zk.connect()
^^^^^^^^^^^^
File "C:\Users\rehan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\zk\base.py", line 384, in connect
raise ZKErrorResponse("Unauthenticated")
zk.exception.ZKErrorResponse: Unauthenticated
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\rehan\OneDrive\Desktop\biometric-attendance-sync-tool-master-papl\erpnext_sync.py", line 62, in main
pull_process_and_push_data(device, device_attendance_logs)
File "C:\Users\rehan\OneDrive\Desktop\biometric-attendance-sync-tool-master-papl\erpnext_sync.py", line 89, in pull_process_and_push_data
device_attendance_logs = get_all_attendance_from_device(device['ip'], device_id=device['device_id'], clear_from_device_on_fetch=device['clear_from_device_on_fetch'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rehan\OneDrive\Desktop\biometric-attendance-sync-tool-master-papl\erpnext_sync.py", line 170, in get_all_attendance_from_device
raise Exception('Device fetch failed.')
Exception: Device fetch failed.
ERROR exception when calling pull_process_and_push_data function for device{"device_id": "1", "ip": "192.168.100.201", "punch_direction": "AUTO", "clear_from_device_on_fetch": ""}
Traceback (most recent call last):
File "erpnext_sync.py", line 51, in main
pull_process_and_push_data(device, device_attendance_logs)
File "erpnext_sync.py", line 129, in pull_process_and_push_data
raise Exception('API Call to ERPNext Failed.')
Exception: API Call to ERPNext Failed.
I have error says:
frappe.exceptions.ValidationError: This employee already has a log with the same timestamp.
Employee Checkin EMP-CKIN-05-2021-000166
and the status of this employee status : '2'
I tried to delete record that contain this problem from file floor_7_192_168_1_2_last_fetch_dump.json but the problem still exist.|
Any kind of help please?
This code is not running properly zk file is missing so we are not able to import it and execute it
What is the meaning of "Shift" field?
getting the following error:
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.7/http/client.py", line 1344, in getresponse
response.begin()
File "/usr/lib/python3.7/http/client.py", line 306, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.7/http/client.py", line 288, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.7/http/client.py", line 1344, in getresponse
response.begin()
File "/usr/lib/python3.7/http/client.py", line 306, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.7/http/client.py", line 288, in _read_status
raise BadStatusLine(line)
urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine('SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3\r\n'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "push_to_erpnext.py", line 49, in main
pull_process_and_push_data(device, device_attendance_logs)
File "push_to_erpnext.py", line 106, in pull_process_and_push_data
erpnext_status_code, erpnext_message = send_to_erpnext(device_attendance_log['user_id'], device_attendance_log['timestamp'], device['device_id'], device['punch_direction'])
File "push_to_erpnext.py", line 170, in send_to_erpnext
response = requests.request("POST", url, headers=headers, data=data)
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/home/frappe/frappe-bench/push-biometric-erpnext/venv/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine('SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3\r\n'))
I am trying to use the Biometric Attendance Sync Tool (https://github.com/frappe/biometric-attendance-sync-tool) to synchronize attendance data from a local machine to ERPNext hosted on Frappe Cloud. The synchronization process is working, and all data is being posted successfully except for the time field.
The issue I am facing is that the time from the biometric device is not being fetched correctly. Instead, the current time (local machine time) is being used for the time field in ERPNext. I have checked the tool's configuration and ensured that the time zone settings are correct.
Has anyone encountered a similar issue? Is there a way to ensure that the time from the biometric device is accurately synced with ERPNext? Any guidance or suggestions would be greatly appreciated.
Thank you in advance for your help!
import requests
import json
ERPNEXT_API_KEY = 'your_api_key'
ERPNEXT_API_SECRET = 'your_api_secret'
ERPNEXT_URL = 'your_erpnext_url'
data = {
'employee_field_value': '20018',
'timestamp': '2024-04-25 17:04:34',
'device_id': 'deskdevice',
'log_type': 'IN'
}
endpoint = f"{ERPNEXT_URL}/api/method/hrms.hr.doctype.employee_checkin.employee_checkin.add_log_based_on_employee_field"
headers = {
'Authorization': f"token {ERPNEXT_API_KEY}:{ERPNEXT_API_SECRET}",
'Accept': 'application/json',
'Content-Type': 'application/json'
}
response = requests.post(endpoint, headers=headers, json=data)
if response.status_code == 200:
print("Data sent successfully!")
print(response.json())
else:
print("Failed to send data to ERPNext.")
print(response.text)
-----------------------------------------------------------
python3 test.py
Data sent successfully!
{'message': {'name': 'EMP-CKIN-04-2024-000009', 'owner': 'email id masked', 'creation': '2024-04-26 15:43:51.149027', 'modified': '2024-04-26 15:43:51.149027', 'modified_by': 'email id masked', 'docstatus': 0, 'idx': 0, 'employee': 'IDH-0001', 'employee_name': 'Employee', 'log_type': 'IN', 'shift': 'Office Shift', 'time': '2024-04-26 15:43:51.153962', 'device_id': 'deskdevice', 'skip_auto_attendance': 0, 'shift_start': '2024-04-26 08:00:00', 'shift_end': '2024-04-26 17:00:00', 'shift_actual_start': '2024-04-26 06:00:00', 'shift_actual_end': '2024-04-27 00:00:00', 'doctype': 'Employee Checkin'}}
Hello,
I'm trying to connect zkteco k-14 biometrics to my erpnext cloud instance. I setup port forwarding in my device router and get the public IP then put it in the config file but i'm getting the error:
zk.exception.ZKNetworkError: can't reach device (ping MY.PUBLIC.IP)
Anyone have an idea how to do this setup?
Hello,
IMHO, Promotion and Transfer can also have following activities as onboarding and separation too.
For example when employee is promoted, he/she may be required to,
As promotion routine can happen in batch, many employee can be affected.
Note: I am just asking here so I can help doing it. Otherwise, I can make it as my custom module.
WDYT?
File "push_to_erpnext.py", line 221, in
error_logger = setup_logger('error_logger', '/'.join([config.LOGS_DIRECTORY, 'error.log']), logging.ERROR)
File "push_to_erpnext.py", line 203, in setup_logger
if not logger.hasHandlers():
AttributeError: 'Logger' object has no attribute 'hasHandlers'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.