def on_any_event(self, event): logging.info('%s, %s' % (event.event_type, event.src_path)) if str(event.src_path).lower() == conf.watchdog_notify_ready_file: msg = comm.getMsg(conf.watchdog_notify_ready_file) if msg.lower() == conf.ready_string: self.bReady = True comm.saveFile(conf.watchdog_notify_ready_file, conf.not_ready_string) logging.info('-----------------------------------------') logging.info('start building aladdin installers') #top20 bind1 always build, using full xml aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_full, bDownload=False, bBuild=True, bindType='baidusd', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile='', bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False) #top20 bind1 always build, using daily xml aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_daily, bDownload=False, bBuild=True, bindType='baidusd', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile='', bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False) ############################################################################################################################ #top20 unbind update build, using full xml aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_full, bDownload=False, bBuild=False, bindType='baidusd_nobind', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile='', bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False) #top20 unbind update build, using daily xml aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_daily, bDownload=False, bBuild=False, bindType='baidusd_nobind', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile='', bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False) ############################################################################################################################ #top20-80 unbind update build, using full xml aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_full, bDownload=False, bBuild=False, bindType='baidusd_nobind', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_20_80_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile=conf.baidusd_packinfo_20_80_excluded_file, bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False) #top20-80 unbind update build, using daily xml aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_daily, bDownload=False, bBuild=False, bindType='baidusd_nobind', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_20_80_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile=conf.baidusd_packinfo_20_80_excluded_file, bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False) logging.info('-----------------------------------------') logging.info('build complete') self.bReady = False
def convert_encoding(filename, target_encoding): # convert file from the source encoding to target encoding logging.info('converting %s to utf-8 file format' % filename) content = codecs.open(filename, 'r').read() content = content.decode('gbk') #.encode(source_encoding) codecs.open(filename, 'w', encoding=target_encoding).write(content) ctx = comm.getMsg(filename) ctx = ctx.replace('encoding="gbk"', 'encoding="utf-8"') comm.saveFile(filename, ctx)
def AddBuildId(buildIdFile): buildId=1 if os.path.exists(buildIdFile): data=comm.getMsg(buildIdFile) try: buildId=str(int(data)+1) except: buildId="121" comm.saveFile(buildIdFile,buildId) return buildId
def AddBuildId(buildIdFile): buildId = 1 if os.path.exists(buildIdFile): data = comm.getMsg(buildIdFile) try: buildId = str(int(data) + 1) except: buildId = "121" comm.saveFile(buildIdFile, buildId) return buildId
def update_buildver(num): buildverFile = conf.buildver_headerfile cont = '''//Auto-generated file by ../../Tools/AutoBuild/rewrite_version.py //DO NOT EDIT!! #ifndef __BUILD_VER_H_INCLUDED__ #define __BUILD_VER_H_INCLUDED__ #define VER_BUILD %s //Build Version #endif // __BUILD_VER_H_INCLUDED__ ''' % num comm.saveFile(buildverFile,cont)
def generateUpdateList(aladdin_update_list, type, subfolder): ctx = '' for item in aladdin_update_list: ctx += item + '\r\n' if ctx != '': clname = type.replace(';','_') clname += '-changelist_' clname += subfolder + '_' clname += str(datetime.datetime.now()).replace(':','-').replace(' ','-').replace('.','_') clname += '.txt' if not os.path.isdir(conf.aladdin_update_pool_folder + 'changelist'): os.mkdir(conf.aladdin_update_pool_folder + 'changelist') comm.saveFile(conf.aladdin_update_pool_folder + 'changelist\\' + clname, ctx)
def update_buildver(num): buildverFile = conf.buildver_headerfile cont = '''//Auto-generated file by ../../Tools/AutoBuild/rewrite_version.py //DO NOT EDIT!! #ifndef __BUILD_VER_H_INCLUDED__ #define __BUILD_VER_H_INCLUDED__ #define VER_BUILD %s //Build Version #endif // __BUILD_VER_H_INCLUDED__ ''' % num comm.saveFile(buildverFile, cont)
def main(argc, argv): if argc != 3 and argc != 4: print 'usage:python rewrite_version.py <product_shortname (bdm|bdkv)> <build_type (daily|force)> [update]' return buildIdFile = '' nsiFile = '' nsiBuildlineFile = '' productMacro = '' bUpdate = False if argc == 4 and argv[3] == 'update': bUpdate = True if argv[1].lower() == 'bdm': nsiBuildlineFile = conf.bdm_nsifile_buildline if argv[2].lower() == 'daily': buildIdFile = conf.buildIdFile nsiFile = conf.bdm_nsifile_daily elif argv[2].lower() == 'version': buildIdFile = conf.versionBuildIdFile nsiFile = conf.bdm_nsifile_version elif argv[2].lower() == 'partial': buildIdFile = conf.customBuildIdFile nsiFile = conf.bdm_nsifile_partial elif argv[1].lower() == 'bdkv': nsiBuildlineFile = conf.bdkv_nsifile_buildline if argv[2].lower() == 'daily': buildIdFile = conf.kvBuildIdFile nsiFile = conf.bdkv_nsifile_daily elif argv[2].lower() == 'version': buildIdFile = conf.kvVersionBuildIdFile nsiFile = conf.bdkv_nsifile_version elif argv[2].lower() == 'partial': buildIdFile = conf.kvCustomBuildIdFile nsiFile = conf.bdkv_nsifile_partial if buildIdFile and nsiFile: num = AddBuildId(buildIdFile) num = comm.setBuildNumber(argv[1].lower(), num, True, bUpdate) severtime = time.strftime("%Y-%m-%d %I:%M:%S") update_nsis_build_info(nsiFile, '!define RELEASE_VERSION', '!define BUILD_TIME', num, severtime) update_buildver(num) verStr = comm.getInstallerVersion(argv[1].lower()).split('.') update_version_define(nsiFile, verStr) update_product_version(nsiFile, verStr) buildlinestr = '!define BUILD_LINE "%s"' % verStr[2] comm.saveFile(nsiBuildlineFile, buildlinestr)
def main(argc,argv): if argc != 3 and argc != 4: print 'usage:python rewrite_version.py <product_shortname (bdm|bdkv)> <build_type (daily|force)> [update]' return buildIdFile = '' nsiFile = '' nsiBuildlineFile = '' productMacro = '' bUpdate = False if argc == 4 and argv[3] == 'update': bUpdate = True if argv[1].lower() == 'bdm': nsiBuildlineFile = conf.bdm_nsifile_buildline if argv[2].lower() == 'daily': buildIdFile = conf.buildIdFile nsiFile = conf.bdm_nsifile_daily elif argv[2].lower() == 'version': buildIdFile = conf.versionBuildIdFile nsiFile = conf.bdm_nsifile_version elif argv[2].lower() == 'partial': buildIdFile = conf.customBuildIdFile nsiFile = conf.bdm_nsifile_partial elif argv[1].lower() == 'bdkv': nsiBuildlineFile = conf.bdkv_nsifile_buildline if argv[2].lower() == 'daily': buildIdFile = conf.kvBuildIdFile nsiFile = conf.bdkv_nsifile_daily elif argv[2].lower() == 'version': buildIdFile = conf.kvVersionBuildIdFile nsiFile = conf.bdkv_nsifile_version elif argv[2].lower() == 'partial': buildIdFile = conf.kvCustomBuildIdFile nsiFile = conf.bdkv_nsifile_partial if buildIdFile and nsiFile: num = AddBuildId(buildIdFile) num = comm.setBuildNumber(argv[1].lower(),num,True,bUpdate) severtime = time.strftime("%Y-%m-%d %I:%M:%S") update_nsis_build_info(nsiFile, '!define RELEASE_VERSION', '!define BUILD_TIME',num,severtime) update_buildver(num) verStr = comm.getInstallerVersion(argv[1].lower()).split('.') update_version_define(nsiFile,verStr) update_product_version(nsiFile,verStr) buildlinestr = '!define BUILD_LINE "%s"' % verStr[2] comm.saveFile(nsiBuildlineFile,buildlinestr)
def main(argc, argv): #set sysencoding to utf-8 reload(sys) sys.setdefaultencoding('utf-8') os.chdir(sys.path[0]) #init logging system, it's told logging is threadsafe, so do NOT need to sync logging.basicConfig(format = '%(asctime)s - %(levelname)s: %(message)s', level=logging.DEBUG, stream = sys.stdout) #parse arguments parser = argparse.ArgumentParser() parser.add_argument('-f', '--download-full-xml-file', action='store_true', default=False, dest='bUpdateFull', help='download the latest full xml file') parser.add_argument('-d', '--download-daily-xml-file', action='store_true', default=False, dest='bUpdateDaily', help='download the latest daily xml file') parser.add_argument('-t', '--translate-to-utf8', action='store_true', default=False, dest='bTranslate', help='auto translate the xml file to utf-8 file format') parser.add_argument('-b', '--autostart-build', action='store_true', default=False, dest='bBuild', help='auto trigle the switch to build') args = parser.parse_args() logging.info('-----------------------------------------') logging.info('download-full-xml : ' + str(args.bUpdateFull)) logging.info('download-daily-xml : ' + str(args.bUpdateDaily)) logging.info('auto-translate : ' + str(args.bTranslate)) logging.info('auto-build : ' + str(args.bBuild)) command = '' try: if args.bUpdateFull: command = conf.wget_exe + ' ' + conf.url_full_xml + ' -O ' + conf.aladdin_xml_full logging.info(command) os.system(command) if args.bTranslate: convert_encoding(conf.aladdin_xml_full, 'utf-8') if args.bUpdateDaily: command = conf.wget_exe + ' ' + conf.url_daily_xml + ' -O ' + conf.aladdin_xml_daily logging.info(command) os.system(command) if args.bTranslate: convert_encoding(conf.aladdin_xml_daily, 'utf-8') if args.bBuild: comm.saveFile(conf.watchdog_notify_ready_file, conf.ready_string) except Exception, e: comm.saveFile(conf.watchdog_notify_ready_file, str(e))