Ejemplo n.º 1
0
    def test_execute(mock_loop_root):
        """
            Unit: Script: Test execute()
        """
        execute()

        mock_loop_root.assert_called_once_with()
Ejemplo n.º 2
0
def do_sdk_script(channel, decompile_dir, package_name, sdk_dir):
    script = os.path.join(sdk_dir, 'script.pyc')
    if not os.path.exists(script):
        return 0
    try:
        sys.path.append(sdk_dir)
        import script
        script.execute(channel, decompile_dir, package_name)
        del sys.modules['script']
        sys.path.remove(sdk_dir)
        return 0
    except Exception as e:
        LogUtils.error('%s execute failed:%s', script, e.__str__())
        return 1
Ejemplo n.º 3
0
def do_script(task, android, py_file, tempDir, ext_infos):
    """
    :param task:任务实体
    :param android:android实体
    :param py_file:脚本python文件
    :param tempDir:脚本路径
    :param ext_infos:额外扩展参数
    :return: ret
    """
    if not os.path.exists(py_file):
        return

    if not py_file.endswith(".py"):
        return

    sys.path.append(tempDir)
    try:
        import script
        ret = script.execute(task, android, ext_infos)
        del sys.modules["script"]
        sys.path.remove(tempDir)
        return ret
    except ImportError as ie:
        sys.path.remove(tempDir)
        return
Ejemplo n.º 4
0
def doScript(channel, pluginInfo, decompileDir, packageName, sdkTempDir, scriptName):

    if scriptName != 'script.py':
        log_utils.error("the script file name must be script.py")
        return 1

    sdkScript = os.path.join(sdkTempDir, scriptName)

    if not os.path.exists(sdkScript):
        return 0

    sys.path.append(sdkTempDir)


    import script
    ret = script.execute(channel, pluginInfo, decompileDir, packageName)
    del sys.modules['script']
    sys.path.remove(sdkTempDir)

    return ret
Ejemplo n.º 5
0
 def do_send(self, line):
     param = line.split(" ")
     if len(param) != 2 or param[0] == "-help":
         print("usage: send <address> <amount>")
         return
     trans = Transaction(param[0], param[1])
     if trans.status == 'KO':
         print(colored("*" * 50 + "\n\n" + " " * 4 + "ERROR (Wrong bitcoin addres or amount)" + "\n\n" + "*" * 50, 'red'))
         return
     # trans.display()
     lock = trans.param['tx_in'][0]['Signature Script']
     seri = Serializer(trans, sign=True)
     str = seri.make()
     trans.signFirst = str
     # print(trans.param['tx_in'][0]['Script Length'])
     if not trans.real_sign():
         print("\033[0m\033[91m" + "*" * 50 + "\n\n" + " " * 14 + "ERROR (Wrong private key)" + "\n\n" + "*" * 50 + "\033[0m")
         return
     unlock = trans.param['tx_in'][0]['Signature Script']
     if not execute(unlock + lock , str):
         print(colored("*" * 50 + "\n\n" + " " * 20 + "Script ERROR" + "\n\n" + "*" * 50, 'red'))
         return
     seri_sign = Serializer(trans)
     # print(trans.param)
     # print('____________________')
     final = seri_sign.make()
     # obk = Deserializer(final)
     # obk.make()
     # print(obk.param)
     tmp = ""
     for i in range(1, len(final) + 1):
         tmp = tmp + final[i - 1]
         if i % 49 == 0:
             tmp = tmp + "\n"
     print(colored("*" * 50 + "\n\n" + " " * 14 + "Serialized transaction\n\n" + tmp + "\n\n" + "*" * 50, 'green'))
     self.broadcast = final