create data. download, and wallet directories if they don't exist on startup

This commit is contained in:
Jack Robison 2019-02-01 22:29:07 -05:00
parent 478f79353a
commit ccbe8aa0eb
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

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}")