This repository has been archived by the owner on May 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 119
Allow execution from any filepath #670
Open
Empty2k12
wants to merge
1
commit into
JoinMarket-Org:develop
Choose a base branch
from
Empty2k12:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BlinkyStitt
suggested changes
Mar 26, 2017
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using -11
and split here is fragile. Probably better to do something like:
dirname = os.path.dirname(os.path.abspath(__file__))
wallet_path = os.path.join(dirname, '..', 'wallets', filename)
Although I think moving wallet and log dir to configuration variables would probably be better still
@@ -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__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to above, use join
instead of split
:
dirname = os.path.dirname(os.path.abspath(__file__))
wallet_dir = os.path.join(dirname, '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__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Until now you had to go go into the folder containing wallet-tool, yg or any other of the tools to use them. This commit solves this (at least for wallet-tool, log creation and everywhere the Wallet class is used).
You can now execute joinmarket from any filepath using a command like this
python ~/Desktop/JoinmarketDev/yield-generator-basic.py wallet.json
I am not sure if I have missed any code where the folder is being assumed.
To figure you the filepath a python function has been used. For all files in the /joinmarket/ subfolder the subfolder name is being stripped using
[:-11]
. Additionally the method to get the filepath returns a tuple and the actual filepath is accessed using the index.I am not sure if this is best practice, since my knowledge in Python is still limited. Please suggest missing cases and code improvements!