Created
April 25, 2014 13:18
-
-
Save eduardocl/11289269 to your computer and use it in GitHub Desktop.
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 subprocess | |
def executar(str): | |
''' Executa um comendo no shell retornando o stdout ''' | |
args = str.split(' ') | |
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
out, err = p.communicate() | |
return out | |
out = executar('find . -name *.java') | |
total = 0 | |
for p in out.split('\n'): | |
if p.strip(): | |
comando = 'wc -l {0}'.format(p.strip()) | |
num,nome = executar(comando).split(' ') | |
total = total + int(num) | |
print "Total de linhas", total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment