I'm trying to pass arguments to my Python program via launch.json and one of my arguments requires special characters as it is the password (I plan to add more secure ways to input the password but that's not the point).
Here's my launch.json (with the password changed but still with special characters)
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"args": [
"-u",
"camera@iot-project.com",
"-p",
"Y^bKKiUPu!fM6!dBsvnALmuXbP6fqT$d"
],
"console": "integratedTerminal"
}
]
}
When I set my password argument to "'Y^bKKiUPu!fM6!dBsvnALmuXbP6fqT$d'", it actually passes the single quotes into the Python program, which isn't what I want (running the program in a terminal with single quotes works).
Here is my Python program:
import sys
import getopt
import pyrebase
# Get full command-line arguments
argument_list = sys.argv
# Keep all but the first
argument_list = argument_list[1:]
# Parse arguments
try:
options, arguments = getopt.getopt(argument_list, "u:p:", ["username", "password"])
except getopt.GetoptError as error:
print(error)
exit(1)
# Get username and password from arguments
for option, argument in options:
if option in ["-u", "--username"]:
username = argument
if option in ["-p", "--password"]:
password = argument
config = {
"apiKey": "*apikeyhere*",
"authDomain": "*domain*.firebaseapp.com",
"databaseURL": None,
"storageBucket": "*domain*.appspot.com",
}
firebase = pyrebase.initialize_app(config)
print(username)
print(password)
firebaseAuth = firebase.auth()
user = firebaseAuth.sign_in_with_email_and_password(username, password)
