-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from amelchio/connection-control
Connection control
- Loading branch information
Showing
5 changed files
with
148 additions
and
10 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,32 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Example file for eternalegypt library.""" | ||
|
||
import sys | ||
import asyncio | ||
import aiohttp | ||
import logging | ||
|
||
import eternalegypt | ||
|
||
async def set_autoconnect_mode(mode): | ||
"""Example of printing the current upstream.""" | ||
jar = aiohttp.CookieJar(unsafe=True) | ||
websession = aiohttp.ClientSession(cookie_jar=jar) | ||
|
||
try: | ||
modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) | ||
await modem.login(password=sys.argv[2]) | ||
|
||
await modem.set_autoconnect_mode(mode) | ||
|
||
await modem.logout() | ||
except eternalegypt.Error: | ||
print("Could not login") | ||
|
||
await websession.close() | ||
|
||
if len(sys.argv) != 4: | ||
print("{}: <netgear ip> <netgear password> <mode>".format(sys.argv[0])) | ||
else: | ||
asyncio.get_event_loop().run_until_complete(set_autoconnect_mode(sys.argv[3])) |
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,32 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Example file for eternalegypt library.""" | ||
|
||
import sys | ||
import asyncio | ||
import aiohttp | ||
import logging | ||
|
||
import eternalegypt | ||
|
||
async def connect(): | ||
"""Example of printing the current upstream.""" | ||
jar = aiohttp.CookieJar(unsafe=True) | ||
websession = aiohttp.ClientSession(cookie_jar=jar) | ||
|
||
try: | ||
modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) | ||
await modem.login(password=sys.argv[2]) | ||
|
||
await modem.connect_lte() | ||
|
||
await modem.logout() | ||
except eternalegypt.Error: | ||
print("Could not login") | ||
|
||
await websession.close() | ||
|
||
if len(sys.argv) != 3: | ||
print("{}: <netgear ip> <netgear password>".format(sys.argv[0])) | ||
else: | ||
asyncio.get_event_loop().run_until_complete(connect()) |
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,32 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Example file for eternalegypt library.""" | ||
|
||
import sys | ||
import asyncio | ||
import aiohttp | ||
import logging | ||
|
||
import eternalegypt | ||
|
||
async def set_failover_mode(mode): | ||
"""Example of printing the current upstream.""" | ||
jar = aiohttp.CookieJar(unsafe=True) | ||
websession = aiohttp.ClientSession(cookie_jar=jar) | ||
|
||
try: | ||
modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) | ||
await modem.login(password=sys.argv[2]) | ||
|
||
await modem.set_failover_mode(mode) | ||
|
||
await modem.logout() | ||
except eternalegypt.Error: | ||
print("Could not login") | ||
|
||
await websession.close() | ||
|
||
if len(sys.argv) != 4: | ||
print("{}: <netgear ip> <netgear password> <mode>".format(sys.argv[0])) | ||
else: | ||
asyncio.get_event_loop().run_until_complete(set_failover_mode(sys.argv[3])) |
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