コード例 #1
0
ファイル: node.py プロジェクト: threadshare/pyeos
    def getAccountCodeHash(self, account):
        cmd = "%s %s get code %s" % (Utils.EosClientPath, self.endpointArgs,
                                     account)
        if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
        try:
            retStr = Utils.checkOutput(cmd.split())
            # Utils.Print ("get code> %s"% retStr)
            p = re.compile(r'code\shash: (\w+)\n', re.MULTILINE)
            m = p.search(retStr)
            if m is None:
                msg = "Failed to parse code hash."
                Utils.Print("ERROR: " + msg)
                return None

            return m.group(1)
        except subprocess.CalledProcessError as ex:
            msg = ex.output.decode("utf-8")
            Utils.Print("ERROR: Exception during code hash retrieval. %s" %
                        (msg))
            return None
コード例 #2
0
ファイル: node.py プロジェクト: threadshare/pyeos
    def runCmdReturnJson(cmd, trace=False):
        cmdArr = shlex.split(cmd)
        retStr = Utils.checkOutput(cmdArr)
        jStr = Node.filterJsonObject(retStr)
        if trace: Utils.Print("RAW > %s" % (retStr))
        if trace: Utils.Print("JSON> %s" % (jStr))
        if not jStr:
            msg = "Expected JSON response"
            Utils.Print("ERROR: " + msg)
            Utils.Print("RAW > %s" % retStr)
            raise TypeError(msg)

        try:
            jsonData = json.loads(jStr)
            return jsonData
        except json.decoder.JSONDecodeError as ex:
            Utils.Print(ex)
            Utils.Print("RAW > %s" % retStr)
            Utils.Print("JSON> %s" % jStr)
            raise
コード例 #3
0
ファイル: node.py プロジェクト: threadshare/pyeos
 def runCmdReturnStr(cmd, trace=False):
     cmdArr = shlex.split(cmd)
     retStr = Utils.checkOutput(cmdArr)
     if trace: Utils.Print("RAW > %s" % (retStr))
     return retStr