Skip to content

Instantly share code, notes, and snippets.

@lackofdream
Last active April 11, 2016 18:55
Show Gist options
  • Save lackofdream/5a0bc33c4dbabb6f46d019e8c6af31a1 to your computer and use it in GitHub Desktop.
Save lackofdream/5a0bc33c4dbabb6f46d019e8c6af31a1 to your computer and use it in GitHub Desktop.
UpTweet
import subprocess
import tweepy
import os
import socket
a = subprocess.Popen('uptime', stdout=subprocess.PIPE)
s = a.communicate()
res = s[0].decode('utf-8')
hostname = socket.gethostname()
CK = os.environ['CK']
CS = os.environ['CS']
AT = os.environ['AT']
AS = os.environ['AS']
auth = tweepy.OAuthHandler(CK, CS)
auth.set_access_token(AT, AS)
api = tweepy.API(auth)
api.update_status(status=hostname+":\n"+res)
[Unit]
Description=Tweet your uptime output.
[Service]
Environment=CK=
Environment=CS=
Environment=AT=
Environment=AS=
Type=oneshot
ExecStart=/home/g/scripts/uptweet/env/bin/python /home/g/scripts/uptweet/main.py
[Unit]
Description=An uptweet a day, keep SERVER_DOWN away.
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment