From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: yocto@yoctoproject.org
Cc: paul.eggleton@linux.intel.com
Subject: [[AUH] 02/17] upgradehelper.py: Merge options into a dictionary
Date: Wed, 25 Nov 2015 18:00:31 -0600 [thread overview]
Message-ID: <1448496046-13186-3-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1448496046-13186-1-git-send-email-anibal.limon@linux.intel.com>
Use one dictionary to keep together the options this enables
possibility to define an interface for steps, see next commit.
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
upgradehelper.py | 83 ++++++++++++++++++++++++++++----------------------------
1 file changed, 42 insertions(+), 41 deletions(-)
diff --git a/upgradehelper.py b/upgradehelper.py
index 128bc07..1c3dcbc 100755
--- a/upgradehelper.py
+++ b/upgradehelper.py
@@ -126,15 +126,38 @@ def parse_config_file(config_file):
class Updater(object):
def __init__(self, auto_mode=False, send_email=False, skip_compilation=False):
+ build_dir = get_build_dir()
- self.uh_dir = os.path.join(get_build_dir(), "upgrade-helper")
+ self.bb = Bitbake(build_dir)
+
+ try:
+ self.base_env = self.bb.env()
+ except EmptyEnvError as e:
+ import traceback
+ E( " %s\n%s" % (e.message, traceback.format_exc()))
+ E( " Bitbake output:\n%s" % (e.stdout))
+ exit(1)
+
+ self.email_handler = Email(settings)
+ self.statistics = Statistics()
+ self.git = None
+
+ self.opts = {}
+ self.opts['interactive'] = not auto_mode
+ self.opts['send_email'] = send_email
+ self.opts['author'] = "Upgrade Helper <%s>" % \
+ settings.get('from', 'uh@not.set')
+ self.opts['machines'] = settings.get('machines',
+ 'qemux86 qemux86-64 qemuarm qemumips qemuppc').split()
+ self.opts['skip_compilation'] = skip_compilation
+ self.opts['buildhistory_enabled'] = self._buildhistory_is_enabled()
+
+ self.uh_dir = os.path.join(build_dir, "upgrade-helper")
if not os.path.exists(self.uh_dir):
os.mkdir(self.uh_dir)
-
self.uh_work_dir = os.path.join(self.uh_dir, "work-%s" % \
datetime.now().strftime("%Y%m%d%H%M%S"))
os.mkdir(self.uh_work_dir)
-
self.uh_recipes_all_dir = os.path.join(self.uh_work_dir, "all")
os.mkdir(self.uh_recipes_all_dir)
self.uh_recipes_succeed_dir = os.path.join(self.uh_work_dir, "succeed")
@@ -142,16 +165,6 @@ class Updater(object):
self.uh_recipes_failed_dir = os.path.join(self.uh_work_dir, "failed")
os.mkdir(self.uh_recipes_failed_dir)
- self.bb = Bitbake(get_build_dir())
- self.git = None
- self.author_email = settings.get('from', 'uh@not.set')
- self.author = "Upgrade Helper <%s>" % self.author_email
- self.skip_compilation = skip_compilation
- self.interactive = not auto_mode
- self.send_email = send_email
-
- self.machines = settings.get('machines', 'qemux86 qemux86-64 qemuarm qemumips qemuppc').split()
-
self.upgrade_steps = [
(self._load_env, "Loading environment ..."),
(self._create_workdir, None),
@@ -167,18 +180,6 @@ class Updater(object):
(self._buildhistory_diff, None)
]
- try:
- self.base_env = self.bb.env()
- except EmptyEnvError as e:
- import traceback
- E( " %s\n%s" % (e.message, traceback.format_exc()))
- E( " Bitbake output:\n%s" % (e.stdout))
- exit(1)
- self.buildhistory_enabled = self._buildhistory_is_enabled()
-
- self.email_handler = Email(settings)
- self.statistics = Statistics()
-
def _get_status_msg(self, err):
if err:
return str(err)
@@ -199,7 +200,7 @@ class Updater(object):
" BUILDHISTORY_COMMIT=1 please set.")
exit(1)
- if self.skip_compilation:
+ if self.opts['skip_compilation']:
W(" Buildhistory disabled because user" \
" skip compilation!")
else:
@@ -228,7 +229,7 @@ class Updater(object):
stdout = self.git.status()
if stdout != "":
- if self.interactive:
+ if self.opts['interactive']:
W(" %s: git repository has uncommited work which will be dropped! Proceed? (y/N)" % self.pn)
answer = sys.stdin.readline().strip().upper()
if answer == '' or answer != 'Y':
@@ -261,16 +262,16 @@ class Updater(object):
else:
raise UnsupportedProtocolError
- self.recipe = recipe(self.env, self.new_ver, self.interactive, self.workdir,
+ self.recipe = recipe(self.env, self.new_ver, self.opts['interactive'], self.workdir,
self.recipe_dir, self.bb, self.git)
def _buildhistory_init(self):
- if self.buildhistory_enabled == False:
+ if not self.opts['buildhistory_enabled']:
return
self.buildhistory = BuildHistory(self.bb, self.pn, self.workdir)
- I(" %s: Initial buildhistory for %s ..." % (self.pn, self.machines))
- self.buildhistory.init(self.machines)
+ I(" %s: Initial buildhistory for %s ..." % (self.pn, self.opts['machines']))
+ self.buildhistory.init(self.opts['machines'])
def _unpack_original(self):
self.recipe.unpack()
@@ -289,18 +290,18 @@ class Updater(object):
self.recipe.fetch()
def _compile(self):
- if self.skip_compilation:
+ if self.opts['skip_compilation']:
W(" %s: Compilation was skipped by user choice!")
return
- for machine in self.machines:
+ for machine in self.opts['machines']:
I(" %s: compiling for %s ..." % (self.pn, machine))
self.recipe.compile(machine)
- if self.buildhistory_enabled == True:
+ if self.opts['buildhistory_enabled']:
self.buildhistory.add()
def _buildhistory_diff(self):
- if self.buildhistory_enabled == False:
+ if not self.opts['buildhistory_enabled']:
return
I(" %s: Checking buildhistory ..." % self.pn)
@@ -315,7 +316,7 @@ class Updater(object):
# this function will be called at the end of each recipe upgrade
def pkg_upgrade_handler(self, err):
- if err and self.patch_file and self.interactive:
+ if err and self.patch_file and self.opts['interactive']:
answer = "N"
I(" %s: Do you want to keep the changes? (y/N)" % self.pn)
answer = sys.stdin.readline().strip().upper()
@@ -380,7 +381,7 @@ class Updater(object):
if license_diff_fn:
msg_body += license_change_info % license_diff_fn
if not err:
- msg_body += next_steps_info % (', '.join(self.machines),
+ msg_body += next_steps_info % (', '.join(self.opts['machines']),
os.path.basename(self.patch_file))
msg_body += mail_footer
@@ -393,7 +394,7 @@ class Updater(object):
attachments.append(attachment_fullpath)
# Only send email to Maintainer when recipe upgrade succeed.
- if self.send_email and not err:
+ if self.opts['send_email'] and not err:
self.email_handler.send_email(to_addr, subject, msg_body, attachments, cc_addr=cc_addr)
# Preserve email for review purposes.
@@ -415,7 +416,7 @@ class Updater(object):
self.patch_file = None
if self.recipe is not None:
I(" %s: Auto commit changes ..." % self.pn)
- self.git.commit(self.recipe.commit_msg, self.author)
+ self.git.commit(self.recipe.commit_msg, self.opts['author'])
I(" %s: Save patch in %s." % (self.pn, self.workdir))
stdout = self.git.create_patch(self.workdir)
self.patch_file = stdout.strip()
@@ -525,7 +526,7 @@ class Updater(object):
def run(self, package_list=None):
I(" Building gcc runtimes ...")
- for machine in self.machines:
+ for machine in self.opts['machines']:
I(" building gcc runtime for %s" % machine)
self.bb.complete("gcc-runtime", machine)
@@ -595,7 +596,7 @@ class Updater(object):
I("%s" % statistics_summary)
- if self.send_email:
+ if self.opts['send_email']:
self.send_status_mail()
class UniverseUpdater(Updater):
--
2.1.4
next prev parent reply other threads:[~2015-11-26 0:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 0:00 [[AUH] 00/17] AUH code refactor and support test image Aníbal Limón
2015-11-26 0:00 ` [[AUH] 01/17] {upgradehelper, bitbake}.py: Move _get_env function to bitbake Aníbal Limón
2015-11-26 0:00 ` Aníbal Limón [this message]
2015-11-26 0:00 ` [[AUH] 03/17] upgradehelper.py: Adds own module for steps Aníbal Limón
2015-11-26 0:00 ` [[AUH] 04/17] upgradehelper: Reorder files into directories Aníbal Limón
2015-11-26 0:00 ` [[AUH] 05/17] buildhistory: Add option for enable in upgrade-helper.conf Aníbal Limón
2015-11-26 0:00 ` [[AUH] 06/17] recipe/base.py: Add is_recipe_or_include_file func Aníbal Limón
2015-11-26 0:00 ` [[AUH] 07/17] recipe/base.py: Add modify_recipe_files function decorator Aníbal Limón
2015-11-26 0:00 ` [[AUH] 08/17] recipe/base.py: Add support for get recipe inherits Aníbal Limón
2015-11-26 20:25 ` Paul Eggleton
2015-11-27 16:50 ` Aníbal Limón
2015-11-26 0:00 ` [[AUH] 09/17] steps.py: Merge load_dirs step into load_env Aníbal Limón
2015-11-26 0:00 ` [[AUH] 10/17] steps.py: Move clean_repo to first step Aníbal Limón
2015-11-26 0:00 ` [[AUH] 11/17] utils/git.py: Add method for apply patches into a branch Aníbal Limón
2015-11-26 20:28 ` Paul Eggleton
2015-11-27 16:51 ` Aníbal Limón
2015-11-26 0:00 ` [[AUH] 12/17] upgradehelper.py: Add settings for enable testimage Aníbal Limón
2015-11-26 0:00 ` [[AUH] 13/17] upgradehelper: Add testimage feature Aníbal Limón
2015-11-26 20:29 ` Paul Eggleton
2015-11-27 16:51 ` Aníbal Limón
2015-11-26 0:00 ` [[AUH] 14/17] upgradehelper.py: Changed retry failure build to 30 days Aníbal Limón
2015-11-26 0:00 ` [[AUH] 15/17] upgradehelper: Add workdir setting Aníbal Limón
2015-11-26 0:00 ` [[AUH] 16/17] statistics: Improve email format and get_summary method Aníbal Limón
2015-11-26 0:00 ` [[AUH] 17/17] statistics: Add support for publish_work_url setting Aníbal Limón
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448496046-13186-3-git-send-email-anibal.limon@linux.intel.com \
--to=anibal.limon@linux.intel.com \
--cc=paul.eggleton@linux.intel.com \
--cc=yocto@yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.