fix: throw if directory exsists
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
067f354905
commit
5f22220825
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
# standard import
|
# standard import
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from chainlib.cli.config import Config
|
from chainlib.cli.config import Config
|
||||||
|
|
||||||
@ -66,13 +66,17 @@ def execute(
|
|||||||
if wallet_keystore:
|
if wallet_keystore:
|
||||||
config.add(wallet_keystore, "WALLET_KEY_FILE", exists_ok=True)
|
config.add(wallet_keystore, "WALLET_KEY_FILE", exists_ok=True)
|
||||||
|
|
||||||
if not skip_gen:
|
if skip_gen:
|
||||||
|
contract = load_contract(directory)
|
||||||
|
else:
|
||||||
|
if os.path.exists(directory):
|
||||||
|
raise Exception(f"Directory {directory} already exists")
|
||||||
if csv_file:
|
if csv_file:
|
||||||
|
print(f"Generating from csv:{csv_file} to {directory}")
|
||||||
contract = load_contract_from_csv(config, directory, csv_file)
|
contract = load_contract_from_csv(config, directory, csv_file)
|
||||||
else:
|
else:
|
||||||
|
print("Using Interactive Mode")
|
||||||
contract = generate_contract(directory, [target], config, interactive=True)
|
contract = generate_contract(directory, [target], config, interactive=True)
|
||||||
else:
|
|
||||||
contract = load_contract(directory)
|
|
||||||
|
|
||||||
print(contract)
|
print(contract)
|
||||||
|
|
||||||
|
@ -4,13 +4,8 @@ import logging
|
|||||||
import os
|
import os
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
# external imports
|
|
||||||
from cic_types.ext.metadata import MetadataRequestsHandler
|
|
||||||
from cic_types.ext.metadata.signer import Signer as MetadataSigner
|
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from chainlib.cli.config import Config
|
from chainlib.cli.config import Config
|
||||||
|
|
||||||
# Local Modules
|
# Local Modules
|
||||||
from cic.contract.components.attachment import Attachment
|
from cic.contract.components.attachment import Attachment
|
||||||
from cic.contract.components.meta import Meta
|
from cic.contract.components.meta import Meta
|
||||||
@ -20,8 +15,9 @@ from cic.contract.helpers import init_writers_from_config
|
|||||||
from cic.contract.network import Network
|
from cic.contract.network import Network
|
||||||
from cic.contract.processor import ContractProcessor
|
from cic.contract.processor import ContractProcessor
|
||||||
from cic.writers import HTTPWriter, KeyedWriterFactory, MetadataWriter
|
from cic.writers import HTTPWriter, KeyedWriterFactory, MetadataWriter
|
||||||
|
# external imports
|
||||||
|
from cic_types.ext.metadata import MetadataRequestsHandler
|
||||||
|
from cic_types.ext.metadata.signer import Signer as MetadataSigner
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -74,16 +70,6 @@ def load_contract(directory) -> Contract:
|
|||||||
def generate_contract(
|
def generate_contract(
|
||||||
directory: str, targets: List[str], config, interactive=True
|
directory: str, targets: List[str], config, interactive=True
|
||||||
) -> Contract:
|
) -> Contract:
|
||||||
if os.path.exists(directory):
|
|
||||||
contine = input(
|
|
||||||
f"Directory {directory} already exists, Would you like to delete it? (y/n): "
|
|
||||||
)
|
|
||||||
if contine.lower() != "y":
|
|
||||||
log.debug("Trying to load existing contract")
|
|
||||||
return load_contract(directory)
|
|
||||||
else:
|
|
||||||
print(f"Deleted {directory}")
|
|
||||||
os.system(f"rm -rf {directory}")
|
|
||||||
os.makedirs(directory)
|
os.makedirs(directory)
|
||||||
log.info("Generating token")
|
log.info("Generating token")
|
||||||
token = Token(directory, interactive=interactive)
|
token = Token(directory, interactive=interactive)
|
||||||
|
Loading…
Reference in New Issue
Block a user