+ def get_https_cmd(self):
+ version = self.get_version()
+ print "VERSION: %s" % version
+ if "AP96" in version:
+ cmd = "curl -s --insecure --user '%s:%s' https://%s/outlets.htm " + \
+ " | grep -E '^[^<]+' " + \
+ " | grep -v 'Protected Object' "
+ else:
+ # NOTE: no other case known right now...
+ cmd = "curl -s --insecure --user '%s:%s' https://%s/outlets.htm " + \
+ " | grep -E '^[^<]+' " + \
+ " | grep -v 'Protected Object' "
+
+ return cmd
+
+ def get_http_cmd(self):
+ version = self.get_version()
+ print "VERSION: %s" % version
+ if "AP7900" in version:
+ cmd = "curl -s --anyauth --user '%s:%s' http://%s/rPDUout.htm | grep -E '^[^<]+'"
+ elif "AP7920" in version:
+ cmd = "curl -s --anyauth --user '%s:%s' http://%s/ms3out.htm | grep -E '^[^<]+' "
+ else:
+ # default case...
+ print "USING DEFAULT"
+ cmd = "curl -s --anyauth --user '%s:%s' http://%s/ms3out.htm | grep -E '^[^<]+' "
+
+ return cmd
+
+ def get_version(self):
+ # NOTE: this command returns and formats all data.
+ #cmd = """curl -s --anyauth --user '%s:%s' http://%s/about.htm """ +
+ # """ | sed -e "s/<[^>]*>//g" -e "s/ //g" -e "/^$/d" """ +
+ # """ | awk '{line=$0 ; if ( ! /:/ && length(pline) > 0 ) \
+ # { print pline, line } else { pline=line} }' """ +
+ # """ | grep Model """
+
+ # NOTE: we may need to return software version, no model version to
+ # know which file to request on the server.
+
+ if self.type == Transport.HTTP:
+ cmd = """curl -s --anyauth --user '%s:%s' http://%s/about.htm """ + \
+ """ | sed -e "s/<[^>]*>//g" -e "s/ //g" -e "/^$/d" """ + \
+ """ | grep -E "AP[[:digit:]]+" """
+ #""" | grep -E "v[[:digit:]].*" """
+ elif self.type == Transport.HTTPS:
+ cmd = """curl -s --insecure --user '%s:%s' https://%s/about.htm """ + \
+ """ | sed -e "s/<[^>]*>//g" -e "s/ //g" -e "/^$/d" """ + \
+ """ | grep -E "AP[[:digit:]]+" """
+ #""" | grep -E "v[[:digit:]].*" """
+ else:
+ raise ExceptionNoTransport("Unsupported transport to get version")