Ejemplo n.º 1
0
def zte3g_handler(data):
    action = data["action"]
    jsonhelper = utils.JsonHelper()
    if action == "turnon":
        rtcode = utils.execmd("./shell/ztedial.sh start")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "turnoff":
        rtcode = utils.execmd("./shell/ztedial.sh stop")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
Ejemplo n.º 2
0
def wifi_handler(data):
    action = data["action"]
    ifname = data["ifname"]
    jsonhelper = utils.JsonHelper()
    if action == "turnon":
        rtcode = utils.execmd("./shell/makeap.sh start " + ifname)
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "turnoff":
        rtcode = utils.execmd("./shell/makeap.sh stop " + ifname)
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
Ejemplo n.º 3
0
def zte3g_handler(action):
    jsonhelper = utils.JsonHelper()
    if action == "turnon":
        rtcode = utils.execmd("./shell/ztedial.sh start")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "turnoff":
        rtcode = utils.execmd("./shell/ztedial.sh stop")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "check":
        rtcode, output = utils.execmdcommunicate("./shell/ztedial.sh check")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
Ejemplo n.º 4
0
def ssh_pubkey_handler(data):
    action = data["action"]
    jsonhelper = utils.JsonHelper()
    if action == "get":
        rtcode1, output1 = utils.execmdcommunicate("cat /root/.ssh/id_rsa.pub")
        jsonhelper.addkeyvalue("pubkey", output1)
        rtcode2, output2 = utils.execmdcommunicate("cat /root/.ssh/authorized_keys")
        jsonhelper.addkeyvalue("authorized_keys", output2)
        jsonhelper.setreturncode("0", "success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "remake":
        utils.execmd("rm -rf /root/.ssh/id_rsa*")
        utils.execmd("ssh-keygen  -t rsa -f /root/.ssh/id_rsa  -N ''")
        rtcode, output = utils.execmdcommunicate("cat /root/.ssh/id_rsa.pub")
        jsonhelper.setreturncode(rtcode, output)
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "set_authorized_keys":
        authorized_keys = data["authorized_keys"]
        rtcode, output = utils.execmdcommunicate("echo '" + authorized_keys + "' > /root/.ssh/authorized_keys")
        jsonhelper.setreturncode(rtcode, output)
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
Ejemplo n.º 5
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import json
import utils
import sys
import os
import subprocess
import commands

jsonhelper = utils.JsonHelper()
rtcode, output = utils.execmd("ls -al")
jsonhelper.setreturncode(rtcode, output)
print(jsonhelper.getjsonstring())