Last active
August 29, 2015 14:05
-
-
Save pelson/a9e8b25496309fa2997d to your computer and use it in GitHub Desktop.
Allows control the travis-ci machine via a text file, as a poor-man's keyboard.
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
Allows control the travis-ci machine via a text file, as a poor-man's keyboard. | |
Note: This is only a hacky example when I got frustrated by the queue time for travis-ci builds. | |
Run with the URL of the command file as the only argument: | |
python listen_and_execute.py https://gist.githubusercontent.com/pelson/a9e8b25496309fa2997d/raw/commands.txt |
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
# sudo apt-get install g++-3.4 --force-yes | |
gcc -v | |
#exit | |
locate gcc | |
#ls /usr/local/bin | |
ls /usr/bin/*gcc* | |
/usr/bin/gcc-3.4 -v | |
/usr/bin/g++-3.4 -v | |
sudo rm /usr/bin/gcc | |
sudo rm /usr/bin/g++ | |
sudo ln -s /usr/bin/gcc-3.4 /usr/bin/gcc | |
sudo ln -s /usr/bin/g++-3.4 /usr/bin/g++ | |
g++ --version | |
#export CC=gcc-3.4 | |
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64 | |
exit |
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 os | |
import urllib2 | |
import time | |
def listen_and_execute(url, max_iterations=60, sleep_time=10): | |
last_contents = '' | |
for i in xrange(max_iterations): | |
response = urllib2.urlopen(url) | |
contents = response.read().strip() | |
if last_contents != contents: | |
for command in contents.split('\n'): | |
if command == 'exit': | |
print 'Exiting.' | |
exit() | |
print 'Executing {}'.format(command) | |
os.system(command) | |
last_contents = contents | |
time.sleep(sleep_time) | |
if __name__ == '__main__': | |
import sys | |
url = sys.argv[1] | |
listen_and_execute(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment