Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fail gracefully when camera goes missing #47

Closed
kemitche opened this Issue May 18, 2012 · 6 comments

Comments

Projects
None yet
5 participants

I use lolcommits on my laptop. At the office, my docking station has a webcam attached, and all goes well, but when on the go, there's no webcam, and lolcommits fails noisily. This means I have to disable lolcommits (and then remember to re-enable it later) any time I commit outside the office.

lolcommits should fail gracefully, perhaps with a WARNING message, when the webcam is unavailable (or provide the option to do so)

Owner

mroth commented May 18, 2012

Hrm, good idea. I'll look into this, I'm not quite sure how to approach. Can you please dump the error output you get when it does this?

Contributor

prydonius commented May 18, 2012

Well, so long as imagesnap, mplayer and CommandCam fail gracefully when there's no camera, the easiest test would be to just see if the image was saved, if not exit, if so continue.

Here is the output I see when committing without the camera attached. It appears @prydonius' approach might work well, if I'm reading it right.

kemitche@kemi-reddit:~/reddit/public$ git ci -am "Sample commit"
*** Preserving this moment in history.
/usr/lib/ruby/1.8/fileutils.rb:506:in `rename': No such file or directory - /home/kemitche/.lolcommits/public/tmpdir880/00000006.jpg or /home/kemitche/.lolcommits/public/tmp_snapshot.jpg (Errno::ENOENT)
    from /usr/lib/ruby/1.8/fileutils.rb:506:in `mv'
    from /usr/lib/ruby/1.8/fileutils.rb:1402:in `fu_each_src_dest'
    from /usr/lib/ruby/1.8/fileutils.rb:1418:in `fu_each_src_dest0'
    from /usr/lib/ruby/1.8/fileutils.rb:1400:in `fu_each_src_dest'
    from /usr/lib/ruby/1.8/fileutils.rb:495:in `mv'
    from /var/lib/gems/1.8/gems/lolcommits-0.1.2/lib/lolcommits.rb:91:in `capture'
    from /var/lib/gems/1.8/gems/lolcommits-0.1.2/bin/lolcommits:94:in `do_capture'
    from /var/lib/gems/1.8/gems/lolcommits-0.1.2/bin/lolcommits:173
    from /var/lib/gems/1.8/bin/lolcommits:19:in `load'
    from /var/lib/gems/1.8/bin/lolcommits:19
[lolc 4f0d613] Sample commit
 1 files changed, 1 insertions(+), 0 deletions(-)
Contributor

prydonius commented May 21, 2012

Another idea would be to use a blank image (like a lolcat), and put the commit message and sha on it so that it doesn't mess up you're lolcommit history.

And once again it would decide to use a blank image if no webcam image is saved.

I solved this by adding another post-commit hook to set LOLCOMMITS_DEVICE before firing lolcommits.

in .git/hooks/post-commit:

export LOLCOMMITS_DEVICE="$(imagesnap -l | tail -n1)"
lolcommits --capture --stealth --fork
Collaborator

matthutchinson commented Nov 9, 2014

I think best approach here, is to quit/abort nicely (with a warning) if no camera was detected at all, or a bad LOLCOMMITS_DEVICE has been set..

matthutchinson added a commit that referenced this issue Nov 21, 2014

Merge pull request #237 from mroth/better-failover-for-missing-camera…
…-issue-47

Better failover when no snapshot created closes #47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment