Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
Allow execution from any filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
Empty2k12 committed Nov 26, 2016
1 parent 72537e2 commit bdf7f67
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion joinmarket/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def __setattr__(self, name, value):
logFormatter = logging.Formatter(
('%(asctime)s [%(threadName)-12.12s] '
'[%(levelname)-5.5s] %(message)s'))
fileHandler = logging.FileHandler('logs/{}.log'.format(value))
dirname = os.path.split(os.path.abspath(__file__))
fileHandler = logging.FileHandler(os.path.join(dirname[0][:-11], 'logs/{}.log'.format(value)))
fileHandler.setFormatter(logFormatter)
log.addHandler(fileHandler)

Expand Down
3 changes: 2 additions & 1 deletion joinmarket/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ def __init__(self,
self.index.append([0, 0])

def read_wallet_file_data(self, filename, pwd=None):
dirname = os.path.split(os.path.abspath(__file__))
self.path = None
self.index_cache = [[0, 0]] * self.max_mix_depth
path = os.path.join('wallets', filename)
path = os.path.join(dirname[0][:-11], 'wallets', filename)
if not os.path.isfile(path):
if get_network() == 'testnet':
log.debug('filename interpreted as seed, only available in '
Expand Down
6 changes: 4 additions & 2 deletions wallet-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,16 @@ def cus_print(s):
elif method == 'listwallets':
# Fetch list of wallets
possible_wallets = []
for (dirpath, dirnames, filenames) in os.walk('wallets'):
dirname = os.path.split(os.path.abspath(__file__))
for (dirpath, dirnames, filenames) in os.walk(os.path.join(dirname[0], 'wallets')):
possible_wallets.extend(filenames)
# Breaking as we only want the top dir, not subdirs
break
# For each possible wallet file, read json to list
walletjsons = []
for possible_wallet in possible_wallets:
fd = open(os.path.join('wallets', possible_wallet), 'r')
dirname = os.path.split(os.path.abspath(__file__))
fd = open(os.path.join(dirname[0], 'wallets', possible_wallet), 'r')
try:
walletfile = fd.read()
walletjson = json.loads(walletfile)
Expand Down

0 comments on commit bdf7f67

Please sign in to comment.