Merge pull request #1846 from lbryio/create-directories-if-dont-exist

create data. download, and wallet directories if they don't exist on startup
This commit is contained in:
Jack Robison 2019-02-01 22:57:27 -05:00 committed by GitHub
commit 4e27eaf8e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,6 @@
import os
import sys
import pathlib
import json
import asyncio
import argparse
@ -216,12 +218,19 @@ def get_argument_parser():
return main
def ensure_directory_exists(path: str):
if not os.path.isdir(path):
pathlib.Path(path).mkdir(parents=True, exist_ok=True)
def main(argv=None):
argv = argv or sys.argv[1:]
parser = get_argument_parser()
args, command_args = parser.parse_known_args(argv)
conf = Config.create_from_arguments(args)
for directory in (conf.data_dir, conf.download_dir, conf.wallet_dir):
ensure_directory_exists(directory)
if args.cli_version:
print(f"{lbrynet_name} {lbrynet_version}")