Skip to content

Commit

Permalink
Read all data on standard input (no more limit at 1MB)
Browse files Browse the repository at this point in the history
  • Loading branch information
flashcode committed Mar 16, 2013
1 parent 56ebda1 commit f1d99d6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions gitchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@
# commits_version | bar | commits by tag/version | git tag
# files_type | pie | files by type (extension) | -
#
# 2013-03-15, Sebastien Helleu <[email protected]>:
# version 0.1: initial release
#

import pygal, os, re, select, subprocess, sys, traceback

VERSION = '0.1'
VERSION = '0.2'

class GitChart:
"""Generate a git stat chart."""
Expand Down Expand Up @@ -291,10 +288,15 @@ def generate(self, name, title, repository, output, in_data=None):
sys.exit(1)

# read data on standard input
in_data = None
inr, outr, exceptr = select.select([sys.stdin], [], [], 0)
if inr:
in_data = os.read(sys.stdin.fileno(), 1024 * 1024) # read max 1MB
in_data = ''
while True:
inr, outr, exceptr = select.select([sys.stdin], [], [], 0)
if not inr:
break
data = os.read(sys.stdin.fileno(), 4096)
if not data:
break
in_data += data.decode('utf-8')

if not chart.generate(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], in_data=in_data):
print('Failed to generate chart: %s' % sys.argv)

0 comments on commit f1d99d6

Please sign in to comment.