Skip to content

Instantly share code, notes, and snippets.

@wangyangkobe
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangyangkobe/b39dbfb1c1cd15b1ab44 to your computer and use it in GitHub Desktop.
Save wangyangkobe/b39dbfb1c1cd15b1ab44 to your computer and use it in GitHub Desktop.
cba_build_package
#!/vobs/ims/common/tools_root/cdfrt/dist/unitprep/TDP-Python-CXS1040058-R2A01/contained/DT_Python/bin/python
import os
from subprocess import Popen, PIPE
import traceback
import threading
import time
import sys
AIT_DIR = r"/vobs/ims/sbg/src/delivery/sgcPSR/SiteConfigurationPackage/AIT"
SGC_PSR = r"/vobs/ims/sbg/src/delivery/sgcPSR"
user = os.environ['USER']
targetDir = os.path.join(os.path.expanduser('~'), "cba_%s" % user) + "/"
# Implementation of Ticker class
class Ticker(threading.Thread):
def __init__(self, msg):
threading.Thread.__init__(self)
self.msg = msg
self.event = threading.Event()
def __enter__(self):
self.start()
def __exit__(self, ex_type, ex_value, ex_traceback):
self.event.set()
self.join()
def run(self):
sys.stdout.write(self.msg)
while not self.event.isSet():
sys.stdout.write(".")
sys.stdout.flush()
self.event.wait(5)
def run():
os.system(r"rm -rf /vobs/ims/sbg/src/delivery/sgcPSR/SiteConfigurationPackage/AIT/*")
os.chdir("/vobs/ims/sbg/src")
#os.system("cdf-build -j 32 -r CXP9025193_1")
print 'Do operation: \"cdf-build -j 32 -r CXP9025193_1\"'
with Ticker("Please waiting "):
process = Popen(["cdf-build -j 32 -r CXP9025193_1"], stdout=PIPE, stderr=PIPE, shell=True)
stdout, stderr = process.communicate()
print
if stdout.find("Build successful"):
print "Building of unit CXC1737957 is successful"
else:
print stdout
return
os.chdir(r"/vobs/ims/sbg/src/delivery/sgcPSR/")
print "\n"
os.system("cdf-build -p -d ./ CXP9025193_1")
os.system(r"\cp PSR-sgcPSR-CXP9025193_1-R1A01.tar.gz {0}".format(targetDir))
print "finish: PSR-sgcPSR-CXP9025193_1-R1A01.tar.gz!"
print "\n"
print "*" * 50
os.system("cdf-cgt -p sgc_plugin_otp -d . configuration-otp.xml")
if not os.path.exists("{0}/SiteConfigurationPackage/AIT/sgc_plugin_otp.tar.gz".format(SGC_PSR)):
return
os.system(r"\cp {0}/SiteConfigurationPackage/AIT/sgc_plugin_otp.tar.gz {1}".format(SGC_PSR, targetDir))
print "finish: %s!" % "sgc_plugin_otp.tar.gz"
print "\n"
print "*" * 50
os.system("cdf-cgt -p sgc_plugin_otp-os -d . configuration-otp-os.xml")
if not os.path.exists("{0}/SiteConfigurationPackage/AIT/sgc_plugin_otp-os.tar.gz".format(SGC_PSR)):
return
os.system(r"\cp {0}/SiteConfigurationPackage/AIT/sgc_plugin_otp-os.tar.gz {1}".format(SGC_PSR, targetDir))
print "finish: %s!" % "sgc_plugin_otp-os.tar.gz"
print "\n"
print "*" * 50
os.system("cdf-cgt -p sgc_plugin_all -d . configuration-all.xml")
if not os.path.exists("{0}/SiteConfigurationPackage/AIT/sgc_plugin_all.tar.gz".format(SGC_PSR)):
return
os.system(r"\cp {0}/SiteConfigurationPackage/AIT/sgc_plugin_all.tar.gz {1}".format(SGC_PSR, targetDir))
print "finish: %s!" % "sgc_plugin_all.tar.gz"
print "\n"
def success_info():
print "++++++++++++++++++++++++++++++++++++++++++++++"
print "++ Build Successfully! ++"
print "++ Your package is Here: ++"
print "++ {} ++".format(targetDir)
print "++++++++++++++++++++++++++++++++++++++++++++++"
def fail_info():
print "++++++++++++++++++++++++++++++++++++++++++++++"
print "++ Build Failed! ++"
print "++++++++++++++++++++++++++++++++++++++++++++++"
if __name__ == '__main__':
if not os.path.exists(targetDir):
os.system("mkdir {0}".format(targetDir))
try:
run()
success_info()
except:
traceback.print_exc()
fail_info()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment