Manishearth/ChatExchange

examples/web_viewer.py is not working

Opened this issue · 1 comments

When I tried to run the examples/web_viewer.py, it says:

Username: [REDACTED]
Password: 
INFO:chatexchange.client.Client:Logging in.
INFO:chatexchange.client.Client:Logged in.
INFO:chatexchange.client.Client:Worker thread reporting for duty.
INFO:chatexchange.rooms.Room:Queued message 'Hello, world!' for room_id #1.
INFO:chatexchange.client.Client:Now serving customer 1, ('send', 1, 'Hello, world!')
INFO:chatexchange.rooms.Room:Queue length: 0.
Exception in thread ChatExchange: message_sender for chat.stackexchange.com:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/peter/Py/chatexchange/ChatExchange/chatexchange/client.py", line 229, in _worker
    self._do_action_despite_throttling(next_action)
  File "/home/peter/Py/chatexchange/ChatExchange/chatexchange/client.py", line 296, in _do_action_despite_throttling
    response = self._br.send_message(room_id, text)
  File "/home/peter/Py/chatexchange/ChatExchange/chatexchange/browser.py", line 318, in send_message
    return self.post_fkeyed(
  File "/home/peter/Py/chatexchange/ChatExchange/chatexchange/browser.py", line 136, in post_fkeyed
    return self.post(url, data, headers)
  File "/home/peter/Py/chatexchange/ChatExchange/chatexchange/browser.py", line 116, in post
    return self._request('post', url, data, headers, with_chat_root)
  File "/home/peter/Py/chatexchange/ChatExchange/chatexchange/browser.py", line 105, in _request
    response.raise_for_status()
  File "/home/peter/.local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://chat.stackexchange.com/chats/1/messages/new
127.0.0.1 - - [06/Jun/2023 08:31:27] "GET / HTTP/1.1" 200 -
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 48520)
Traceback (most recent call last):
  File "/usr/lib/python3.10/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.10/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.10/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.10/socketserver.py", line 747, in __init__
    self.handle()
  File "/usr/lib/python3.10/http/server.py", line 432, in handle
    self.handle_one_request()
  File "/usr/lib/python3.10/http/server.py", line 420, in handle_one_request
    method()
  File "/home/peter/Py/webviewerchat.py", line 101, in do_GET
    self.send_page()
  File "/home/peter/Py/webviewerchat.py", line 155, in send_page
    self.wfile.write('''<!doctype html ng-cloak>
  File "/usr/lib/python3.10/socketserver.py", line 826, in write
    self._sock.sendall(b)
TypeError: a bytes-like object is required, not 'str'
----------------------------------------
127.0.0.1 - - [06/Jun/2023 08:31:28] code 404, message Not Found
127.0.0.1 - - [06/Jun/2023 08:31:28] "GET /favicon.ico HTTP/1.1" 404 -
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 48532)
Traceback (most recent call last):
  File "/usr/lib/python3.10/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.10/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.10/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.10/socketserver.py", line 747, in __init__
    self.handle()
  File "/usr/lib/python3.10/http/server.py", line 432, in handle
    self.handle_one_request()
  File "/usr/lib/python3.10/http/server.py", line 421, in handle_one_request
    self.wfile.flush() #actually send the response if not already done.
ValueError: I/O operation on closed file.
----------------------------------------

What is this and what should I do?

Unsure, I'm happy to accept PRs fixing this but I personally don't have time to investigate