change to python3 instead of explicit 3.6
This commit is contained in:
1
net/devices/actiontec/ActionTec/Cmd.py
Executable file
1
net/devices/actiontec/ActionTec/Cmd.py
Executable file
@@ -0,0 +1 @@
|
||||
#!/usr/bin/env python3.6
|
||||
66
net/devices/actiontec/ActionTec/Connector.py
Executable file
66
net/devices/actiontec/ActionTec/Connector.py
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3.6
|
||||
|
||||
# stdlib
|
||||
import re
|
||||
import socket
|
||||
|
||||
def CheckConnection(host, port):
|
||||
# We favor socket over telnetlib's check because it has a little better
|
||||
# handling of exceptions.
|
||||
try:
|
||||
port = int(port) # just in case we were passed a str()
|
||||
except ValueError:
|
||||
raise ValueError('"{0}" is not a port number'.format(port))
|
||||
# In case they're catching the exception...
|
||||
return(False)
|
||||
s = socket.socket()
|
||||
try:
|
||||
s.connect((host, port))
|
||||
except Exception as e:
|
||||
raise RuntimeError(('We were unable to successfully connect to ' +
|
||||
'"{0}:{1}": {2}').format(host, port, e))
|
||||
return(False)
|
||||
finally:
|
||||
s.close()
|
||||
return(True)
|
||||
|
||||
def Login(host, port, ssl, user, password):
|
||||
user_prompt = [re.compile('^\s*user(name)?\s*:?\s*'.encode('utf-8'),
|
||||
re.IGNORECASE)]
|
||||
passwd_prompt = [re.compile('^\s*passw(or)d?\s*:?\s*'.encode('utf-8'),
|
||||
re.IGNORECASE)]
|
||||
# Are there any other valid chars? Will need to experiment.
|
||||
# How is this even set? The default is "Wireless Broadband Router".
|
||||
# I think it can't be changed, at least via the Web GUI.
|
||||
cmd_prompt = [re.compile('[-_a-z0-9\s]*>'.encode('utf-8'),
|
||||
re.IGNORECASE)]
|
||||
ctx = None
|
||||
ctxargs = {'host': host, 'port': port}
|
||||
try:
|
||||
if ssl:
|
||||
try:
|
||||
from ssltelnet import SslTelnet as telnet
|
||||
ctxargs['force_ssl'] = True
|
||||
except ImportError:
|
||||
raise ImportError(('You have enabled SSL but do not have ' +
|
||||
'the ssltelnet module installed. See ' +
|
||||
'the README file, footnote [1].'))
|
||||
else:
|
||||
from telnetlib import Telnet as telnet
|
||||
ctx = telnet(**ctxargs)
|
||||
ctx.expect(user_prompt, timeout = 8)
|
||||
ctx.write((user + '\n').encode('utf-8'))
|
||||
ctx.expect(passwd_prompt, timeout = 8)
|
||||
ctx.write((password + '\n').encode('utf-8'))
|
||||
ctx.expect(cmd_prompt, timeout = 15)
|
||||
except EOFError:
|
||||
if ctx:
|
||||
ctx.close()
|
||||
ctx = None
|
||||
except Exception as e:
|
||||
raise RuntimeError(('We encountered an error when trying to connect:' +
|
||||
' {0}').format(e))
|
||||
if ctx:
|
||||
ctx.close()
|
||||
ctx = None
|
||||
return(ctx)
|
||||
33
net/devices/actiontec/ActionTec/__init__.py
Executable file
33
net/devices/actiontec/ActionTec/__init__.py
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3.6
|
||||
|
||||
import .Cmd as Cmd
|
||||
import .Connector as Connector
|
||||
|
||||
class Router(object):
|
||||
def __init__(self, host, port, user, password, ssl = False):
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.user = user
|
||||
self.password = password
|
||||
self.ssl = ssl
|
||||
self.ctx = None
|
||||
# Convenient shorthand. See "help.all.txt".
|
||||
self.cmds = {'reboot': 'system reboot',
|
||||
'wipe': 'conf factory restore',
|
||||
# this will... require an interactive session
|
||||
'shell': 'system shell'}
|
||||
|
||||
def connect(self):
|
||||
# We don't need to define an except, really.
|
||||
# The function handles that for us.
|
||||
Connector.CheckConnection(self.host, self.port)
|
||||
self.ctx = Connector.Login(self.host, self.port, self.ssl, self.user,
|
||||
self.password)
|
||||
return()
|
||||
|
||||
def execute(self):
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
if self.ctx:
|
||||
self.ctx.close()
|
||||
177
net/devices/actiontec/ActionTec/help.all.txt
Normal file
177
net/devices/actiontec/ActionTec/help.all.txt
Normal file
@@ -0,0 +1,177 @@
|
||||
Command Category wanmonitor - wanmonitor commands for rtd, do not use it directly
|
||||
get notify wanmonitor to send wan type to rtd
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category conf - Read and write Wireless Broadband Router configuration data
|
||||
factory Factory related commands
|
||||
print Print Wireless Broadband Router configuration
|
||||
set Set Wireless Broadband Router configuration path to value
|
||||
set_obscure Set Wireless Broadband Router configuration path to an
|
||||
obscured value
|
||||
del Delete subtree from Wireless Broadband Router configuration
|
||||
ram_set Set Wireless Broadband Router dynamic configuration
|
||||
ram_print Print Wireless Broadband Router dynamic configuration
|
||||
reconf Reconfigure the system according to the current Wireless
|
||||
Broadband Router configuration
|
||||
firmware_restore Restore to saved firmware and reboot.
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category upnp - UPnP commands
|
||||
igd IGD commands
|
||||
status Display UPnP status
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category qos - Control and display QoS data
|
||||
utilization Connection utilization information
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category wmm - wmm configuration and control
|
||||
get get the specified entry
|
||||
set set the specified entry
|
||||
del del the specified entry
|
||||
get_dev get the entries of the specified device
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category cwmp - CWMP related commands
|
||||
status Print CWMP status
|
||||
session_start Start CWMP session to ACS
|
||||
session_stop Stop CWMP session
|
||||
indexes Print CWMP devices indexes
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category bridge - API for managing ethernet bridge
|
||||
connection connect separate network interfaces to form one seamless LAN
|
||||
config Configure bridge
|
||||
info Print bridge information
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category firewall - Control and display Firewall and NAT data
|
||||
restart Stop and start Firewall & NAT
|
||||
start Start Firewall & NAT
|
||||
stop Stop Firewall & NAT
|
||||
filter Turn Firewall packet inspection on/off
|
||||
mac_cache_dump Dump MAC cache data
|
||||
dump Display Firewall data
|
||||
variable Display variables of the firewall rules
|
||||
trace Trace packet traversal via the Firewall ruleset
|
||||
fastpath Turns firewall fastpath feature on/off (default is on)
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category connection - API for managing connections
|
||||
pppoe Configure pppoe interface
|
||||
vlan Configure vlan interface
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category inet_connection - API for managing internet connections
|
||||
pppoe Configure pppoe internet connection
|
||||
ether Configure ethernet internet connection
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category misc - API for Wireless Broadband Router miscellaneous tasks
|
||||
print_ram print ram consumption for each process
|
||||
vlan_add Add VLAN interface
|
||||
top Profiling over event loop and estream
|
||||
wbm_debug_set Stop and start WBM debug mode
|
||||
wbm_border_set Stop and start WBM border mode
|
||||
knet_hooks_dump Dump to console which knet_hooks run on each device
|
||||
malloc_info Print memory information of malloc module
|
||||
malloc_trim Free unused allocated memory in malloc module
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category firmware_update - Firmware update commands
|
||||
start Remotely upgrade Wireless Broadband Router
|
||||
cancel Kill running remote upgrade
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category log - Controls Wireless Broadband Router logging behavior
|
||||
filter Controls the CLI session logging behavior
|
||||
print Print the contents of a given syslog buffer to the console
|
||||
clear Clear the contents of a given syslog buffer
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category dev - Device related commands
|
||||
mv88e60xx Marvell MV88e60xx Ethernet Switch commands
|
||||
moca MOCA commands
|
||||
mii_reg_get Get Ethernet MII register value
|
||||
mii_reg_set Set Ethernet MII register value
|
||||
mii_phy_reg_get Get Ethernet MII register value
|
||||
mii_phy_reg_set Set Ethernet MII register value
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category kernel - Kernel related commands
|
||||
sys_ioctl issue openrg ioctl
|
||||
meminfo Print memory information
|
||||
top Print Wireless Broadband Router's processes memory usage
|
||||
cpu_load_on Periodically shows cpu usage.
|
||||
cpu_load_off Stop showing cpu usage (triggered by cpu_load_on).
|
||||
cpu_load_avg Shows average cpu usage of last 1, 5 and 15 minutes.
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category system - Commands to control Wireless Broadband Router execution
|
||||
http_intercept_status Display HTTP intercept status
|
||||
diag_test run diagtest 0=all or select 1-9 for TBHR
|
||||
..TLANIPSTB
|
||||
diag_correction run corrections -- may reboot or reset BHR
|
||||
die Exit from Wireless Broadband Router and return ret
|
||||
ps Print Wireless Broadband Router's tasks
|
||||
entity_close Close an entity
|
||||
etask_list_dump Dump back trace of all etasks
|
||||
restore_factory_settings Restore factory configuration
|
||||
reboot Reboot the system
|
||||
ver Display version information
|
||||
print_config Print compilation configuration. Search for option
|
||||
if specified
|
||||
exec Execute program
|
||||
cat Print file contents to console
|
||||
shell Spawn busybox shell in foreground
|
||||
date Print the current UTC and local time
|
||||
print_page Print page id and name
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category flash - Flash and loader related commands
|
||||
commit Save Wireless Broadband Router configuration to flash
|
||||
erase Erase a given section in the flash
|
||||
load Load and burn image
|
||||
boot Boot the system
|
||||
bset Configure bootloader
|
||||
layout Print the flash layout and content
|
||||
dump Dump the flash content
|
||||
lock Lock mtd region
|
||||
unlock Unlock mtd region
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category net - Network related commands
|
||||
dns_route Dyncamic Routing according to DNS replies
|
||||
igmp IGMP Proxy related commands
|
||||
host Resolve host by name
|
||||
protected_setup Network related commands
|
||||
wsc wps related commands
|
||||
ifconfig Configure network interface
|
||||
ping Test network connectivity
|
||||
rg_ifconfig List Wireless Broadband Router Network Devices
|
||||
route Print route table
|
||||
main_wan Print the name of the current main wan device
|
||||
intercept_state Print interception state
|
||||
exit Exit sub menu
|
||||
help Show help for commands within this menu
|
||||
|
||||
Command Category cmd - Commands related to the Command module
|
||||
exit Exit from the current CLI session
|
||||
help Show help for commands within this menu
|
||||
Reference in New Issue
Block a user