{"id":1122,"date":"2017-01-21T22:23:33","date_gmt":"2017-01-22T06:23:33","guid":{"rendered":"https:\/\/partofthething.com\/thoughts\/?p=1122"},"modified":"2017-01-22T12:24:04","modified_gmt":"2017-01-22T20:24:04","slug":"running-fortune-in-a-python-virtualenv","status":"publish","type":"post","link":"https:\/\/partofthething.com\/thoughts\/running-fortune-in-a-python-virtualenv\/","title":{"rendered":"Running fortune in a Python virtualenv"},"content":{"rendered":"<p>I learned on reddit the other day about the sudo &#8220;insults&#8221; capability where it throws shade at you when you mistype the password. I configured it everywhere I could, but I wanted more, so I came across <code>cowsay<\/code> and <code>fortune<\/code>.<\/p>\n<pre class=\"crayon:false\">$ fortune | cowsay\r\n\/ SHIFT TO THE LEFT! SHIFT TO THE RIGHT! \\\r\n\\ POP UP, PUSH DOWN, BYTE, BYTE, BYTE!\u00a0\u00a0 \/\r\n\u00a0----------------------------------------\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \\\u00a0\u00a0 ^__^\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \\\u00a0 (oo)\\_______\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (__)\\\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 )\\\/\\\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ||----w |\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ||\u00a0\u00a0\u00a0\u00a0 ||<\/pre>\n<p>Needless to say&#8230; wow.<\/p>\n<p><!--more--><\/p>\n<p>Anyway so I wanted to get <code>fortune<\/code> going in my <a href=\"https:\/\/partofthething.com\/thoughts\/?cat=75\">home-automation setup using home-assistant <\/a>(which is running in a virtualenv) as a quote-of-the-day kind of thing but I kept running into trouble! My setup was:<\/p>\n<pre class=\"crayon:false\">sensor:\r\n\u00a0- platform: command_line\r\n\u00a0\u00a0\u00a0 command: \"fortune -a -s\"\r\n\u00a0\u00a0\u00a0 scan_interval: 600\r\n\u00a0\u00a0\u00a0 name: quote<\/pre>\n<p>But I kept getting:<\/p>\n<pre class=\"crayon:false\">subprocess.CalledProcessError: Command 'fortune -a -s' returned non-zero exit status 127<\/pre>\n<p>Ugh!<\/p>\n<p>It took me literally forever to realize that <a href=\"https:\/\/anonscm.debian.org\/cgit\/collab-maint\/fortune-mod.git\/tree\/?id=refs\/heads\/master\">the package<\/a> comes with two utilities that go in <code>\/usr\/bin: unstr and strfile. <\/code>These weren&#8217;t being found because the virtualenv&#8217;s <code>bin<\/code> folder was taking precedence. Two symlinks later, and I&#8217;m up and running!<\/p>\n<pre class=\"crayon:false\">lrwxrwxrwx 1 hass nogroup\u00a0\u00a0\u00a0\u00a0\u00a0 14 Jan 21 22:21 unstr -&gt; \/usr\/bin\/unstr\r\nlrwxrwxrwx 1 hass nogroup\u00a0\u00a0\u00a0\u00a0\u00a0 16 Jan 21 22:07 strfile -&gt; \/usr\/bin\/strfile<\/pre>\n<p>Hope someone else finds this useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I learned on reddit the other day about the sudo &#8220;insults&#8221; capability where it throws shade at you when you mistype the password. I configured it everywhere I could, but I wanted more, so I came across cowsay and fortune. $ fortune | cowsay \/ SHIFT TO THE LEFT! SHIFT TO THE RIGHT! \\ \\ &hellip; <a href=\"https:\/\/partofthething.com\/thoughts\/running-fortune-in-a-python-virtualenv\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Running fortune in a Python virtualenv<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[3],"tags":[],"class_list":["post-1122","post","type-post","status-publish","format-standard","hentry","category-computers"],"_links":{"self":[{"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/posts\/1122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/comments?post=1122"}],"version-history":[{"count":4,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/posts\/1122\/revisions"}],"predecessor-version":[{"id":1130,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/posts\/1122\/revisions\/1130"}],"wp:attachment":[{"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/media?parent=1122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/categories?post=1122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/tags?post=1122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}