Skip to content

Commit

Permalink
[decode-syseeprom]: Fix caching (sonic-net#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
jleveque authored and Shuotian Cheng committed Oct 28, 2017
1 parent 67f8806 commit 875c1a1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/decode-syseeprom
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ PLATFORM_KEY = 'platform'

PLATFORM_ROOT = '/usr/share/sonic/device'

cache_root = '/var/cache/ssw/decode-syseeprom'
CACHE_ROOT = '/var/cache/sonic/decode-syseeprom'
CACHE_FILE = 'syseeprom_cache'

# Returns platform and HW SKU
def get_platform():
Expand Down Expand Up @@ -98,21 +99,21 @@ def run(target, opts, args):
sys.stderr.write("Device is not ready: " + status + "\n")
exit(0)

if not os.path.exists(cache_root):
if not os.path.exists(CACHE_ROOT):
try:
os.makedirs(cache_root)
os.makedirs(CACHE_ROOT)
except:
pass
if opts.init:
for file in glob.glob(os.path.join(cache_root, '*')):
for file in glob.glob(os.path.join(CACHE_ROOT, '*')):
os.remove(file)

#
# only the eeprom classes that inherit from eeprom_base
# support caching. Others will work normally
#
try:
target.set_cache_name(os.path.join(cache_root, opts.target))
target.set_cache_name(os.path.join(CACHE_ROOT, CACHE_FILE))
except:
pass

Expand Down

0 comments on commit 875c1a1

Please sign in to comment.