homebysix / recipe-robot

A kick ass tool for creating AutoPkg recipes.
Apache License 2.0
299 stars 28 forks source link

Add support for new SourceForgeBestReleaseURLProvider processor #114

Open n8felton opened 7 years ago

n8felton commented 7 years ago

I've created a new SourceForgeBestReleaseURLProvider shared processor at https://github.com/autopkg/n8felton-recipes/blob/master/SharedProcessors/SourceForgeBestReleaseURLProvider.py that gives us another option for downloading files from SourceForge. This SourceForgeBestReleaseURLProvider shared processor could be used as either the primary processor or as a fallback processor for SourceForge projects.

As an example:

$ ./recipe-robot -v --app-mode https://sourceforge.net/projects/weka/

                      -----------------------------------
                     |  Welcome to Recipe Robot v1.0.4.  |
                      -----------------------------------
                                \   _[]_
                                 \  [oo]
                                   d-||-b
                                     ||
                                   _/  \_

Processing https://sourceforge.net/projects/weka/ ...
Input path looks like a SourceForge URL.
    App name is: Weka
Getting SourceForge project ID...
    SourceForge project ID is: 5091
Getting SourceForge description...
    SourceForge description is: Machine learning software to solve data mining problems
Determining download URL from SourceForge RSS feed...
[WARNING] Could not detect SourceForge latest release download_url.
Searching for existing AutoPkg recipes for Weka...
    No results
[ERROR] Recipe Robot exploded with unexpected error: is_from_app_store
Traceback (most recent call last):
  File "./recipe-robot", line 98, in main
    time, _ = recipe_robot_lib.generate_recipes(facts, prefs)  # pylint: disable=assignment-from-no-return
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/tools.py", line 117, in run_func
    result = func(*args, **kwargs)
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/recipe_generator.py", line 65, in generate_recipes
    raise_if_recipes_cannot_be_generated(facts, preferred)
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/recipe_generator.py", line 117, in raise_if_recipes_cannot_be_generated
    if (not facts.is_from_app_store() and
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/facts.py", line 90, in is_from_app_store
    return self["is_from_app_store"]
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/roboabc.py", line 45, in __getitem__
    return self._dict[key]
KeyError: 'is_from_app_store'

[ERROR]
                                    _[]_
                                    [xx]
                                   q-||-p
                                     ||
                                   _/  \_

This currently fails, but could instead use my shared processor (or the code from my shared processor) as a fallback (or primary, and use the current processor as the fallback) to locate the download instead.

Optionally, I have also created a new MD5Checksum shared processor that complements the SourceForgeBestReleaseURLProvider shared processor as the SourceForge Release API provides the MD5 checksum of the available project downloads. https://github.com/autopkg/n8felton-recipes/blob/master/SharedProcessors/MD5Checksum.py

An example of these processors in action can been seen at https://github.com/autopkg/n8felton-recipes/blob/master/Weka/Weka.download.recipe

homebysix commented 7 years ago

That's great, @n8felton!

Are there still any situations in which @jessepeterson's SourceForgeURLProvider would still be better and/or the preferred processor? Does this new processor cover all the existing use cases of SourceForgeURLProvider, and then some?

n8felton commented 7 years ago

There is one pitfall to this processor; reliance on the SourceForge project team to update their "best release."

A good example of this is https://sourceforge.net/projects/filezilla/. https://sourceforge.net/projects/filezilla/best_release.json has 3.17.0.1 listed as their "best release" even though 3.22.1 appears to be the latest release.