owenwater / alfred-cal

Displays a calendar with Alfred Workflow
MIT License
63 stars 13 forks source link

Workflow saves an empty "settings.json" file, and stops working. #8

Closed boris-chervenkov closed 9 years ago

boris-chervenkov commented 9 years ago

Every once in a while, the workflow saves the settings.json file as an empty file / 0 bytes. When this happens, the workflow does not work anymore.

Usually (but not every time), the error occurs when I enter some invalid input, like "cal <fweiuf" , then I add/remove characters from the query string. The error might also occur when I type the input a bit too fast.

When I run the main script via iPython:

In [1]: from main import Main

In [2]: main = Main("")

In [3]: main.execute()
16:18:58 workflow.py:2070 DEBUG    Workflow version : 1.2.1
16:18:58 workflow.py:1473 DEBUG    Reading settings from `/Users/XXXXX/Library/Application Support/Alfred 2/Workflow Data/zmin.calendar/settings.json` ...
16:18:58 workflow.py:2088 ERROR    No JSON object could be decoded
Traceback (most recent call last):
  File "workflow/workflow.py", line 2081, in run
    func(self)
  File "main.py", line 39, in main
    self.init_settings()
  File "main.py", line 29, in init_settings
    self.minus = self.wf.settings.setdefault('minus', self.minus_default)
  File "workflow/workflow.py", line 1475, in settings
    self._default_settings)
  File "workflow/workflow.py", line 900, in __init__
    self._load()
  File "workflow/workflow.py", line 911, in _load
    for key, value in json.load(file_obj, encoding='utf-8').items():
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 290, in load
    **kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 351, in loads
    return cls(encoding=encoding, **kw).decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
16:18:58 workflow.py:2106 DEBUG    Workflow finished in 0.009 seconds.
An exception has occurred, use %tb to see the full traceback.

.

And the UI shows:

screen shot 2015-08-05 at 16 11 11

When I edit the settings.json file to contain an empty JSON object, the workflow starts working again.

owenwater commented 9 years ago

Hi @boris-chervenkov,

Have you tried the latest update? This issue should be fixed by v1.2.1. Please let me know if the problem persists.

boris-chervenkov commented 9 years ago

Hi, @owenwater,

I thought I was using the latest version of the workflow, but apparently I was not. I'll let you know if something comes up.

Thank you again for the wonderful Alfred workflow :o)

Boris