Skip to content
This repository was archived by the owner on Apr 16, 2021. It is now read-only.

Commit 95c7a0b

Browse files
committed
example upkeep. provide a pipenv script to run all of them.
sleep for 5 seconds in between examples so we don't get a HTTP 429 "too many requests" from RH's API
1 parent ca4f631 commit 95c7a0b

File tree

5 files changed

+59
-51
lines changed

5 files changed

+59
-51
lines changed

Diff for: Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ coveralls:
1313
.PHONY: lint
1414
lint:
1515
pipenv run tox -e lint
16+
17+
18+
.PHONY: examples
19+
examples:
20+
pipenv run run_all_examples

Diff for: Pipfile

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ ipdb = "*"
2424

2525
[requires]
2626
python_version = "3.6"
27+
28+
[scripts]
29+
run_all_examples = "sh ./run_all_examples.sh"

Diff for: examples/auth.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44

55
print("----- running {}".format(__file__))
66

7-
# #
8-
# # get the authentication configs
9-
# #
10-
# config_file = "config.debug.ini"
11-
# config = configparser.ConfigParser()
12-
# config.read(config_file)
13-
# username = config['account']['username']
14-
# password = config['account']['password']
157
#
16-
# client = Client(username=username, password=password)
17-
# result = client.authenticate()
8+
# get the authentication configs
189
#
19-
# print("Authenticated successfully = {}".format(result))
20-
#
21-
# print("Account Url = {}".format(client.account_url))
22-
# print("Account Id = {}".format(client.account_id))
23-
#
24-
# user = User.fetch(client)
25-
# print("Username = {}".format(user["username"]))
26-
#
27-
# result = client.relogin_oauth2()
28-
# print("Re-Authenticated with refresh_token successfully = {}".format(result))
29-
#
30-
# result = client.logout_oauth2()
31-
# print("Logged out successfully = {}".format(result))
10+
config_file = "config.debug.ini"
11+
config = configparser.ConfigParser()
12+
config.read(config_file)
13+
username = config['account']['username']
14+
password = config['account']['password']
15+
16+
client = Client(username=username, password=password)
17+
result = client.authenticate()
18+
19+
print("Authenticated successfully = {}".format(result))
20+
21+
print("Account Url = {}".format(client.account_url))
22+
print("Account Id = {}".format(client.account_id))
23+
24+
user = User.fetch(client)
25+
print("Username = {}".format(user["username"]))
26+
27+
result = client.relogin_oauth2()
28+
print("Re-Authenticated with refresh_token successfully = {}".format(result))
29+
30+
result = client.logout_oauth2()
31+
print("Logged out successfully = {}".format(result))

Diff for: examples/auth_mfa.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@
44

55
print("----- running {}".format(__file__))
66

7-
#
8-
# get the authentication configs
9-
#
10-
# config_file = "config.debug.ini"
11-
# config = configparser.ConfigParser()
12-
# config.read(config_file)
13-
# username = config['account']['username']
14-
# password = config['account']['password']
15-
#
16-
# mfa_code = "code goes here as a string"
17-
#
18-
# client = Client(username=username, password=password, mfa_code=mfa_code)
19-
# result = client.authenticate()
20-
#
21-
# print("Authenticated successfully = {}".format(result))
22-
#
23-
# print("Account Url = {}".format(client.account_url))
24-
# print("Account Id = {}".format(client.account_id))
25-
#
26-
# user = User.fetch(client)
27-
# print("Username = {}".format(user["username"]))
28-
#
29-
# result = client.relogin_oauth2()
30-
# print("Re-Authenticated with refresh_token successfully = {}".format(result))
31-
#
32-
# result = client.logout_oauth2()
33-
# print("Logged out successfully = {}".format(result))
7+
8+
get the authentication configs
9+
10+
config_file = "config.debug.ini"
11+
config = configparser.ConfigParser()
12+
config.read(config_file)
13+
username = config['account']['username']
14+
password = config['account']['password']
15+
16+
mfa_code = "code goes here as a string"
17+
18+
client = Client(username=username, password=password, mfa_code=mfa_code)
19+
result = client.authenticate()
20+
21+
print("Authenticated successfully = {}".format(result))
22+
23+
print("Account Url = {}".format(client.account_url))
24+
print("Account Id = {}".format(client.account_id))
25+
26+
user = User.fetch(client)
27+
print("Username = {}".format(user["username"]))
28+
29+
result = client.relogin_oauth2()
30+
print("Re-Authenticated with refresh_token successfully = {}".format(result))
31+
32+
result = client.logout_oauth2()
33+
print("Logged out successfully = {}".format(result))

Diff for: run_all_examples.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
for f in examples/*.py; do sleep 2s && python "$f"; done
1+
for f in examples/*.py; do sleep 5s && python "$f"; done

0 commit comments

Comments
 (0)