Skip to content

Commit

Permalink
Update the python scripts to prioritize arguments over environment va…
Browse files Browse the repository at this point in the history
…riables (#302)

[#301] Update the python scripts to prioritize arguments over environment variables

Signed-off-by: Antonia Avramova <antonia.avramova@bosch.io>
  • Loading branch information
antonia-avramova authored Dec 19, 2023
1 parent ccb39c0 commit e80d0bd
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions quickstart/hono_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def on_sendable(self, event):
# Parse command line args
options, reminder = getopt.getopt(sys.argv[2:], 't:d:', ["img=", "id="])
opts_dict = dict(options)
tenant_id = os.environ.get("TENANT") or opts_dict['-t']
device_id = os.environ.get("DEVICE_ID") or opts_dict['-d']
tenant_id = opts_dict.get('-t') or os.environ["TENANT"]
device_id = opts_dict.get('-d') or os.environ["DEVICE_ID"]
command = sys.argv[1]
if command == CLI_OPT_RUN_CMD:
container_img_ref = opts_dict['--img']
Expand Down
6 changes: 3 additions & 3 deletions quickstart/hono_commands_fb.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ def on_connection_closed(self, event):
# Parse command line args
options, reminder = getopt.getopt(sys.argv[2:], 't:d:h:')
opts_dict = dict(options)
tenant_id = os.environ.get("TENANT") or opts_dict['-t']
device_id = os.environ.get("DEVICE_ID") or opts_dict['-d']
host = os.environ.get("HOST") or opts_dict['-h']
tenant_id = opts_dict.get('-t') or os.environ["TENANT"]
device_id = opts_dict.get('-d') or os.environ["DEVICE_ID"]
host = opts_dict.get('-h') or os.environ["HOST"]
command = sys.argv[1]
if command == CLI_OPT_BACKUP_CMD:
action = "backup"
Expand Down
4 changes: 2 additions & 2 deletions quickstart/hono_commands_fu.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def on_connection_closed(self, event):
# Parse command line args
options, reminder = getopt.getopt(sys.argv[1:], 't:d:')
opts_dict = dict(options)
tenant_id = os.environ.get("TENANT") or opts_dict['-t']
device_id = os.environ.get("DEVICE_ID") or opts_dict['-d']
tenant_id = opts_dict.get('-t') or os.environ["TENANT"]
device_id = opts_dict.get('-d') or os.environ["DEVICE_ID"]

# AMQP global configurations
uri = 'amqps://hono.eclipseprojects.io:15671'
Expand Down
6 changes: 3 additions & 3 deletions quickstart/hono_commands_sb.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ def on_connection_closed(self, event):
# Parse command line args
options, reminder = getopt.getopt(sys.argv[1:], 't:d:p:')
opts_dict = dict(options)
tenant_id = opts_dict['-t'] or os.environ.get("TENANT")
device_id = opts_dict['-d'] or os.environ.get("DEVICE_ID")
new_password = opts_dict['-p'] or os.environ.get("PASSWORD")
tenant_id = opts_dict.get('-t') or os.environ["TENANT"]
device_id = opts_dict.get('-d') or os.environ["DEVICE_ID"]
new_password = opts_dict.get('-p') or os.environ["PASSWORD"]

hono_ep = 'https://hono.eclipseprojects.io:28443'

Expand Down
4 changes: 2 additions & 2 deletions quickstart/hono_commands_sm.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ def run(self):
# Parse command line args
options, reminder = getopt.getopt(sys.argv[1:], 't:d:')
opts_dict = dict(options)
tenant_id = os.environ.get("TENANT") or opts_dict['-t']
device_id = os.environ.get("DEVICE_ID") or opts_dict['-d']
tenant_id = opts_dict.get('-t') or os.environ["TENANT"]
device_id = opts_dict.get('-d') or os.environ["DEVICE_ID"]

# AMQP global configurations
uri = 'amqps://hono.eclipseprojects.io:15671'
Expand Down
4 changes: 2 additions & 2 deletions quickstart/hono_commands_su.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def on_sendable(self, event):
# Parse command line args
options, reminder = getopt.getopt(sys.argv[1:], 't:d:')
opts_dict = dict(options)
tenant_id = os.environ.get("TENANT") or opts_dict['-t']
device_id = os.environ.get("DEVICE_ID") or opts_dict['-d']
tenant_id = opts_dict.get('-t') or os.environ["TENANT"]
device_id = opts_dict.get('-d') or os.environ["DEVICE_ID"]


# AMQP global configurations
Expand Down
2 changes: 1 addition & 1 deletion quickstart/hono_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def on_message(self, event):

# Parse command line args
options, reminder = getopt.getopt(sys.argv[1:], 't:')
tenant_id = os.environ.get("TENANT") or dict(options)['-t']
tenant_id = dict(options).get('-t') or os.environ["TENANT"]

uri = 'amqps://hono.eclipseprojects.io:15671'
address = 'event/{}'.format(tenant_id)
Expand Down

0 comments on commit e80d0bd

Please sign in to comment.