Exemplo n.º 1
0
 def close_ar8020(self):
     self.Info(u"关闭AR8020")
     Utility.execute_command(
         Command.adb.shell_command(
             cmd=
             'echo 0 > /sys/bus/platform/drivers/artosyn_ar8020/soc:ar8020/enable',
             serial=self.device))
Exemplo n.º 2
0
def git_clone():
    os.chdir(PATH_SOURCE_CODE)
    command_exit_code = Utility.execute_command(
        cmd="git clone ssh://[email protected]:29418/9201")
    if command_exit_code != 0:
        raise IOError
    os.chdir(os.path.join(PATH_SOURCE_CODE, '9201'))
    command_exit_code = Utility.execute_command(
        cmd="git checkout -b encrypt origin/encrypt")
    if command_exit_code != 0:
        raise IOError
    return os.path.join(PATH_SOURCE_CODE, '9201')
Exemplo n.º 3
0
 def open_ar8020(self):
     self.Info(u"打开AR8020")
     Utility.execute_command(
         Command.adb.shell_command(
             cmd=
             'echo 1 > /sys/bus/platform/drivers/artosyn_ar8020/soc:ar8020/enable',
             serial=self.device))
     self.sleep(5)
     for x in range(20):
         exec_rslt = Utility.execute_command(
             command=Command.adb.shell_command(
                 'ls /dev/ |grep artosyn_port', serial=self.device))
         self.Debug(u"第%s次结果:%s" % (x, exec_rslt.outputs))
         if exec_rslt.exit_code == 0 and len(exec_rslt.outputs) == 4:
             return True
         self.sleep(0.5)
     self.Error(u"AR8020没有打开")
     raise AssertionError(u"AR8020没有打开")
Exemplo n.º 4
0
 def Test(self):
     self.sleep(1)
     result = Utility.execute_command(self.command, encoding='gb2312')
     line = result.outputs[2]
     if "TTL=" in line:
         self.Debug("%-14s>> %s" % (self.ip, line))
         return self.ResultPass
     else:
         self.Error("%-14s>> %s" % (self.ip, line))
         return self.ResultFail
Exemplo n.º 5
0
 def write_serial_number(self):
     self.open_ar8020()
     for x in range(20):
         write_rslt = Utility.execute_command(
             Command.adb.shell_command(
                 cmd="/data/local/tmp/AR8020_SDK WriteSN %s" %
                 self.ar8020_serial_number,
                 serial=self.device))
         print(repr(write_rslt.outputs))
         read_rslt = Utility.execute_command(
             Command.adb.shell_command(
                 cmd="/data/local/tmp/AR8020_SDK ReadSN",
                 serial=self.device))
         if read_rslt.exit_code == 0 and read_rslt.outputs[
                 0] == self.ar8020_serial_number:
             self.Info(u"写入AR8020的SN号成功")
             self.close_ar8020()
             return True
     raise AssertionError(u"没有正常获取到AR8020的SN号")
Exemplo n.º 6
0
def build():
    find_resource_files(os.path.join(root_path, 'resource'))
    data_part = get_add_data_part(resources=resource_files)
    command = "pyinstaller -w -y --icon=favicon.ico --workpath {tmp} --distpath {out} {data} {script}".format(
        tmp=os.path.join(abs_path, 'tmp'),
        out=os.path.join(abs_path, 'out'),
        data=data_part,
        script=os.path.join(root_path, name))
    result = Utility.execute_command(command)
    if result.exit_code == 0:
        return True
    return False
Exemplo n.º 7
0
 def read_serial_number(self):
     self.open_ar8020()
     for x in range(20):
         exec_rslt = Utility.execute_command(
             Command.adb.shell_command(
                 cmd="/data/local/tmp/AR8020_SDK ReadSN",
                 serial=self.device))
         if exec_rslt.exit_code == 0 and exec_rslt.outputs[0]:
             self.ar8020_serial_number = exec_rslt.outputs[0]
             self.Info(u"获取到AR8020的SN号:%s" % self.ar8020_serial_number)
             self.close_ar8020()
             return True
     self.Error(u"没有正常获取到AR8020的SN号")
     raise AssertionError(u"没有正常获取到AR8020的SN号")
Exemplo n.º 8
0
def run(*args, **kwargs):
    JobFunc.SendJobStartMail()
    Utility.print_info(__file__, args, kwargs)
    workspace_path = Utility.get_compiler_path()
    Utility.create_folder(workspace_path)
    free, used, total = Utility.get_disk_usage(workspace_path)
    print "free:%s" % free
    print "used:%s" % used
    print "total:%s" % total
    if free < 200:
        JobFunc.RaiseException(MemoryError, "Insufficient disk space.")

    os.chdir(workspace_path)
    repo_init_command = Utility.Repo.init(
        url='ssh://[email protected]:29418/manifest',
        branch='C2_8.1_master')
    repo_init_exit_code = Utility.execute_command(repo_init_command)
    if repo_init_exit_code != 0:
        JobFunc.RaiseException(IOError, "Repo init error")

    repo_sync_command = Utility.Repo.sync()
    repo_sync_exit_code = Utility.execute_command(repo_sync_command)
    if repo_sync_exit_code != 0:
        JobFunc.RaiseException(IOError, "Repo sync error")
Exemplo n.º 9
0
 def __upgrade(self, image):
     self.open_ar8020()
     self.Info(u"开始升级 \"%s\"" % image)
     exec_rslt = Utility.execute_command(
         Command.adb.shell_command(cmd="/data/local/tmp/AR8020_UPGRADE %s" %
                                   image,
                                   serial=self.device))
     print repr(exec_rslt.outputs[-2])
     if exec_rslt.exit_code == 0 and "upgrade successed" in exec_rslt.outputs[
             -2]:
         self.Info(u"升级 \"%s\" 成功" % image)
         self.close_ar8020()
         return True
     self.Error(u"升级 \"%s\" 失败" % image)
     for output in exec_rslt.outputs:
         self.Error(output)
     raise AssertionError(u"升级 \"%s\" 失败" % image)
Exemplo n.º 10
0
def build_user():
    workspace_path = Utility.get_compiler_path()
    os.chdir(workspace_path)
    envsetup_command = "source build/envsetup.sh"
    link_command = "source build/link.sh"
    lunch_command = "lunch g2-user general"
    ulimit_command = "ulimit -c unlimited"
    update_command = "make update-api -j8"
    make_command = "make -j8"

    commands = [
        envsetup_command, link_command, lunch_command, ulimit_command,
        update_command, make_command
    ]
    command = " && ".join(commands)
    command_exit_code = Utility.execute_command(cmd=command)
    if command_exit_code != 0:
        JobFunc.RaiseException(IOError, "Build Error")
Exemplo n.º 11
0
def build_userdebug():
    workspace_path = Path.COMPILER_PATH
    os.chdir(workspace_path)
    envsetup_command = "source build/envsetup.sh"
    link_command = "source build/link.sh"
    lunch_command = "lunch g2-userdebug general"
    ulimit_command = "ulimit -c unlimited"
    update_command = "make update-api -j8"
    make_command = "make -j8"
    make_ota_command = "make otapackage -j8"

    commands = [
        envsetup_command,
        link_command,
        lunch_command,
        ulimit_command,
        update_command,
        make_command,
        # make_ota_command
    ]
    command = " && ".join(commands)
    command_exit_code = Utility.execute_command(cmd=command)
    if command_exit_code != 0:
        JobFunc.RaiseException(IOError, "Build Error")
Exemplo n.º 12
0
    def push_files(self):
        for image in [self.BOOT, self.BOOTLOADER, self.APP]:
            Utility.execute_command(
                Command.adb.push(local=image,
                                 remote="/data/local/tmp/%s" %
                                 os.path.basename(image),
                                 serial=self.device))

        for binary in [self.AR8020_SDK, self.AR8020_UPGRADE]:
            Utility.execute_command(
                Command.adb.push(local=binary,
                                 remote="/data/local/tmp/%s" %
                                 os.path.basename(binary),
                                 serial=self.device))
            Utility.execute_command(
                Command.adb.shell_command(cmd="chmod +x /data/local/tmp/%s" %
                                          os.path.basename(binary),
                                          serial=self.device))
        self.Info(u"Push文件成功。")
Exemplo n.º 13
0
def sync_repo(path):
    os.chdir(path)
    repo_sync_command = Utility.Repo.sync()
    repo_sync_exit_code = Utility.execute_command(repo_sync_command)
    if repo_sync_exit_code != 0:
        JobFunc.RaiseException(IOError, "Repo sync error")
Exemplo n.º 14
0
def init_repo(path):
    os.chdir(path)
    repo_init_command = Utility.Repo.init(url='ssh://[email protected]:29418/manifest', branch='C2_8.1_master')
    repo_init_exit_code = Utility.execute_command(repo_init_command)
    if repo_init_exit_code != 0:
        JobFunc.RaiseException(IOError, "Repo init error")
Exemplo n.º 15
0
def execute_script(script):
    command_exit_code = Utility.execute_command(cmd="./%s" % script)
    if command_exit_code != 0:
        raise IOError
Exemplo n.º 16
0
def change_permission(path):
    command_exit_code = Utility.execute_command(cmd="chmod u+x %s" % path)
    if command_exit_code != 0:
        raise IOError
Exemplo n.º 17
0
 def root_devices(self):
     Utility.execute_command(Command.adb.root(serial=self.device))