` c@s>ddlZddlZddlZGdddeZdS)Nc@sFeZdZddddZddZddZd d ZdS) ComponentNFcCs||_||_d|_g|_g|_|rtjj|jd}tjj|s}|j|d}|st d|jdn |d|_|j|d|_tjj|jd}tjj|r t |d}|j j |_WdQRX|j|d |_d |jd |jd |ji}t |d )}|j tj|ddddWdQRXnrt |d}tj|j }WdQRX|st d|jd|d |_|d |_|d |_|j s|jd rt d|jdS)Npkg5zprint-value-COMPONENT_NAMEz Component returns empty name at .rzprint-package-namesz pkg5.fmrisrzprint-required-packagesnamefmris dependenciesw sort_keysTindentz&Component pkg5 data is empty for path z$Empty list of supplied FMRIs path = )debugpathrsupplied_packagesrequired_packagesosjoinisfilerun_make ValueErroropenread splitlineswritejsondumpsloads)selfrr Zcomponent_pkg5_fileZcomponent_nameZcomponent_pkg5_fmris_filefdatar ;/jenkins/jobs/oi-userland/workspace/tools/bass/component.py__init__#s@        ,   zComponent.__init__cCs=d}t|j}t|j}|j|r9d}|S)NFT)setrr intersection)r componentresults1s2r r r!requiredMs zComponent.requiredc Csg}|jr"tjd||tjdd|gdtjdtjd|dd}|j\}}x'|jD]}|j|jqwW|jr|j d krtjd |j ||S) NzExecuting 'gmake %s' in %sgmakez-sstdoutstderrcwduniversal_newlinesTrz exit: %d, %s) r logger subprocessPopenPIPE communicaterappendrstrip returncode)rrZtargetsr&procr+r,outr r r!rWs     zComponent.run_makecCsEd|j}|ddj|j7}|ddj|j7}|S)NzComponent: Path: %s z Provides Package(s): %s z z Required Package(s): %s )rrrr)rr&r r r!__str__ns zComponent.__str__)__name__ __module__ __qualname__r"r)rr9r r r r!r"s * r)rr0robjectrr r r r!s