Created
June 25, 2013 14:41
-
-
Save jfrobbins/5859002 to your computer and use it in GitHub Desktop.
simple way to post gitstats summary to a pump.io server
This file contains hidden or 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
| #! /usr/bin/env python | |
| import sys | |
| import os | |
| import subprocess | |
| def getNoteText(fileText): | |
| for line in fileText: | |
| if line.find("<dl><dt>") >= 0: | |
| return parseLineForGoods(line) | |
| return "stats parsing error" | |
| def parseLineForGoods(line): | |
| #lets try not doing anything | |
| endTag = line.find("</body>") | |
| if endTag >= 0: | |
| line = line[:endTag] | |
| return line | |
| def main(args): | |
| if len(args) <= 0: | |
| print('no repo dir was selected, use default dir') | |
| inFile = "/home/user/code/project/stats/index.html" | |
| else: | |
| inFile = args[0] | |
| if not os.path.isfile(inFile): | |
| print(inFile + ' is not a valid file.') | |
| sys.exit() | |
| with open(inFile, 'r') as f: | |
| print("file is opened") | |
| sfile = f.readlines() #read the lines into a list | |
| f.close() | |
| if sfile: | |
| noteText = getNoteText(sfile) | |
| subprocess.call(['node', '/srv/www/pump.io/bin/pump-post-note', '-s', 'myserver', '-u', 'myusername', '-n', noteText]) | |
| #print noteText | |
| else: | |
| print('file could not be read') | |
| sys.exit() | |
| if __name__ == '__main__': | |
| main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment