dorel14 / 3CX-Cdr-Server

GNU General Public License v3.0
5 stars 3 forks source link

Problem with TZ and Locales #17

Closed dorel14 closed 5 months ago

dorel14 commented 5 months ago

Exception when decoding cdr

Exception occurred during processing of request from ('172.17.17.61', 58050)
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/socketserver.py", line 683, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/lib/python3.9/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/appuser/app/srv/tcp_socket_server.py", line 17, in __init__
    socketserver.BaseRequestHandler.__init__(self, request,
  File "/usr/local/lib/python3.9/socketserver.py", line 747, in __init__
    self.handle()
  File "/home/appuser/app/srv/tcp_socket_server.py", line 29, in handle
    cdrs, cdrdetails = parse_cdr(cdr)
  File "/home/appuser/app/myhelpers/cdr.py", line 126, in parse_cdr
    df_cdr_details["call_date"] = df_cdr["time_start"].apply(
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/series.py", line 4626, in apply
    return SeriesApply(self, func, convert_dtype, args, kwargs).apply()
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/apply.py", line 1025, in apply
    return self.apply_standard()
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/apply.py", line 1076, in apply_standard
    mapped = lib.map_infer(
  File "pandas/_libs/lib.pyx", line 2834, in pandas._libs.lib.map_infer
  File "/home/appuser/app/myhelpers/cdr.py", line 127, in <lambda>
    lambda x: dt.date(dt.strptime(x, date_format))
TypeError: strptime() argument 1 must be str, not float
          So i figured it out :) 

in the .env i had set the info

to be

#TZ informations
TZ=Europe/Stockholm
#Locales informations
LOCALE_LANGUAGE = sv-SE

But when i changed to the same as the template it started working.

#TZ informations
TZ=Europe/Paris
#Locales informations
LOCALE_LANGUAGE = fr_FR

now i get,

200 b'{"historyid":"Call 266531","callid":"37dd3c388f010000_4489","duration":"00:00:19","time_start":"2024-05-02T11:37:43","time_answered":"2024-05-02T11:38:14","time_end":"2024-05-02T11:38:14","reason_terminated":"TerminatedBySrc","from_no":"Ext.10007","to_no":"070XXXXXXX","from_dn":"10007","to_dn":"10020","dial_no":"070XXXXXXX","reason_changed":null,"final_number":"070XXXXXXX","final_dn":"10020","bill_code":"default","bill_rate":"1","bill_cost":"0.33","bill_name":"default","chain":"Chain: Ext.10007;070XXXXXXX;","from_type":"Extension","to_type":"Line","final_type":"Line","from_dispname":"Agent Wilhelmsson","to_dispname":"706766765","final_dispname":"706766765","missed_queue_calls":null,"id":3}'
200 b'{"cdr_historyid":"Call 266531","abandonned":false,"handling_time_seconds":31,"waiting_time_seconds":31,"call_date":"2024-05-02","call_time":"07:37:43","call_week":18,"day_of_week":"jeudi","id":3}'

Originally posted by @MrGlenn-tech in https://github.com/dorel14/3CX-Cdr-Tcp-Server/issues/16#issuecomment-2089815738

dorel14 commented 5 months ago

Hello Tested today and problem is the same but if you set up

LOCALE_LANGUAGE = sv_SE

instead of

LOCALE_LANGUAGE = sv-SE 

it works perfectly