All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: "Aníbal Limón" <anibal.limon@linux.intel.com>
Cc: yocto@yoctoproject.org
Subject: Re: [PATCH 03/10][AUH] recipe.py: Improvements and refactor of fetch method.
Date: Tue, 10 Nov 2015 08:46:56 +0000	[thread overview]
Message-ID: <1520936.0Hx4VQ3Cib@peggleto-mobl.ger.corp.intel.com> (raw)
In-Reply-To: <1447106501-470-4-git-send-email-anibal.limon@linux.intel.com>

Hi Aníbal,

On Monday 09 November 2015 16:01:34 Aníbal Limón wrote:
> Make more clear fetch method changing recursive manner to
> loop and split logic into try fetch and suffix change.
> 
> Now when fails only retry changing recipe suffix when recipe
> isn't git based because does not make sense suffixes in SCM's.
> 
> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
> ---
>  recipe.py | 58 +++++++++++++++++++++++++++++++++-------------------------
>  1 file changed, 33 insertions(+), 25 deletions(-)
> 
> diff --git a/recipe.py b/recipe.py
> index 6fd8f24..0e8799f 100644
> --- a/recipe.py
> +++ b/recipe.py
> @@ -55,7 +55,6 @@ class Recipe(object):
>              "tar.gz", "tgz", "zip", "tar.bz2", "tar.xz", "tar.lz4", "bz2",
>              "lz4", "orig.tar.gz", "src.tar.gz", "src.rpm", "src.tgz",
>              "svnr\d+.tar.bz2", "stable.tar.gz", "src.rpm"]
> -        self.suffix_index = 0
>          self.old_env = None
> 
>          self.commit_msg = self.env['PN'] + ": upgrade to " + self.new_ver +
> "\n\n" @@ -540,33 +539,42 @@ class Recipe(object):
>          self.bb.unpack(self.env['PN'])
> 
>      def fetch(self):
> -        try:
> -            self.bb.fetch(self.env['PN'])
> -        except Error as e:
> -            machine, failed_recipes = self._get_failed_recipes(e.stdout)
> -            if not self.env['PN'] in failed_recipes:
> -                raise Error("unknown error occured during fetch")
> -
> -            fetch_log = failed_recipes[self.env['PN']][1]
> -            if self.suffix_index < len(self.suffixes) and
> self._is_uri_failure(fetch_log): -                I(" Trying new SRC_URI
> suffix: %s ..." % self.suffixes[self.suffix_index]) -               
> self._change_source_suffix(self.suffixes[self.suffix_index]) -             
>   self.suffix_index += 1
> -                self.fetch()
> -
> -            if not self._is_uri_failure(fetch_log):
> -                if not self.checksums_changed:
> +        from gitrecipe import GitRecipe
> +
> +        def _try_fetch():
> +            try:
> +                self.bb.fetch(self.env['PN'])
> +                return
> +            except Error as e:
> +                machine, failed_recipes =
> self._get_failed_recipes(e.stdout) +                if not self.env['PN']
> in failed_recipes:
> +                    raise Error("Unknown error occured during fetch",
> +                            stdout = e.stdout, stderr = e.stderr)
> +
> +                fetch_log = failed_recipes[self.env['PN']][1]
> +
> +                if not self._is_uri_failure(fetch_log) and not \
> +                        self.checksums_changed:
>                      self._change_recipe_checksums(fetch_log)
> -                    return
> -                else:
> -                    raise FetchError()
> +                    self.checksums_changed = True
> +                    return True
> 
> -                if self.recipes_renamed and not self.checksums_changed:
> -                    raise Error("fetch succeeded without changing
> checksums") +                return False
> +
> +        succeed = _try_fetch()
> +        if succeed is False and not isinstance(self, GitRecipe):
> +            for sfx in self.suffixes:
> +                I(" Trying new SRC_URI suffix: %s ..." % sfx)
> +                self._change_source_suffix(sfx)
> +
> +                succeed = _try_fetch()
> +                if succeed is True:
> +                    break
> 
> -            elif self.suffix_index == len(self.suffixes):
> -                # Every suffix tried without success
> -                raise FetchError()
> +        if succeed is False:

"x is True" or "x is False" is very odd syntax - the "is" operator is for when 
you want to compare the instance of two things, and whilst that may work that 
isn't what you want here. Simply "x" or "not x" would be the more standard way 
to do this.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre


  reply	other threads:[~2015-11-10  8:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09 22:01 [PATCH 00/10][AUH] Improvements and small fixes Aníbal Limón
2015-11-09 22:01 ` [PATCH 01/10][AUH] upgradehelper.py: Add step for build gcc-runtime at init Aníbal Limón
2015-11-09 22:01 ` [PATCH 02/10][AUH] upgradehelper.py: Fix bug when buildhistory isn't enabled Aníbal Limón
2015-11-09 22:01 ` [PATCH 03/10][AUH] recipe.py: Improvements and refactor of fetch method Aníbal Limón
2015-11-10  8:46   ` Paul Eggleton [this message]
2015-11-11 20:08     ` Aníbal Limón
2015-11-09 22:01 ` [PATCH 04/10][AUH] buildhistory.py: Don't modify BB_ENV_EXTRAWHITE before init Aníbal Limón
2015-11-10  8:54   ` Paul Eggleton
2015-11-11 20:14     ` Aníbal Limón
2015-11-09 22:01 ` [PATCH 05/10][AUH] upgradehelper.py: Add sanity test for ensure that git is configured Aníbal Limón
2015-11-10  8:59   ` Paul Eggleton
2015-11-11 20:15     ` Aníbal Limón
2015-11-09 22:01 ` [PATCH 06/10][AUH] buildhistory.py: Add missing warning import. git.py: Fix last_commit method Aníbal Limón
2015-11-09 22:01 ` [PATCH 07/10][AUH] upgradehelper.py: Improve work directory structure Aníbal Limón
2015-11-09 22:01 ` [PATCH 08/10][AUH] upgradehelper.py: Add support for do recipe upgrades based on builddep Aníbal Limón
2015-11-10  9:09   ` Paul Eggleton
2015-11-11 20:15     ` Aníbal Limón
2015-11-09 22:01 ` [PATCH 09/10][AUH] upgradehelper.py: Add support for preserve statistics into work directory Aníbal Limón
2015-11-09 22:01 ` [PATCH 10/10][AUH] requirements.txt: Add file for now only with GitPython 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=1520936.0Hx4VQ3Cib@peggleto-mobl.ger.corp.intel.com \
    --to=paul.eggleton@linux.intel.com \
    --cc=anibal.limon@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.