-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add randomly generated user agents (#42)
- Loading branch information
1 parent
887655a
commit 2621367
Showing
3 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import growattServer | ||
import getpass | ||
|
||
""" | ||
This is a simple script that demonstrates the various ways to initialise the library to set a User Agent | ||
""" | ||
|
||
#Prompt user for username | ||
username=input("Enter username:") | ||
|
||
#Prompt user to input password | ||
user_pass=getpass.getpass("Enter password:") | ||
|
||
|
||
|
||
api = growattServer.GrowattApi() | ||
login_response = api.login(username, user_pass) | ||
print("Default initialisation") | ||
print("User-Agent: %s\nLogged in User id: %s" % (api.agent_identifier, login_response['userId'])) | ||
print("") | ||
|
||
api = growattServer.GrowattApi(True) | ||
login_response = api.login(username, user_pass) | ||
print("Add random ID to default User-Agent") | ||
print("User-Agent: %s\nLogged in User id: %s" % (api.agent_identifier, login_response['userId'])) | ||
print("") | ||
|
||
api = growattServer.GrowattApi(False, "my-user-id") | ||
login_response = api.login(username, user_pass) | ||
print("Override default User-Agent") | ||
print("User-Agent: %s\nLogged in User id: %s" % (api.agent_identifier, login_response['userId'])) | ||
print("") | ||
|
||
api = growattServer.GrowattApi(True, "my-user-id") | ||
login_response = api.login(username, user_pass) | ||
print("Override default User-Agent and add random ID") | ||
print("User-Agent: %s\nLogged in User id: %s" % (api.agent_identifier, login_response['userId'])) | ||
print("") | ||
|
||
api = growattServer.GrowattApi(False, growattServer.GrowattApi.agent_identifier + " - my-user-id") | ||
login_response = api.login(username, user_pass) | ||
print("Extend default User-Agent") | ||
print("User-Agent: %s\nLogged in User id: %s" % (api.agent_identifier, login_response['userId'])) | ||
print("") | ||
|
||
api = growattServer.GrowattApi(True, growattServer.GrowattApi.agent_identifier + " - my-user-id") | ||
login_response = api.login(username, user_pass) | ||
print("Extend default User-Agent and add random ID") | ||
print("User-Agent: %s\nLogged in User id: %s" % (api.agent_identifier, login_response['userId'])) | ||
print("") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters