Remove envparas reference
authorLingchaox Xin <lingchaox.xin@intel.com>
Thu, 11 Apr 2013 06:38:25 +0000 (14:38 +0800)
committerLingchaox Xin <lingchaox.xin@intel.com>
Thu, 11 Apr 2013 08:14:21 +0000 (16:14 +0800)
And drop boss-reports.py, job_aiaiaicheck.py, they will not be
used in the future.

Change-Id: Ic71b2b96f68025b5b7abc719311c2d415b439cfa

boss-reports.py [deleted file]
common/envparas.py [deleted file]
job_aiaiaicheck.py [deleted file]
job_imager.py
job_obsevent_dispatcher.py
job_repomaker.py

diff --git a/boss-reports.py b/boss-reports.py
deleted file mode 100755 (executable)
index 3964c1e..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-#!/usr/bin/python
-
-from __future__ import with_statement
-import os, sys, io
-import ConfigParser
-import optparse
-from string import Template
-from builddiff.imagediff import ImageDiff
-from builddiff.repodiff import builddiff
-
-try:
-  from lxml import etree
-except ImportError:
-  try:
-    # Python 2.5
-    import xml.etree.cElementTree as etree
-  except ImportError:
-    try:
-      # Python 2.5
-      import xml.etree.ElementTree as etree
-    except ImportError:
-      try:
-        # normal cElementTree install
-        import cElementTree as etree
-      except ImportError:
-        try:
-          # normal ElementTree install
-          import elementtree.ElementTree as etree
-        except ImportError:
-          print("Failed to import ElementTree from any known place")
-
-from common.envparas import export
-
-PARAM_LIST = ['RELATIVE_URI',
-              'release_build_id']
-
-export(PARAM_LIST, locals())
-
-P_NAME = 'reports' # component name in boss
-
-DEFAULTCONF = """
-[$pname]
-daemon = Yes
-logfile = /var/log/boss/${pname}.log
-pidfile = /var/run/boss/${pname}.pid
-runas_user = obsrun
-runas_group = obsrun
-
-# ${pname} specific configrations
-
-project_name = tizen.org
-
-release_dir = /srv/www/download/releases
-snapshots_dir = /srv/www/download/snapshots
-"""
-
-def find_desc(name, configs):
-  for ks in configs.findall('config'):
-    n = ks.find('name').text
-    n = n[0:n.rindex('.ks')]
-    if name == n or name == "meego-%s" %n:
-      #print "%s=%s" %(n,name)
-      return ks.find('description').text
-
-def compare(buildid, relative, project_set, oldid = None, output_dir = None):
-    """Support tizen
-    """
-
-    if buildid.startswith('tizen'):
-        _tizen_compare(buildid, relative, project_set, oldid, output_dir)
-    else:
-        pass
-
-def _tizen_compare(buildid, relative, project_set, oldid, output_dir):
-    distro = 'tizen'
-    release_dir = project_set['release_dir']
-    parent = project_set['snapshots_dir'] + '/' + relative
-
-    style_dir = "/usr/share/python-builddiff/styles/" + distro
-
-    # sample buildid:
-    #   tizen_20111228.2
-    #   tizen-1.0_20111228.1
-    try:
-        sid = buildid.split("_")
-        distro_ver = sid[0]
-        builds = sid[-1]
-        major, build_no  = builds.split('.')
-    except:
-        print 'Invalid build id: %s' % buildid
-        return None
-
-    # daily
-    daily = []
-    weekly = []
-    compare_to = []
-    if oldid:
-        compare_to = [(oldid, parent)]
-    else:
-        daily_dir = release_dir + '/daily/' + relative.lstrip('/')
-        if os.path.isdir(daily_dir):
-            _d = os.listdir(daily_dir)
-            daily = sorted([(x, daily_dir) for x in _d if x.startswith(distro_ver)],
-                           key = lambda bid: map(int, bid[0].split('_')[-1].split('.')))[-2:]
-        else:
-            daily = []
-
-        print "daily: %s" %daily
-
-        weekly_dir = release_dir + '/weekly/' + relative.lstrip('/')
-        if os.path.isdir(weekly_dir):
-            _d = os.listdir(weekly_dir)
-            weekly = sorted([(x, weekly_dir) for x in _d if x.startswith(distro_ver)],
-                           key = lambda bid: map(int, bid[0].split('_')[-1].split('.')))[-1:]
-        else:
-            weekly = []
-
-        print "weekly: %s" %weekly
-
-        sys.stdout.flush()
-        compare_to = weekly+daily
-
-    print "going to compare with ", compare_to
-    sys.stdout.flush()
-
-    if buildid and len(compare_to) > 0:
-        if output_dir is not None:
-            outputdir = "%s/%s" %(output_dir, buildid)
-        else:
-            outputdir = "%s/%s/builddata/reports" %(parent, buildid)
-
-        print "All reports will be stored in %s" %outputdir
-        if not os.path.exists(outputdir):
-            os.mkdir(outputdir, 0755)
-
-        for old, olddir in set(compare_to):
-            oldurl = "%s/%s" %(olddir, old)
-            newurl = "%s/%s" %(parent, buildid)
-
-            repodiff = builddiff(oldurl, newurl, outputdir = outputdir, project_name = project_set['project_name'], relative_uri=relative)
-
-            imgdiff = ImageDiff(oldurl, newurl, project_name = project_set['project_name'])
-            imgdiff.repodiff = repodiff
-            imgdiff.outputdir = outputdir
-
-            if not os.path.exists(imgdiff.outputdir):
-                os.mkdir(imgdiff.outputdir, 0755)
-
-            for image in os.listdir("%s/%s/images" %(parent, buildid)):
-                if os.path.exists("%s/%s/images" %(olddir, old)):
-                  print "working on %s" %image
-                  imgdiff.image_diff(image, relative)
-
-        create_report(parent, buildid, style_dir, outputdir)
-    else:
-        print "nothing to report"
-
-    sys.stdout.flush()
-
-def create_report(parent, id, styledir, output):
-    files = {}
-    repos = []
-    for f in os.listdir(output):
-        if 'repodiff' in f:
-            nohtml =  f[9:f.rindex('.html')]
-            old, new = nohtml.split("--")
-            repos.append( { 'html': f, 'new': new, 'old': old } )
-            continue
-
-        if '.html' in f and f != 'index.html':
-            nohtml =  f[0:f.rindex('.html')]
-            ks, old, new = nohtml.split("--")
-
-            configs = etree.parse('%s/%s/builddata/image-configs.xml' %(parent, id))
-            desc = find_desc(ks, configs)
-            manfile = '%s/%s/images/%s/MANIFEST' %(parent, id, ks)
-            if os.path.exists(manfile):
-                manifest = open(manfile, "r")
-                manifest_lines = [m.split() for m in manifest.readlines()]
-                manifest.close()
-            else:
-                manifest_lines = []
-
-            if not files.has_key(ks):
-                files[ks] = [{'new': new, 'old': old, 'description': desc, 'html': f, 'manifest': manifest_lines}]
-            else:
-                files[ks].append({'new': new, 'old': old, 'description': desc, 'html': f, 'manifest': manifest_lines})
-
-    xmlroot = etree.Element("report")
-    etree.SubElement(xmlroot, "build_id").text = id
-    for k in files.keys():
-        images = etree.SubElement(xmlroot, "images")
-        image = etree.SubElement(images, "image")
-        etree.SubElement(image, "name").text = k
-        etree.SubElement(image, "description").text = files[k][0]['description']
-        imgf = etree.SubElement(image, "files")
-        for imf in files[k][0]['manifest']:
-            ff = etree.SubElement(imgf, "file")
-            ff.set("md5sum", imf[0])
-            ff.set("name", imf[1].lstrip('*'))
-
-        for d in files[k]:
-            diff = etree.SubElement(image, "diff")
-            for key in d.keys():
-                if key != 'description' and key != 'manifest':
-                    diff.set(key, d[key])
-
-    reposel = etree.SubElement(xmlroot, "repos")
-    for r in repos:
-        repo = etree.SubElement(reposel, "repo")
-        for key in r.keys():
-            repo.set(key, r[key])
-
-    tree = etree.ElementTree(xmlroot)
-    #tree.write('%s/%s/builddata/reports/index.xml' %(parent, id))
-
-    # transform
-    xslt_root = etree.parse('%s/index.xslt' %styledir)
-    transform = etree.XSLT(xslt_root)
-    html = transform(tree)
-    hfp = open("%s/index.html" %(output), 'w')
-    hfp.write(str(html))
-    hfp.close()
-
-def main(project_set):
-
-    compare(release_build_id, RELATIVE_URI, project_set)
-
-if __name__ == "__main__":
-    parser = optparse.OptionParser()
-    parser.add_option("-c", "--config", dest="config", 
-                      help="specify configuration file")
-    parser.add_option("", "--get-defconf", dest="get_defconf", action="store_true",
-                      help="Print out the default  configuration file")
-
-    parser.add_option("", "--build-id", dest="buildid", 
-                      help="Create report for build id")
-    parser.add_option("", "--compare-with", dest="comparewith", 
-                      help="Compare with this id")
-    parser.add_option("", "--output-dir", dest="output_dir", 
-                      help="Output directory")
-    (opts, args) = parser.parse_args()
-
-    if opts.buildid:
-        print 'will support command line later'
-        """
-        if opts.output_dir:
-            compare(opts.buildid, opts.comparewith,  opts.output_dir)
-        else:
-            compare(opts.buildid)
-        """
-    else:
-        temp = Template(DEFAULTCONF)
-        str_conf = temp.substitute(pname=P_NAME)
-
-        if opts.get_defconf:
-            print str_conf
-            sys.exit(0)
-
-        if opts.config:
-            with open(opts.config) as f:
-                str_conf = f.read()
-
-        config = ConfigParser.ConfigParser()
-        config.readfp(io.BytesIO(str_conf))
-
-        project_set = {}
-        try:
-            # reports participant specific conf
-            if config.has_option(P_NAME, 'project_name'):
-                project_set['project_name'] = config.get(P_NAME, 'project_name')
-            else:
-                project_set['project_name'] = None
-
-            project_set['release_dir'] = config.get(P_NAME, 'release_dir')
-            project_set['snapshots_dir'] = config.get(P_NAME, 'snapshots_dir')
-
-        except ConfigParser.NoOptionError, e:
-            print 'In config, %s' % str(e)
-            sys.exit(1)
-
-        main(project_set)
diff --git a/common/envparas.py b/common/envparas.py
deleted file mode 100644 (file)
index 6d2bc79..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/python -tt
-# vim: ai ts=4 sts=4 et sw=4
-
-"""This file will use some environment variables to initialise global variables.
-"""
-
-import os
-
-def export(envargs, local_env):
-    """ Export the environ parameters as python variable """
-    for element in envargs:
-        if element in os.environ.keys():
-            local_env[element]=os.getenv(element)
-            print "%s='%s'" %(element, local_env[element])
-        else:
-            print "WARN: %s doesn't exist" %(element)
-            local_env[element]=''
-    return local_env
diff --git a/job_aiaiaicheck.py b/job_aiaiaicheck.py
deleted file mode 100755 (executable)
index 900972f..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/env python
-# vim: ai ts=4 sts=4 et sw=4
-
-"""This script will use aiaiai to check kernel patch.
-"""
-
-import os
-import tempfile
-import shutil
-
-# internal module
-from common import runner
-from common import utils
-from common import git
-from common.envparas import * 
-
-envparas = ['GERRIT_SSHPORT',
-            'GERRIT_USERNAME',
-            'GERRIT_HOSTNAME',
-            'GIT_CACHE_DIR']
-export(envparas, locals())
-GERRIT_CMD = 'ssh -p %s %s@%s gerrit' % (GERRIT_SSHPORT, GERRIT_USERNAME, GERRIT_HOSTNAME)
-GIT_URL = 'ssh://%s@%s:%s' % (GERRIT_USERNAME, GERRIT_HOSTNAME, GERRIT_SSHPORT)
-
-def end(rc = 0):
-    shutil.rmtree(tmpdir)
-    exit(rc)
-
-if __name__ == '__main__':
-
-    print '---[JOB STARTED]----------------------------------------'
-    tmpdir = tempfile.mkdtemp(prefix=WORKSPACE+'/')
-    prjdir = os.path.join(tmpdir, GERRIT_PROJECT)
-    prjpath, prj = os.path.split(GERRIT_PROJECT)
-
-    aiaiaicmd = '%s/aiaiai/aiaiai-test-patchset' % JENKINS_HOME
-
-    # update local git tree from remote
-    try:
-        if os.path.exists(os.path.join(GIT_CACHE_DIR, GERRIT_PROJECT)):
-            print '\nuse local repo as reference to clone'
-            if runner.show('git clone %s/%s --reference %s %s' % (GIT_URL, GERRIT_PROJECT, os.path.join(GIT_CACHE_DIR, GERRIT_PROJECT), '%s/%s' % (tmpdir,GERRIT_PROJECT)))[0]:
-                print 'use local repo as reference to clone: Failed.'
-                shutil.rmtree(os.path.join(GIT_CACHE_DIR, GERRIT_PROJECT))
-    except Exception, ex:
-        print '\nExcept occur when use reference repo to clone code'
-        print ex
-    if not utils.retry(git.update_git_project, (tmpdir, GERRIT_PROJECT, GIT_URL)):
-        end(1)
-
-    mygit = git.Git(prjdir)
-    mygit.fetch('%s/%s' % (GIT_URL, GERRIT_PROJECT), GERRIT_REFSPEC, '-t')
-    mygit.checkout('FETCH_HEAD')
-    patch = mygit.format_patch('-n1 -o %s' % tmpdir)[0]
-    basecommit = mygit.get_base_commit(GERRIT_PATCHSET_REVISION)
-    mygit.checkout(basecommit)
-    print '%s -v -j18 --bisectability --sparse --smatch --coccinelle --cppcheck -i %s . ivi_gen_defconfig,i386' % (aiaiaicmd, patch)
-
-    with utils.Workdir(prjdir):
-        outs = runner.outs('%s -v -j18 --bisectability --sparse --smatch --coccinelle --cppcheck -i %s . ivi_gen_defconfig,i386' % (aiaiaicmd, patch))
-
-    print outs
-    msg = []
-    for line in outs.splitlines():
-        if line:
-            msg.append(line)
-    if msg:
-        runner.show('%s %s %s,%s --message \'"%s"\'' % (GERRIT_CMD, 'review', GERRIT_CHANGE_NUMBER, GERRIT_PATCHSET_NUMBER, 'aiaiai check result:\n- '+'\n'.join(msg)))
-    end()
index 1be95b8..07fcd83 100755 (executable)
@@ -8,21 +8,11 @@ try:
 except ImportError:
     import simplejson as json
 
-from common.envparas import export
 from common.buildtrigger import trigger_info
 
-PARAM_LIST = {
-        'TRIGGER_INFO',
-        'WORKSPACE',
-        'IMG_PUB_PATH_BASE',
-        'IMG_DEST_PATH_BASE'
-    }
-
-export(PARAM_LIST, locals())
-
 def main():
 
-    fields = trigger_info(TRIGGER_INFO)
+    fields = trigger_info(os.getenv('TRIGGER_INFO'))
 
     try:
         kickstart = fields["kickstart"]
@@ -31,14 +21,15 @@ def main():
         timeout = '90m'
         starttime = fields.get("starttime") or datetime.now()
         image_pub_path = fields.get("images_path")
-        image_dest_path = image_pub_path.replace(IMG_PUB_PATH_BASE, IMG_DEST_PATH_BASE)
+        image_dest_path = image_pub_path.replace(\
+                os.getenv('IMG_PUB_PATH_BASE'), os.getenv('IMG_DEST_PATH_BASE'))
 
     except KeyError, e:
         print 'Lost field: %s' % str(e)
         sys.exit(-1)
 
     # Work directory
-    output_path = os.path.join(WORKSPACE)
+    output_path = os.path.join(os.getenv('WORKSPACE'))
     ks_path = os.path.join(output_path, '%s.ks' %name)
 
     if not os.path.isdir(output_path):
index 98444dd..27c09ad 100755 (executable)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 
+import os
+
 # set default char-set endcoding to utf-8
 import sys
 reload(sys)
@@ -11,25 +13,12 @@ except ImportError:
     import simplejson as json
 
 from common.buildtrigger import trigger_next
-from common.envparas import export
-
-PARAM_LIST = ['AMQP_HOST',
-              'AMQP_VHOST',
-              'AMQP_USER',
-              'AMQP_PASSWD',
-              'AMQP_QUEUE',
-              'OBS_EVENT_STRING',
-              'BUILDCHECK_JOB_NAME',
-              'REQUESTS_JOB_NAME',
-              'REPOMAKER_JOB_NAME']
-
-export(PARAM_LIST, locals())
 
 def main():
-    event_dict = json.loads(OBS_EVENT_STRING)
-    buildcheck_job = BUILDCHECK_JOB_NAME or 'buildcheck-post'
-    requests_job = REQUESTS_JOB_NAME or 'requests'
-    repomaker_job = REPOMAKER_JOB_NAME or 'repomaker'
+    event_dict = json.loads(os.getenv('OBS_EVENT_STRING'))
+    buildcheck_job = os.getenv('BUILDCHECK_JOB_NAME') or 'buildcheck-post'
+    requests_job = os.getenv('REQUESTS_JOB_NAME') or 'requests'
+    repomaker_job = os.getenv('REPOMAKER_JOB_NAME') or 'repomaker'
 
     if event_dict and event_dict.has_key('fields'):
         if event_dict['fields'].has_key('obsEvent'):
index 8dbb812..e74955b 100755 (executable)
@@ -13,7 +13,6 @@ try:
 except ImportError:
     import simplejson as json
 
-from common.envparas import export
 from common.tempbuildpkg import BuildService2
 from common.buildtrigger import trigger_info, trigger_next
 import repomaker
@@ -31,36 +30,8 @@ class ServerConf:
     def __getitem__(self, key):
         return getattr(self, key)
 
-CONFS = {}
-
-PARAM_LIST = ['PATH_BASEDIR',
-              'PATH_TOP_TMPDIR',
-              'PATH_REPO_CONF',
-              'PATH_OSCRC',
-              'OBS_API_URL',
-              'OBS_API_USERNAME',
-              'OBS_API_PASSWD',
-              'WORKSPACE',
-              'PATH_RAW_REPOS',
-              'OBS_TRIGGERS_PATH',
-              'OBS_BUILDING_PATH',
-              'REPOMAKER_PROJECTS',
-              'NO_ARMV8',
-              'MAILTO',
-              'SANDBOX_REPO_BASEURL',
-              'EMAIL_TEMPLATES_DIR',
-              'TRIGGER_INFO',
-              'BUILD_TAG',
-              'RSYNC_SERVER',
-              'IMAGE_INFO',
-              'CONF_BASEURL',
-              'TEMP_REPO',
-              'TEMP_REPO_CONF_STRING']
-
-export(PARAM_LIST, locals())
-
 def is_intrested_project(project):
-    for keyword in REPOMAKER_PROJECTS.split(' '):
+    for keyword in os.getenv('REPOMAKER_PROJECTS', '').split(' '):
         if keyword.endswith('*'):
             if project.startswith(keyword[:-1]):
                 return True
@@ -83,14 +54,14 @@ def image_dispatch(repoinfo):
             set_relative_uri(repoinfo['RELATIVE_URI'])
             images_path = repoinfo['DEST_DIR']
 
-        ks_list = get_ks_list(CONF_BASEURL, release_build_id)
+        ks_list = get_ks_list(os.getenv('CONF_BASEURL', ''), release_build_id)
         if ks_list:
             images_info = generate_images_info ([(ksn, None) for ksn in ks_list],
-                            CONF_BASEURL,
+                            os.getenv('CONF_BASEURL', ''),
                             release_build_id,
-                            MAILTO,
+                            os.getenv('MAILTO', ''),
                             images_path,
-                            RSYNC_SERVER)
+                            os.getenv('RSYNC_SERVER', ''))
             print 'launched for:'
             print '\n'.join(ks_list)
             return images_info
@@ -120,24 +91,25 @@ if __name__ == "__main__":
     sys.stdout.flush()
 
     server_conf = ServerConf()
-    server_conf.raw_repos = PATH_RAW_REPOS
-    server_conf.repos_conf = PATH_REPO_CONF
-    server_conf.oscrc = PATH_OSCRC
-    server_conf.apiurl = OBS_API_URL
-    server_conf.apiuser = OBS_API_USERNAME
-    server_conf.apipasswd = OBS_API_PASSWD
-    server_conf.basedir = PATH_BASEDIR
-    server_conf.top_tmpdir = PATH_TOP_TMPDIR
-    server_conf.obs_triggers_path = OBS_TRIGGERS_PATH or '/srv/obs/repos_sync'
-    server_conf.obs_building_path = OBS_BUILDING_PATH or '/srv/obs/build'
-    server_conf.mailto = filter(None, [s.strip() for s in MAILTO.split(',')]) or []
-    server_conf.no_armv8 = (NO_ARMV8.lower()) == 'yes' or False
-    server_conf.sandbox_repo_baseurl = SANDBOX_REPO_BASEURL or None
-    server_conf.email_templates_dir = EMAIL_TEMPLATES_DIR
-    server_conf.workdir = WORKSPACE
+    server_conf.raw_repos = os.getenv('PATH_RAW_REPOS', '')
+    server_conf.repos_conf = os.getenv('PATH_REPO_CONF', '')
+    server_conf.oscrc = os.getenv('PATH_OSCRC', '')
+    server_conf.apiurl = os.getenv('OBS_API_URL', '')
+    server_conf.apiuser = os.getenv('OBS_API_USERNAME', '')
+    server_conf.apipasswd = os.getenv('OBS_API_PASSWD', '')
+    server_conf.basedir = os.getenv('PATH_BASEDIR', '')
+    server_conf.top_tmpdir = os.getenv('PATH_TOP_TMPDIR', '')
+    server_conf.obs_triggers_path = os.getenv('OBS_TRIGGERS_PATH') or '/srv/obs/repos_sync'
+    server_conf.obs_building_path = os.getenv('OBS_BUILDING_PATH') or '/srv/obs/build'
+    server_conf.mailto = filter(None, [s.strip() for s in \
+            os.getenv('MAILTO','').split(',')]) or []
+    server_conf.no_armv8 = (os.getenv('NO_ARMV8', '').lower()) == 'yes' or False
+    server_conf.sandbox_repo_baseurl = os.getenv('SANDBOX_REPO_BASEURL') or None
+    server_conf.email_templates_dir = os.getenv('EMAIL_TEMPLATES_DIR', '')
+    server_conf.workdir = os.getenv('WORKSPACE', '')
     repo_conf_fn = None
 
-    event_fields = trigger_info(TRIGGER_INFO)
+    event_fields = trigger_info(os.getenv('TRIGGER_INFO', ''))
 
     if not event_fields:
         print "Invalid OBS event: %s" %(OBS_EVENT_STRING)