From 26ca08b4f5061a6b6fe1247cbe9effbed3bd755b Mon Sep 17 00:00:00 2001 From: Sou Niyari Date: Sun, 23 Oct 2022 14:26:34 +0900 Subject: [PATCH] add guards for directly-executed modules (#37) Co-authored-by: eli fessler --- iksm.py | 9 +++++++-- utils.py | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/iksm.py b/iksm.py index 6371c21..b7d3102 100644 --- a/iksm.py +++ b/iksm.py @@ -2,8 +2,8 @@ # https://github.com/frozenpandaman/s3s # License: GPLv3 -import requests, json, re, sys -import os, base64, hashlib +import base64, hashlib, json, os, re, sys +import requests from bs4 import BeautifulSoup session = requests.Session() @@ -379,3 +379,8 @@ def enter_tokens(): new_bullettoken = input("Invalid token - length should be 124 characters. Try again.\nEnter your bulletToken: ") return new_gtoken, new_bullettoken + + +if __name__ == "__main__": + print("This program cannot be run alone. See https://github.com/frozenpandaman/s3s") + sys.exit(0) diff --git a/utils.py b/utils.py index d133eae..6fb74c7 100644 --- a/utils.py +++ b/utils.py @@ -2,7 +2,8 @@ # https://github.com/frozenpandaman/s3s # License: GPLv3 -import base64, datetime, json, re, requests, uuid +import base64, datetime, json, re, sys, uuid +import requests from bs4 import BeautifulSoup SPLATNET3_URL = "https://api.lp1.av5ja.srv.nintendo.net" @@ -103,3 +104,8 @@ def custom_key_exists(key, config_data, value=True): if key not in ["ignore_private", "app_user_agent", "force_uploads"]: print("(!) Checking unexpected custom key") return True if key in config_data and config_data[key].lower() == str(value).lower() else False + + +if __name__ == "__main__": + print("This program cannot be run alone. See https://github.com/frozenpandaman/s3s") + sys.exit(0)