Closed ZaxonXP closed 5 months ago
You can try wrap fcntl.ioctl with try: except: Example:
def pre_format_html_hook(url, html):
with open('/dev/stdin', 'w') as fd:
for char in "Ma":
try:
fcntl.ioctl(fd, termios.TIOCSTI, char)
except Exception as e:
pass
The second fcntl in similar way.
That worked well. Article was stored and no more error is displayed. Thanks!
@rkd77:
I have some remaining small issue with this solution. Currently when I do dumping the page to the text file the Ma
word is also send to the terminal. This screws up my another script where I use the fzf/dmenu
for selection what to do with the saved article. After elinks dumps the file it also typing Ma
on the terminal which select non existing item.
Is there a way to avoid printing this Ma
word to the terminal?
I think the reason it was used is to jump back to the marked a
position after reloading the page.
There is no good solution, because Python hooks have no access to browser options AFAIR. You can workaround it like this: Before dump, touch some file, check in python pre_format hook whether touched file exists and return if exists, dump. remove touched file.
touch /tmp/dump
elinks --dump someurl
rm -f /tmp/dump
At the begining of pre_format_html_hook:
if os.path.exists('/tmp/dump'):
return
Your solution was good. It is working and creating temp file is no problem. Thanks!
I use Newsboat RSS reader to get new articles. The ones which I want to read I dump as a text file using a macro script which is calling Elinks browser. The script is as follows:
This is assigned in the
~/.newsboat/config
as a macroSo when I use the macro I get the following error:
Here is a content of my
hooks.py
script:How can get rid of this error message?
Kind regards, Piotr