pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.62k stars 207 forks source link

Broken when new event on Termux #1010

Open MajoranaOedipus opened 3 years ago

MajoranaOedipus commented 3 years ago

I installed khal on Termux of my Android phone (EMUI 10.0.0) via pip install khal, and created a config file following the instruction. khal calendar works. After setting the default calendar, I tried khal new 13:30 lunch and I got these:

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/khal", line 8, in <module>
    sys.exit(main_khal())
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/khal/cli.py", line 386, in new
    new_func(
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/khal/controllers.py", line 353, in new_from_string
    new_from_args(
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/khal/controllers.py", line 379, in new_from_args
    collection.new(event)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/khal/khalendar/khalendar.py", line 207, in new
    event.href, event.etag = self._storages[calendar].upload(event)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/khal/khalendar/vdir.py", line 214, in upload
    fpath, etag = self._upload_impl(item, href)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/khal/khalendar/vdir.py", line 233, in _upload_impl
    return fpath, get_etag_from_file(f)
  File "/data/data/com.termux/files/usr/lib/python3.9/contextlib.py", line 124, in __exit__
    next(self.gen)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/atomicwrites/__init__.py", line 169, in _open
    self.commit(f)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/atomicwrites/__init__.py", line 204, in commit
    move_atomic(f.name, self._path)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/atomicwrites/__init__.py", line 111, in move_atomic
    return _move_atomic(src, dst)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/atomicwrites/__init__.py", line 59, in _move_atomic
    os.link(src, dst)
AttributeError: module 'os' has no attribute 'link'

And the following is what I wrote in my config file:

[calendars]
[[private]]
path = ~/.config/khal/private
type = calendar
color = yellow

[default]
default_calendar = private
highlight_event_days = True

[highlight_days]
color = light blue
default_color = yellow                      
[locale]
timeformat = %H:%M
dateformat = %Y-%m-%d
longdateformat = %Y-%m-%d
datetimeformat = %Y-%m-%d %H:%M
longdatetimeformat = %Y-%m-%d %H:%M

I don't know if it is about the OS. Please help me!

d7415 commented 3 years ago

The python package included with Termux is explicitly built without os.link support because hardlink support on android is sketchy. atomicwrites in turn uses os.link. We could add detection for edge cases, but I think this would be better handled upstream. Ideally in android.

fsou34 commented 1 year ago

Thanks for this great piece of software. It is a pity that support for hard links is broken in Android. I wish to know if there is any risk using this hack with Khal in Termux? https://karobben.github.io/2022/05/02/Blog/khal/