# coding=utf-8
import os
import os.path
import subprocess
import sys
import time
# print "ssssss"
os.chdir(sys.argv[1])
subprocess.Popen("chmod a+x "+"./gradlew", shell=True)
# s=subprocess.Popen("./gradlew clean build", shell=True)
# if s.wait()==0:
# print "-------"
# else:
# print "======="
# subprocess.Popen("rm "+sys.argv[0], shell=True)
# print "Command execution completed"
c=subprocess.Popen('./gradlew clean', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if c.wait()==0:
print 'clean Successful implementation '
b=subprocess.Popen('./gradlew build', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, err = b.communicate()
for line in out.splitlines():
print(line)
# if b.wait()==0:
# print ' Compile successfully '
# else:
# print ' Compile failed '
else:
print 'clean Execution failure '