diff -r 044383f39525 -r be27ed110b50 buildframework/helium/tools/preparation/ci.ant.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/buildframework/helium/tools/preparation/ci.ant.xml Wed Oct 28 14:39:48 2009 +0000 @@ -0,0 +1,319 @@ + + + + + CI related targets + + + + + + + + + + + + + + + +import os +import fileutils +import threadpool +import subprocess +import sys + +dir_path = str(attributes.get('dir-path')) +del_folder_drive = attributes.get('delete-folders-drive') +pool_size = attributes.get('pool-size') +if pool_size != None: + pool_size = str(pool_size) +else: + pool_size = "4" +delete_dirs = [] +found_inputs = [] +# Read config files +self.log(str("Scanning %s." % dir_path)) +for path_ in os.listdir(dir_path): + self.log(str("Checking %s." % path_)) + filename = os.path.join(dir_path, path_) + if (os.path.isfile(filename)): + found_inputs.append(filename) + file_ = open(filename) + for delete_dir in file_.readlines(): + delete_dir = os.path.normpath(delete_dir.strip()) + if (len(delete_dir) > 0) and os.path.isdir(delete_dir): + delete_dirs.append(delete_dir) + file_.close() + +# Delete all dirs based on config +for dir_ in delete_dirs: + try: + if os.sep == '\\': + fileutils.subst(del_folder_drive, dir_) + self.log(str("substed for deleling folders")) + self.log(str("Removing %s\\" % del_folder_drive)) + fileutils.rmtree("%s\\" % del_folder_drive) + fileutils.unsubst(del_folder_drive) + self.log(str("unsbusted substed for deleling folders")) + else: + self.log(str("Removing %s" % dir_)) + fileutils.rmtree(dir_) + except Exception, e: + if os.sep == '\\': + fileutils.unsubst(del_folder_drive) + self.log(str("unsbusted for deleling folders")) + self.log(str("ERROR: %s" % e)) + +# Delete all config files +for path_ in found_inputs: + self.log(str("Deleting %s." % path_)) + os.remove(path_) + + + + + + + + 0): + for ctime_entry in ctime_list: + print count + if (ba_to_leave >= count): + break + file_.write(os.path.join(root_dir, ctime_dict[ctime_entry]) + '\n') + count -= 1 +file_.close() + ]]> + + + + + + + + + + + + + + + + + + + + +import ccm +import nokia.nokiaccm +import configuration +import os +import logging +import traceback +logging.basicConfig(level=logging.INFO) + +databases = [] +delivery = str(attributes.get('delivery')) +sessionFile = str(attributes.get('sessionfile')) +configBuilder = configuration.NestedConfigurationBuilder(open(delivery, 'r')) +configSet = configBuilder.getConfiguration() +for config in configSet.getConfigurations(): + if config['database'] not in databases: + databases.append(config['database']) + +config = configuration.PropertiesConfiguration() +if os.path.exists(sessionFile): + self.log(str("Opening the file %s..." % sessionFile)) + config.load(open(sessionFile, 'r')) +else: + self.log(str("File %s will be created..." % sessionFile)) + +for database in databases: + self.log(str("Checking %s..." % database)) + update_session = True + if config.has_key(database): + sessionid = config[database] + # test if valid + self.log(str("Is session %s still valid?..." % sessionid)) + if ccm.session_exists(sessionid, database=database): + self.log(str("Yes.")) + update_session = False + + if update_session: + try: + self.log(str("Opening a new session for %s..." % database)) + session = nokia.nokiaccm.open_session(database=database) + session.close_on_exit = False + config[database] = session.addr() + except Exception, exc: + traceback.print_exc() + raise exc + +self.log(str("Updating the file %s..." % sessionFile)) +config.store(open(sessionFile, 'w+')) + + + + + + + + + +import ccm +import configuration +import os +import logging +import amara + +logging.basicConfig(level=logging.INFO) + +delivery = str(r'@{delivery}') +sessionFile = str(r'@{sessionfile}') +outputFilename = str(r'@{output}') + +sconfig = configuration.PropertiesConfiguration() + +print "Opening the file %s..." % sessionFile +sconfig.load(open(sessionFile, 'r')) + +configBuilder = configuration.NestedConfigurationBuilder(open(delivery, 'r')) +configSet = configBuilder.getConfiguration() +projects = [] +for config in configSet.getConfigurations(): + if config.type == "checkout" and not config.get_boolean('skip.ci', False): + try: + sessionid = sconfig[config['database']] + session = ccm.Session(None, None, None, ccm_addr=sessionid, close_on_exit=False) + ccmproject = session.create(config.name) + wapath = os.path.join(config['dir'], ccmproject.name, ccmproject.name) + result = session.get_workarea_info(wapath) + print "Found wa for project %s." % result['project'].objectname + if config.has_key('ci.custom.query'): + projects.append({u'database': unicode(config['database']), u'action': u'checkout', u'name': unicode(result['project'].objectname), u'customQuery': unicode(config['ci.custom.query'])}) + else: + projects.append({u'database': unicode(config['database']), u'action': u'checkout', u'name': unicode(result['project'].objectname)}) + except ccm.CCMException, exc: + projects.append({u'database': unicode(config['database']), u'action': u'to_be_checkout', u'name': unicode(config.name)}) + elif config.type == "snapshot" and not config.get_boolean('skip.ci', False): + sessionid = sconfig[config['database']] + session = ccm.Session(None, None, None, ccm_addr=sessionid, close_on_exit=False) + ccmproject = session.create(config.name) + versionfile = os.path.join(config['dir'], ccmproject.name, 'project.version') + if (os.path.exists(versionfile)): + stream = open(versionfile, "r") + projectname = stream.read().strip() + stream.close() + if (projectname != config.name): + if config.has_key('ci.custom.query'): + projects.append({u'database': unicode(config['database']), u'action': u'snapshot_update', u'name': unicode(config.name), u'customQuery': unicode(config['ci.custom.query'])}) + else: + projects.append({u'database': unicode(config['database']), u'action': u'snapshot_update', u'name': unicode(config.name)}) + else: + if config.has_key('ci.custom.query'): + projects.append({u'database': unicode(config['database']), u'action': u'snapshot', u'name': unicode(config.name), u'customQuery': unicode(config['ci.custom.query'])}) + else: + projects.append({u'database': unicode(config['database']), u'action': u'snapshot', u'name': unicode(config.name)}) + +doc = amara.create_document() +root = doc.xml_create_element(u"config") +doc.xml_append(root) + +for project in projects: + p = doc.xml_create_element(u"project", attributes=project) + root.xml_append(p) + +output = open(outputFilename, "w+") +output.write(doc.xml()) +output.close() + + + + + + + + + + + + + + + + + Delivery file not available or 'ci.session.file' not defined or ccm.enabled not set to true. + + + + + + + + + + + + + + + 'ci.project.config' not defined. + + + + + + + + + + + + + + + \ No newline at end of file