File: user_agent_options.py

package info (click to toggle)
growattserver 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 296 kB
  • sloc: python: 1,344; makefile: 2
file content (51 lines) | stat: -rwxr-xr-x 1,860 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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("")