andreasgrill / auto-selfcontrol

Small utility to schedule start and stop times of SelfControl
MIT License
305 stars 37 forks source link

API v3 Uncaught exception #48

Closed aysark closed 4 years ago

aysark commented 4 years ago

Thank you for this useful tool. I just upgraded selfcontrol and auto-selfcontrol (using brew) and then i run: auto-selfcontrol activate

I get the following exception and it doesn't run selfcontrol nor apply the blocklist.

> Active schedule found for SelfControl!
> Start SelfControl (this could take a few minutes)

> Detected API v3
Uncaught exception:
<class 'subprocess.CalledProcessError'>
Command '['/Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl', '501', '--install', '/usr/local/etc/auto-selfcontrol/blocklist', '2020.05.23T12:00:00--700']' returned non-zero exit status 74
Traceback (most recent call last):
  File "/usr/local/bin/auto-selfcontrol.py", line 446, in <module>
    run(SETTINGS_DIR)
  File "/usr/local/bin/auto-selfcontrol.py", line 97, in run
    run_api_v3(config, settings_dir)
  File "/usr/local/bin/auto-selfcontrol.py", line 168, in run_api_v3
    execSelfControl(config, ["--install", blocklist_path, block_end_date])
  File "/usr/local/bin/auto-selfcontrol.py", line 322, in execSelfControl
    stderr=subprocess.STDOUT
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 223, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command '['/Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl', '501', '--install', '/usr/local/etc/auto-selfcontrol/blocklist', '2020.05.23T12:00:00--700']' returned non-zero exit status 74
gcohara commented 4 years ago

I also have this issue, but I my first auto-selfcontrol activate worked fine. I attempted to reinstall after noticing the block hadn't come on. I believe it's something to do with the times being fed to SelfControl.

In my case, the script gave the error:

CalledProcessError: Command '['/Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl', '501', '--install', '/usr/local/etc/auto-selfcontrol/blocklist', '2020.05.23T07:00:00+0100']' returned non-zero exit status 74

So, I attempted to run

sudo /Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl 501 --install /usr/local/etc/auto-selfcontrol/blocklist 2020.05.23T07:00:00+0100

in the terminal, which gave the error

2020-05-23 21:23:22.194 org.eyebeam.SelfControl[17394:328437] Error: Block end date argument 2020.05.23T07:00:00+0100 is invalid

I then tried 2020-05-23T24:00:00+0100 for the ending date argument, which did work. I'm not sure that the hyphens were necessary. Since this worked I am unable to test any further, since I just get

2020-05-23 21:35:32.813 org.eyebeam.SelfControl[17463:335370] ERROR: Block is already running

but I suspect that the Python script was attempting to start a block ending at 7am today (in the past) rather than a block ending at 7am tomorrow (2020.05.24T07:00:00+0100).

andreasgrill commented 4 years ago

@aysark Could you check if your problem is solved with the current version? You can simply update through brew upgrade auto-selfcontrol.

andreasgrill commented 4 years ago

@gcohara Thanks for looking into this issue. I've fixed the block end date to use the hyphens instead of the dots.

aysark commented 4 years ago

@andreasgrill thank you that fixed it!

liufrank commented 4 years ago

I'm still seeing a similar issue with the dashes on the latest SelfConrtol and Auto-SelfControl.: CalledProcessError: Command '['/Applications/SelfControl.app/Contents/MacOS/org.eyebeam.SelfControl', '501', '--install', '/usr/local/etc/auto-selfcontrol/blocklist', '2020-07-22T09:00:00-0700']' returned non-zero exit status 74

gcohara commented 4 years ago

@liufrank, I had this issue too, and it seems it's also been mentioned in #50 . My workaround was to split the overnight block in two - e.g for a block from 10pm to 9am, split this into two blocks from 10pm to 11.59pm and 00.01am to 9am.