Last active
April 11, 2016 18:55
-
-
Save lackofdream/5a0bc33c4dbabb6f46d019e8c6af31a1 to your computer and use it in GitHub Desktop.
UpTweet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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