Skip to content

Commit

Permalink
add skip_validation argument to totalseg_set_license
Browse files Browse the repository at this point in the history
  • Loading branch information
wasserth committed Feb 8, 2024
1 parent a0ccc4d commit 06b7d0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion totalsegmentator/bin/totalseg_set_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def main():
parser.add_argument("-l", "--license_number", type=str, help="TotalSegmentator license number.",
required=True)

parser.add_argument("-sv", "--skip_validation", action="store_true",
help="Do not evaluate if license number is valid. " +
"Use this option only if you are sure that the license number is valid. " +
"Otherwise, the tool will not work properly.",
default=False)

args = parser.parse_args()

if not args.license_number.startswith("aca_"):
Expand All @@ -27,7 +33,7 @@ def main():
raise ValueError("license number must have exactly 18 characters.")

setup_totalseg() # create config file if not exists
set_license_number(args.license_number)
set_license_number(args.license_number, skip_validation=args.skip_validation)

print("License has been successfully saved.")

Expand Down
9 changes: 5 additions & 4 deletions totalsegmentator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ def setup_totalseg(totalseg_id=None):
return config


def set_license_number(license_number):
if not is_valid_license(license_number):
print("ERROR: Invalid license number. Please check your license number or contact support.")
sys.exit(1)
def set_license_number(license_number, skip_validation=False):
if not skip_validation:
if not is_valid_license(license_number):
print("ERROR: Invalid license number. Please check your license number or contact support.")
sys.exit(1)

totalseg_dir = get_totalseg_dir()
totalseg_config_file = totalseg_dir / "config.json"
Expand Down

0 comments on commit 06b7d0e

Please sign in to comment.