homebysix / recipe-robot

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

KeyError: 'RecipeCreateLocation' Python error #80

Closed flammable closed 8 years ago

flammable commented 8 years ago

Hey Elliot! Thanks for this - I'm really excited to use it!

I just tried my first app, though, and I'm getting this Python error in the output:


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

Processing /Volumes/CocoaPacketAnalyzer/CocoaPacketAnalyzer.app ...
Input path looks like an app.
Validating app...
    App seems valid
Getting app name...
    App name is: CocoaPacketAnalyzer
Getting bundle identifier...
    Bundle identifier is: com.tastycocoabytes.CocoaPacketAnalyzer
Checking for a Sparkle feed...
    Sparkle feed is: http://www.tastycocoabytes.com/cpa/updates/appcasting.php
Getting information from Sparkle feed...
    The Sparkle feed provides a version number
    The latest version is 1.31
    Download URL is: http://www.tastycocoabytes.com/_downloads/CPA_131.dmg
Downloading file for further inspection...
    Downloaded to /Users/mike/Library/Caches/Recipe Robot/2015-11-20_15-01-21_218152/CPA_131.dmg
Determining download format...
    File extension is dmg
Looking for version key...
    Version key is: CFBundleShortVersionString (1.31)
Looking for app icon...
    App icon is: /Volumes/CocoaPacketAnalyzer/CocoaPacketAnalyzer.app/Contents/Resources/CPAIconNR
Getting app description from MacUpdate...
    Description: Network packet protocol analyzer.
Gathering code signature information...
    Code signature verification requirements recorded
    3 authority names recorded
    Developer: BitControl Networks GmbH
Searching for existing AutoPkg recipes for "CocoaPacketAnalyzer"...
    No results
[ERROR] Recipe Robot exploded with unexpected error: RecipeCreateLocation
Traceback (most recent call last):
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe-robot", line 104, 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 111, in run_func
    result = func(*args, **kwargs)
  File "/Applications/Recipe Robot.app/Contents/Resources/scripts/recipe_robot_lib/recipe_generator.py", line 99, in generate_recipes
    recipe_dest_dir = robo_join(prefs["RecipeCreateLocation"],
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_convenience.py", line 162, in __getitem__objectForKey_
    return container_unwrap(res, KeyError, key)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_convenience.py", line 659, in container_unwrap
    raise exc_type(*exc_args)
KeyError: 'RecipeCreateLocation'

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



I tried manually creating the folder ~/Library/AutoPkg/Recipe Robot Output/, but no luck. What am I doing wrong?

I'm running OS X 10.11.1 - let me know if you need any more details. Thanks!

Mike

homebysix commented 8 years ago

Hi @flammable! Did you run recipe-robot --config yet? If not, do that in order to set your preferences, then run the app through again. If all else fails, do defaults write com.elliotjordan.recipe-robot RecipeCreateLocation "/Users/$USER/Library/AutoPkg/Recipe Robot Output" and try again.

@sheagcraig, I wonder what would cause the RecipeCreateLocation key to be missing from prefs. Looking through get_recipe_creation_location() now to see if anything obvious emerges.

flammable commented 8 years ago

Ooh, I should have specified - I'm using the GUI version. Many thanks for the AutoPkg recipe! :)

Although I set those preferences at first launch, I guess they didn't fully save. Here's what my preferences file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Initialized</key>
    <true/>
    <key>LastRecipeRobotVersion</key>
    <string>1.0</string>
    <key>RecipeCreateCount</key>
    <integer>0</integer>
    <key>RecipeIdentifierPrefix</key>
    <string>com.github.flammable</string>
    <key>RecipeTypes</key>
    <array>
        <string>download</string>
        <string>munki</string>
    </array>
</dict>
</plist>

I used the defaults command to set RecipeCreateLocation, and now I'm successfully creating recipes! This is awesome!

homebysix commented 8 years ago

@eahrold, could there be an issue initializing RecipeCreateLocation because of the question mark in this line? https://github.com/homebysix/recipe-robot/blob/master/app/Recipe%20Robot/Defaults.swift#L56

flammable commented 8 years ago

I don't know if it makes a difference, but I didn't click the "Choose..." button to select a folder - I was happy with using the default. I initially thought it was an issue because the folder doesn't exist prior to running the app, so I made it myself - but it still produced the same error because it wasn't set in the preferences file.

eahrold commented 8 years ago

I thought this may happen. In the App we're simply doing an NSUserDefaults registerDefaults which doesn't write to the preference file. This is yet another thing that should resolve itself if we move the script to querying to the defaults system. But I'll put up a temp fix.

homebysix commented 8 years ago

@eahrold Is this as simple as subprocessing to defaults write instead of writing the plist to a file? I can probably handle that.

eahrold commented 8 years ago

Let me take a stab at this with pyobjc NSUserDefaults.

On Nov 25, 2015, at 12:21 PM, Elliot Jordan notifications@github.com wrote:

@eahrold Is this as simple as subprocessing to defaults write instead of writing the plist to a file? I can probably handle that.

— Reply to this email directly or view it on GitHub.

smashism commented 8 years ago

I'm having this error as well… was there an established fix for this elsewhere?

ETA: saw the defaults write above and tried it, we'll see how it goes…

homebysix commented 8 years ago

@smashism Looks like Eldon made some updates in this branch. I'll review and merge them when I get some time.

homebysix commented 8 years ago

@smashism and @flammable, give v1.0.1 a try: https://github.com/homebysix/recipe-robot/releases/latest

flammable commented 8 years ago

Thanks, @homebysix! I'll give it a try on a fresh computer once the holidays are over (probably early next week).

flammable commented 8 years ago

Also, thanks to @eahrold, too. :smile:

flammable commented 8 years ago

I'm super late on this, but just checked - 1.0.1 seems to fix the problem. Thanks!