Skip to content

Commit

Permalink
Merge pull request #208 from lassoan/fix-license-setting
Browse files Browse the repository at this point in the history
Fix license setting
  • Loading branch information
wasserth authored Oct 24, 2023
2 parents e0355ec + ed5be30 commit c695b4c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions totalsegmentator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def setup_totalseg(totalseg_id=None):
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(0)
sys.exit(1)

totalseg_dir = get_totalseg_dir()
totalseg_config_file = totalseg_dir / "config.json"
Expand Down Expand Up @@ -106,7 +106,7 @@ def is_valid_license(license_number):
try:
url = f"http://backend.totalsegmentator.com:80/"
r = requests.post(url + "is_valid_license_number",
json={"license_number": license_number}, timeout=2)
json={"license_number": license_number}, timeout=5)
if r.ok:
return r.json()['status'] == "valid_license"
else:
Expand Down Expand Up @@ -226,7 +226,7 @@ def send_usage_stats(config, params):
"python_version": sys.version,
"cuda_available": torch.cuda.is_available(),
"license_number": license_number
}, timeout=2)
}, timeout=5)
# if r.ok:
# print(f"status: {r.json()['status']}")
# else:
Expand Down
2 changes: 1 addition & 1 deletion totalsegmentator/libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def download_model_with_license_and_unpack(task_name, config_dir):
else:
if r.json()['status'] == "invalid_license":
print(f"ERROR: Invalid license number ({license_number}). Please check your license number or contact support.")
sys.exit(0)
sys.exit(1)

except Exception as e:
raise e
Expand Down
6 changes: 3 additions & 3 deletions totalsegmentator/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def show_license_info():
For commercial usage contact: jakob.wasserthal@usb.ch
"""))
sys.exit(0)
sys.exit(1)
elif status == "invalid_license":
print(message)
sys.exit(0)
sys.exit(1)
elif status == "missing_config_file":
print(message)
sys.exit(0)
sys.exit(1)


def totalsegmentator(input, output, ml=False, nr_thr_resamp=1, nr_thr_saving=6,
Expand Down

0 comments on commit c695b4c

Please sign in to comment.