Project

General

Profile

Bug #2270

REST handlers fail when used with apps that copied old Lookup Editor code

Added by Luke Murphey almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
06/15/2018
Due date:
% Done:

100%

Associated revisions

Revision 541 (diff)
Added by lukemurphey almost 6 years ago

Fixing issue where REST handlers wouldn't work with apps that had copied code

Reference #2270

History

#1 Updated by Luke Murphey almost 6 years ago

The error is;

ImportError: cannot import name LookupEditor

from /home/SW/splunk/etc/apps/lookup_editor/bin/lookup_backups_rest_handler.py

#2 Updated by Luke Murphey almost 6 years ago

Questions:
  • What is the path that is used for resolving libraries?
    • See note, It does include
  • Does a relative import work?
    • No, it is in the same path
  • Do the hosts have the modules available?
    • Yes
  • Does manually setting the sys.path to include the current directory work?
    • No
  • Why does it not output any logs?
    • It does
  • Could another app be including the lookup editor Python code? If so, would inserting the path first help?
Observations:
  • The RHs are not starting, indicating: cannot import name LookupEditor
  • The sys.path looks like it ought to work
References:

#3 Updated by Luke Murphey almost 6 years ago

Here is the sys.path on my mac:
  • /Users/lmurphey/Splunk/711/lib/python2.7/site-packages/splunk/appserver/mrsparkle
  • /Users/lmurphey/Splunk/711/lib/python2.7/site-packages/splunk/persistconn
  • /Users/lmurphey/Splunk/711/lib/python2.7/site-packages
  • /Users/lmurphey/stash/app-ess/test/common
  • /Users/lmurphey/stash/common/test/ui
  • /Users/lmurphey/stash/common/test
  • /Users/lmurphey/Splunk/sp/lib/python2.7/site-packages
  • /Users/lmurphey/Splunk/711/lib/python27.zip
  • /Users/lmurphey/Splunk/711/lib/python2.7
  • /Users/lmurphey/Splunk/711/lib/python2.7/plat-darwin
  • /Users/lmurphey/Splunk/711/lib/python2.7/plat-mac
  • /Users/lmurphey/Splunk/711/lib/python2.7/plat-mac/lib-scriptpackages
  • /Users/lmurphey/Splunk/711/lib/python2.7/lib-tk
  • /Users/lmurphey/Splunk/711/lib/python2.7/lib-old
  • /Users/lmurphey/Splunk/711/lib/python2.7/lib-dynload
  • /Users/lmurphey/Splunk/711/etc/apps/alert_logevent/bin
  • /Users/lmurphey/Splunk/711/etc/apps/alert_webhook/bin
  • /Users/lmurphey/Splunk/711/etc/apps/introspection_generator_addon/bin
  • /Users/lmurphey/Splunk/711/etc/apps/lookup_editor/bin
  • /Users/lmurphey/Splunk/711/etc/apps/search/bin
  • /Users/lmurphey/Splunk/711/etc/apps/splunk_archiver/bin
  • /Users/lmurphey/Splunk/711/etc/apps/splunk_instrumentation/bin
  • /Users/lmurphey/Splunk/711/etc/apps/splunk_monitoring_console/bin
  • /Users/lmurphey/Splunk/711/etc/system/bin

#4 Updated by Luke Murphey almost 6 years ago

Can set the import path to the script directory via:

import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

#5 Updated by Luke Murphey almost 6 years ago

I tried uploading a version of the app that does two things:

  1. Try using the path set from the script directory
  2. Outputs sys.path before starting

The app still doesn't work.

#7 Updated by Luke Murphey almost 6 years ago

Can dump apps with:

| rest /services/apps/local | table title label description

#8 Updated by Luke Murphey almost 6 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

#9 Updated by Luke Murphey almost 6 years ago

  • Subject changed from Lookups cannot be loaded to REST handlers fail when used with apps that copied old Lookup Editor code

Also available in: Atom PDF