Skip to content

Instantly share code, notes, and snippets.

@jfrobbins
Created June 25, 2013 14:41
Show Gist options
  • Select an option

  • Save jfrobbins/5859002 to your computer and use it in GitHub Desktop.

Select an option

Save jfrobbins/5859002 to your computer and use it in GitHub Desktop.
simple way to post gitstats summary to a pump.io server
#! /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