moved variables and OS login into main program
This commit is contained in:
@@ -17,30 +17,6 @@ from secure_delete import secure_delete
|
|||||||
from kmip.core import enums
|
from kmip.core import enums
|
||||||
from kmip.pie import client
|
from kmip.pie import client
|
||||||
|
|
||||||
secure_delete.secure_random_seed_init()
|
|
||||||
os_detected = platform.system()
|
|
||||||
script_directory = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
working_directory = os.path.join(script_directory, "working")
|
|
||||||
exports_directory = os.path.join(script_directory, "exports")
|
|
||||||
script_name = os.path.basename(__file__)
|
|
||||||
secrets_config_file = os.path.join(script_directory, "secrets.config")
|
|
||||||
pykmip_client_config_file = os.path.join(script_directory, "conf", "client.conf")
|
|
||||||
log_file = os.path.join(script_directory, "log.log")
|
|
||||||
datetime_string = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
||||||
|
|
||||||
if os_detected == "Windows":
|
|
||||||
bitwarden_cli_executable = os.path.join(script_directory, "lib", "Bitwarden CLI", "bw.exe")
|
|
||||||
gpg_executable = os.path.join(script_directory, "lib", "gpg", "bin", "gpg.exe")
|
|
||||||
elif os_detected == "Linux":
|
|
||||||
bitwarden_cli_executable = os.path.join(script_directory, "lib", "Bitwarden CLI", "bw_linux")
|
|
||||||
elif os_detected == "macOS":
|
|
||||||
bitwarden_cli_executable = os.path.join(script_directory, "lib", "Bitwarden CLI", "bw_macOS")
|
|
||||||
else:
|
|
||||||
print("Your OS is not supported. Only Windows, Linux, and macOS are supported. Those are the only three supported OSes for the Bitwarden CLI.")
|
|
||||||
print("Detected OS: {0}".format(os_detected))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
def build_logger(level):
|
def build_logger(level):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(level)
|
logger.setLevel(level)
|
||||||
@@ -313,7 +289,6 @@ def edit_account_details(accounts, email):
|
|||||||
array[account_email_address]["account_vault_password"] = account_vault_password
|
array[account_email_address]["account_vault_password"] = account_vault_password
|
||||||
return array
|
return array
|
||||||
|
|
||||||
|
|
||||||
def select_account(accounts, wording = "edit"):
|
def select_account(accounts, wording = "edit"):
|
||||||
print("Which account would you like to {}:".format(wording))
|
print("Which account would you like to {}:".format(wording))
|
||||||
print(" ")
|
print(" ")
|
||||||
@@ -357,6 +332,29 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
logger = build_logger(logging.INFO)
|
logger = build_logger(logging.INFO)
|
||||||
|
|
||||||
|
secure_delete.secure_random_seed_init()
|
||||||
|
os_detected = platform.system()
|
||||||
|
script_directory = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
working_directory = os.path.join(script_directory, "working")
|
||||||
|
exports_directory = os.path.join(script_directory, "exports")
|
||||||
|
script_name = os.path.basename(__file__)
|
||||||
|
secrets_config_file = os.path.join(script_directory, "secrets.config")
|
||||||
|
pykmip_client_config_file = os.path.join(script_directory, "conf", "client.conf")
|
||||||
|
log_file = os.path.join(script_directory, "log.log")
|
||||||
|
datetime_string = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||||
|
|
||||||
|
if os_detected == "Windows":
|
||||||
|
bitwarden_cli_executable = os.path.join(script_directory, "lib", "Bitwarden CLI", "bw.exe")
|
||||||
|
gpg_executable = os.path.join(script_directory, "lib", "gpg", "bin", "gpg.exe")
|
||||||
|
elif os_detected == "Linux":
|
||||||
|
bitwarden_cli_executable = os.path.join(script_directory, "lib", "Bitwarden CLI", "bw_linux")
|
||||||
|
elif os_detected == "macOS":
|
||||||
|
bitwarden_cli_executable = os.path.join(script_directory, "lib", "Bitwarden CLI", "bw_macOS")
|
||||||
|
else:
|
||||||
|
print("Your OS is not supported. Only Windows, Linux, and macOS are supported. Those are the only three supported OSes for the Bitwarden CLI.")
|
||||||
|
print("Detected OS: {0}".format(os_detected))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
client = client.ProxyKmipClient(config_file=pykmip_client_config_file)
|
client = client.ProxyKmipClient(config_file=pykmip_client_config_file)
|
||||||
client.open()
|
client.open()
|
||||||
#print(encrypt(client, "test"))
|
#print(encrypt(client, "test"))
|
||||||
|
|||||||
Reference in New Issue
Block a user