Skip to content

Commit

Permalink
[Price Feed] Parse full path of configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Dec 3, 2015
1 parent bee3064 commit 36e83ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion scripts/pricefeeds/config-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import feedsources
import subprocess
import os
configPath = os.path.dirname(__file__)

################################################################################
## RPC-client connection information (required)
Expand Down Expand Up @@ -143,6 +145,9 @@
## Git revision for storage in blame files
## (do not touch this line)
################################################################################
gittag = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii").strip("\n")
try :
gittag = subprocess.check_output(["git","-C", configPath, "rev-parse", "HEAD"]).decode("ascii").strip("\n")
except :
pass

# coding=utf8 sw=4 expandtab ft=python
8 changes: 5 additions & 3 deletions scripts/pricefeeds/pricefeeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,10 @@ def update_price_feed() :

## Load Feedsource data #####################################################
if configFile.blame != "latest" :
if os.path.isfile("blame/"+configFile.blame+'.json') :
blameFile = config.configPath + "/blame/" + configFile.blame + ".json"
if os.path.isfile() :
## Load data from disk for (faster) debugging and verification
with open("blame/"+configFile.blame+'.json', 'r') as fp:
with open(blameFile, 'r') as fp:
state = json.load(fp)
## Load feed sources
feed = state["feed"]
Expand Down Expand Up @@ -443,14 +444,15 @@ def update_price_feed() :
if key == "feedSources" : continue ## can't storage objects / TODO: pickle
if key == "feedsources" : continue
if key == "subprocess" : continue
if key == "os" : continue
configStruct[key] = config.__dict__[key]
# Store State
state["feed"] = feed
state["derived_prices"] = derived_prices
state["price_feeds"] = price_feeds
state["lastblock"] = get_last_block(rpc)
state["config"] = configStruct
blameFile = "blame/"+str(state["lastblock"])+'.json'
blameFile = config.configPath + "/blame/"+str(state["lastblock"]) + ".json"
with open(blameFile, 'w') as fp:
json.dump(state, fp)
print("Blamefile: "+blameFile)
Expand Down

0 comments on commit 36e83ab

Please sign in to comment.