Add a parameter for setting logmode in chamtool

(cherry picked from commit 4fb21fa)
This commit is contained in:
chenzitai
2018-08-15 23:14:53 +01:00
parent 1d2847cdec
commit 336a32d1e7
+14 -1
View File
@@ -68,6 +68,17 @@ def cmdLog(chameleon, arg):
bytesReceived = chameleon.cmdDownloadLog(fileHandle)
return "{} Bytes successfully written to {}".format(bytesReceived, arg)
def cmdLogMode(chameleon, arg):
result = chameleon.cmdLogMode(arg)
if (arg is None):
return "Current logmode is: {}".format(result['response'])
else:
if (result['statusCode'] in chameleon.STATUS_CODES_SUCCESS):
return "logmode have been set to {}".format(arg)
else:
return "Setting logmode failed: {}".format(arg, result['statusText'])
def cmdLButton(chameleon, arg):
result = chameleon.cmdLButton(arg)
@@ -129,7 +140,7 @@ def cmdThreshold(chameleon, arg):
if (result['statusCode'] in chameleon.STATUS_CODES_SUCCESS):
return "Threshold have been set to {}".format(arg)
else:
return "Setting threshold faled: {}".format(arg, result['statusText'])
return "Setting threshold failed: {}".format(arg, result['statusText'])
def cmdUpgrade(chameleon, arg):
result = chameleon.cmdUpgrade()
@@ -164,6 +175,7 @@ def main():
cmdArgGroup.add_argument("-s", "--setting", dest="setting", action=CmdListAction, nargs='?', type=int, choices=Chameleon.VALID_SETTINGS, help="retrieve or set the current setting")
cmdArgGroup.add_argument("-U", "--uid", dest="uid", action=CmdListAction, nargs='?', help="retrieve or set the current UID")
cmdArgGroup.add_argument("-c", "--config", dest="config", action=CmdListAction, metavar="CFGNAME", nargs='?', help="retrieve or set the current configuration")
cmdArgGroup.add_argument("-lm", "--logmode", dest="logmode", action=CmdListAction, metavar="LOGMODE", nargs='?', help="retrieve or set the current log mode")
cmdArgGroup.add_argument("-lb", "--lbutton", dest="lbutton", action=CmdListAction, metavar="ACTION", nargs='?', help="retrieve or set the current left button action")
cmdArgGroup.add_argument("-rb", "--rbutton", dest="rbutton", action=CmdListAction, metavar="ACTION", nargs='?', help="retrieve or set the current right button action")
cmdArgGroup.add_argument("-gl", "--gled", dest="gled", action=CmdListAction, metavar="FUNCTION", nargs='?', help="retrieve or set the current green led function")
@@ -192,6 +204,7 @@ def main():
"upload" : cmdUpload,
"download" : cmdDownload,
"log" : cmdLog,
"logmode" : cmdLogMode,
"lbutton" : cmdLButton,
"rbutton" : cmdRButton,
"gled" : cmdGreenLED,