This repository was archived by the owner on May 13, 2022. It is now read-only.
Allow execution from any filepath#670
Open
Empty2k12 wants to merge 1 commit intoJoinMarket-Org:developfrom
Empty2k12:develop
Open
Allow execution from any filepath#670Empty2k12 wants to merge 1 commit intoJoinMarket-Org:developfrom Empty2k12:develop
Empty2k12 wants to merge 1 commit intoJoinMarket-Org:developfrom
Empty2k12:develop
Conversation
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) |
Contributor
There was a problem hiding this comment.
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
| # Fetch list of wallets | ||
| possible_wallets = [] | ||
| for (dirpath, dirnames, filenames) in os.walk('wallets'): | ||
| dirname = os.path.split(os.path.abspath(__file__)) |
Contributor
There was a problem hiding this comment.
similar to above, use join instead of split:
dirname = os.path.dirname(os.path.abspath(__file__))
wallet_dir = os.path.join(dirname, 'wallets')
| walletjsons = [] | ||
| for possible_wallet in possible_wallets: | ||
| fd = open(os.path.join('wallets', possible_wallet), 'r') | ||
| dirname = os.path.split(os.path.abspath(__file__)) |
This file contains hidden or 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
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.jsonI 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!