Beispiel #1
0
def copy_binary_to_deploy(src_folder, dst_folder):
    Utility.create_folder(dst_folder)
    for f in os.listdir(src_folder):
        src = os.path.join(src_folder, f)
        dst = os.path.join(dst_folder, f)
        print "Copy \"%s\" to \"%s\"" % (src, dst)
        shutil.copyfile(src=src, dst=dst)
Beispiel #2
0
def build_p0():
    version_type = "P0"
    if os.path.exists(JobFunc.get_deploy_path(_type=version_type)):
        change_version_number(version_type)
        make('mkimg_demo.sh')
        dst_folder = copy_image(_type="P0")
        Utility.zip_folder(dst_folder)
 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))
Beispiel #4
0
def check_space_available(path):
    Utility.create_folder(path)
    free, used, total = Utility.get_disk_usage(path)
    ConsolePrint.info("free:%s" % free)
    ConsolePrint.info("used:%s" % used)
    ConsolePrint.info("total:%s" % total)
    if free < 200:
        JobFunc.RaiseException(MemoryError, "Insufficient disk space.")
 def get_choices(self):
     _type = self._get_value(String.CaseType)
     if _type == String.Android:
         return Utility.get_adb_devices()
     elif _type == String.Serial:
         return Utility.get_serial_ports()
     else:
         raise KeyError
Beispiel #6
0
def copy_debug_info_to_deploy(src_folder, dst_folder):
    Utility.create_folder(dst_folder)
    src_folder = os.path.join(src_folder, 'obj', 'kernel', 'msm-4.4')
    for f in ['vmlinux', 'System.map']:
        src = os.path.join(src_folder, f)
        dst = os.path.join(dst_folder, f)
        print "Copy \"%s\" to \"%s\"" % (src, dst)
        shutil.copyfile(src=src, dst=dst)
Beispiel #7
0
def create_commit_history():
    compiler_path = Utility.get_compiler_path()
    deploy_path = Utility.get_deploy_path()
    os.chdir(compiler_path)
    since = Utility.get_timestamp(time_fmt="%Y-%m-%d %H:%M",
                                  t=Env.BUILD_TIME - 3600 * 24 * 3)
    output = os.popen(Utility.Repo.log(since=since)).read()
    with open(os.path.join(deploy_path, "CommitHistory.txt"), "w") as wfile:
        wfile.write(output)
Beispiel #8
0
def run(*args, **kwargs):
    try:
        Utility.job_started()
        version_type = args[2]
        JobFunc.remove_folder()
        src_path = JobFunc.git_clone()
        check_commit_history(path=src_path, _type=version_type)
    except Exception:
        Utility.Incoming.job_exception()
        raise Exception
Beispiel #9
0
 def update_ybound(self, event):
     try:
         y_max = int(self.max_tc.GetValue())
         y_min = int(self.min_tc.GetValue())
         if y_max < y_min:
             y_min, y_max = y_max, y_min
         self.set_ybound(lower=y_min, upper=y_max)
         Utility.AlertMsg(u"设置成功")
     except ValueError:
         Utility.AlertError(u"输入异常: \"%s\" or \"%s\"" % (self.min_tc.GetValue(), self.max_tc.GetValue()))
    def on_root(self, event):
        def root_device():
            os.system(Adb.root(serial=self.DeviceListBox.GetStringSelection()))
            os.system(
                Adb.shell_command(
                    cmd="setenforce 0",
                    serial=self.DeviceListBox.GetStringSelection()))
            self.update_8020_state()

        Utility.append_work(target=root_device, allow_dupl=False)
Beispiel #11
0
def run(*args, **kwargs):
    Utility.print_info(__file__, args, kwargs)
    version_type = Env.VERSION_TYPE
    remove_out_folder()
    if version_type == "userdebug":
        build_userdebug()
    elif version_type == "user":
        build_user()
    else:
        JobFunc.RaiseException(KeyError,
                               "Unknown version type:%s" % version_type)
    def on_upgrade(self, event):
        def upgrade():
            self.DeviceListBox.Disable()
            self.upgrade_button.Disable()
            bin_file = self.FilePicker.GetPath()
            log.debug("AR8020 File:%s" % bin_file)
            if bin_file and os.path.exists(bin_file):
                log.debug("AR8020 File:%s" % bin_file)
                os.system(
                    Adb.push(local=bin_file,
                             remote="/data/local/tmp/8020.bin",
                             serial=self.DeviceListBox.GetStringSelection()))
                self.open_8020_before_upgrade()
                self.update_8020_state()
                import subprocess
                p = subprocess.Popen(Adb.shell_command(
                    cmd="upgrade_ar8020 /data/local/tmp/8020.bin",
                    serial=self.DeviceListBox.GetStringSelection()),
                                     stdout=subprocess.PIPE,
                                     bufsize=1)
                while True:
                    data = p.stdout.readline()  # block/wait
                    log.debug(repr(data))
                    if "get file size" in data:
                        self.ST_Artosyn.SetLabel(u"Upgrading...")
                    elif "upgrade successed" in data:
                        self.ST_Artosyn.SetLabel(
                            u"Upgrade complete,Wait for reboot AR8020")
                        break
                    else:
                        cur, total = Utility.find_in_string(pattern=pattern,
                                                            string=data)
                        cur, total = float(cur), int(total)
                        self.upgarde_gauge.SetValue(cur / total * 1000)
                        print cur / total * 1000
                    time.sleep(0.01)
                os.system(
                    Adb.shell_command(
                        cmd=
                        "echo 0 > /sys/bus/platform/drivers/artosyn_ar8020/soc:ar8020/enable",
                        serial=self.DeviceListBox.GetStringSelection()))
                time.sleep(1)
                os.system(
                    Adb.shell_command(
                        cmd=
                        "echo 1 > /sys/bus/platform/drivers/artosyn_ar8020/soc:ar8020/enable",
                        serial=self.DeviceListBox.GetStringSelection()))
                self.update_8020_state()
            else:
                log.warn("Can not find Bin File ,Skip.")
            self.DeviceListBox.Enable()
            self.upgrade_button.Enable()

        Utility.append_work(target=upgrade, allow_dupl=False)
Beispiel #13
0
 def stop_exist_uart_log(self):
     self.stop_background_uart_log(self.serial)
     output = os.popen(
         Adb.shell_command(cmd="ps -A |grep uart_log",
                           serial=self.serial)).read()
     for line in output.split('\n'):
         if not line:
             continue
         pid = Utility.find_in_string(re.compile(r'\d+'), line)
         log.info("%s\t>\tpid:%s" % (line, pid))
         Utility.run_cmd(
             Adb.shell_command(cmd='kill -2 %s' % pid, serial=self.serial))
Beispiel #14
0
 def on_export(self, event):
     dlg = wx.FileDialog(self,
                         message="Save As Template",
                         wildcard="Issue Template (*.xml)|*.xml|All files (*.*)|*.*",
                         defaultDir=GlobalVariable.template_folder,
                         style=wx.SAVE
                         )
     if dlg.ShowModal() == wx.ID_OK:
         profile_path = dlg.GetPaths()[0]
         profile = self.__output_options_value()
         Utility.save_profile(profile_path=profile_path, profile=profile)
     dlg.Destroy()
Beispiel #15
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')
Beispiel #16
0
def run(*args, **kwargs):
    Utility.print_info(__file__, *args, **kwargs)
    version_type = Env.VERSION_TYPE
    if version_type == "userdebug":
        deploy_userdebug_version()
    elif version_type == "user":
        deploy_user_version()
    else:
        JobFunc.RaiseException(KeyError,
                               "Unknown version type:%s" % version_type)
    create_commit_history()
    JobFunc.SendJobFinishMail()
Beispiel #17
0
def copy_ota_to_deploy(src_folder, ota_folder, binary_folder):
    print binary_folder
    Utility.create_folder(ota_folder)
    zipfile_ota = os.path.join(src_folder, 'g2-ota-%s.zip' % BUILD_NUMBER)
    folder_intermediates = os.path.join(src_folder, 'obj', 'PACKAGING',
                                        'target_files_intermediates')
    zipfile_targetfile = os.path.join(folder_intermediates,
                                      'g2-target_files-%s.zip' % BUILD_NUMBER)
    # image_system = os.path.join(folder_intermediates, 'g2-target_files-%s' % BUILD_NUMBER, 'IMAGES', 'system.img')
    # image_vendor = os.path.join(folder_intermediates, 'g2-target_files-%s' % BUILD_NUMBER, 'IMAGES', 'vendor.img')
    # image_boot = os.path.join(folder_intermediates, 'g2-target_files-%s' % BUILD_NUMBER, 'IMAGES', 'boot.img')
    shutil.copyfile(src=zipfile_ota, dst=os.path.join(ota_folder, 'ota.zip'))
    shutil.copyfile(src=zipfile_targetfile,
                    dst=os.path.join(ota_folder, 'target_files.zip'))
Beispiel #18
0
 def copy_line(self, event):
     # 没有把列的TITLE罗列出来 需要优化
     rows = self.grid.GetSelectedRows()
     rows.sort()
     print rows
     string = ''
     for row in rows:
         row_string = ''
         for col in range(self.grid.GetNumberCols()):
             value = self.grid.GetCellValue(row, col)
             if '\r' in value or '\n' in value:
                 value = '\"%s\"' % value
             row_string += '%s\t' % value
         string = string + row_string.rstrip('\t') + '\n'
     Utility.send_to_clipboard(string.rstrip('\n'))
Beispiel #19
0
    def run(self):
        for issue_path in self.issue_list:
            file_name = issue_path.split(sep)[-1]
            self.refresh_info(
                'Current: %5d      Total: %5d' %
                (self.issue_list.index(issue_path) + 1, len(self.issue_list)))
            if self.thread_stop or not self.dialog:
                break
            issue_dict = Utility.parse_profile(issue_path)
            issue = yIssueFromXML.generate(issue_dict=issue_dict)
            state, response, error = JIRA.create(data=issue,
                                                 account='qrd_automation',
                                                 password='******')
            issue_dict['state'] = state
            issue_dict['response'] = response
            issue_dict['error'] = error

            if state == 0:
                response = eval(response)
                jira_id = response.get("key")
                issue_dict['jira_id'] = jira_id
                self.append_result('%-14s|%s' % (jira_id, file_name))
            else:
                self.append_result('%-14s|%s' % ('Submit Fail', file_name))
            self.updata_result(key=file_name, value=issue_dict)
        self.enable_done()
Beispiel #20
0
def deploy():
    shutil.move(
        os.path.join(abs_path, 'out', "Automation"),
        os.path.join(abs_path, "Automation_%s" % Utility.get_timestamp()))
    shutil.rmtree(os.path.join(abs_path, 'tmp'))
    shutil.rmtree(os.path.join(abs_path, 'out'))
    os.remove(os.path.join(abs_path, 'Automation.spec'))
Beispiel #21
0
    def __init__(self):
        wx.Dialog.__init__(self,
                           parent=None,
                           id=wx.ID_ANY,
                           title=u"初始化SW16设备",
                           pos=wx.DefaultPosition,
                           size=(300, 250),
                           style=wx.DEFAULT_DIALOG_STYLE)
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        self.wx_static_text = wx.StaticText(self, wx.ID_ANY, u"请选择SW16的虚拟端口:",
                                            wx.DefaultPosition, wx.DefaultSize,
                                            0)
        self.wx_list = wx.ListBox(parent=self,
                                  id=wx.ID_ANY,
                                  pos=wx.DefaultPosition,
                                  size=wx.DefaultSize,
                                  choices=Utility.get_serial_ports(),
                                  style=wx.LB_SINGLE)
        main_sizer.Add(self.wx_static_text, 0, wx.EXPAND | wx.ALL, 3)
        main_sizer.Add(self.wx_list, 1, wx.EXPAND | wx.ALL, 3)

        refresh = wx.Button(self, wx.ID_ANY, u"刷新", wx.DefaultPosition,
                            (-1, 30), 0)
        ok = wx.Button(self, wx.ID_OK, u"确定", size=(-1, 30))
        ok.Bind(wx.EVT_BUTTON, self.on_ok)
        cancel = wx.Button(self, wx.ID_CANCEL, u"取消", size=(-1, 30))
        button_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button_sizer.Add(ok, 1, wx.ALIGN_CENTER | wx.ALL, 3)
        button_sizer.Add(cancel, 1, wx.ALIGN_CENTER | wx.ALL, 3)
        refresh.Bind(wx.EVT_BUTTON, self.on_refresh)
        main_sizer.Add(refresh, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 3)
        main_sizer.Add(button_sizer, 0, wx.EXPAND | wx.ALL, 0)
        self.SetSizer(main_sizer)
        self.Center()
Beispiel #22
0
 def is_ar8020_open(serial):
     log.debug("check the AR 8020 state in device:%s" % serial)
     stdin, stdout, stderr = Utility.run_cmd(
         Adb.shell_command(
             cmd=
             "cat /sys/bus/platform/drivers/artosyn_ar8020/soc:ar8020/enable",
             serial=serial))
     return stdout.read()
Beispiel #23
0
 def on_stop(self, event):
     try:
         self.data.stop()
         self.ampe.stop()
         self.volt.stop()
         Utility.AlertMsg(u"已停止")
         self.EnableCtrl(enable=True)
     except AttributeError:
         pass
Beispiel #24
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")
Beispiel #25
0
def deploy_version(_type):
    output_path = get_userdebug_path(
    ) if _type == userdebug else get_user_path()
    if output_path:
        deploy_path = Path.DAILY_DEPLOY
        binary_folder = os.path.join(deploy_path, binary, _type)
        debug_info_folder = os.path.join(deploy_path, debuginfo, _type)
        ota_folder = os.path.join(deploy_path, ota, _type)
        copy_binary_to_deploy(src_folder=output_path, dst_folder=binary_folder)
        copy_debug_info_to_deploy(src_folder=get_out_path(),
                                  dst_folder=debug_info_folder)
        copy_ota_to_deploy(src_folder=get_out_path(),
                           ota_folder=ota_folder,
                           binary_folder=binary_folder)
        Utility.zip_folder(os.path.join(deploy_path, binary, _type))
        Utility.zip_folder(os.path.join(deploy_path, debuginfo, _type))
    else:
        raise IOError('No such file or directory: %s' % output_path)
Beispiel #26
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没有打开")
Beispiel #27
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号")
Beispiel #28
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
Beispiel #29
0
def check_commit_history(path):
    os.chdir(path)
    since = Utility.get_timestamp(time_fmt="%Y-%m-%d %H:%M", t=Env.BUILD_TIME - 3600 * 24 * 3)
    output = os.popen(Utility.Repo.log(since=since)).read()
    ConsolePrint.info(output)
    if output:
        version_number = create_deploy_folder(path=Path.DAILY_DEPLOY, commit_msg=output)
        modify_src_version_number(path=path, version=version_number)
    else:
        ConsolePrint.info("No commit submitted in the last day ")
        cleanup_repo(path=path)
Beispiel #30
0
 def __init_devices_sizer(self):
     sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"设备"), wx.VERTICAL)
     device_choices = Utility.get_devices()
     fastboot_choices = Utility.get_fastboots()
     d_tilte = wx.StaticText(self, wx.ID_ANY, u"Android Devices", wx.DefaultPosition, wx.DefaultSize,
                             wx.ALIGN_CENTER)
     f_title = wx.StaticText(self, wx.ID_ANY, u"Fastboot Devices", wx.DefaultPosition, wx.DefaultSize,
                             wx.ALIGN_CENTER)
     self.lb_devices = wx.ListBox(sizer.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
                                  device_choices, style=wx.LB_EXTENDED)
     self.lb_fastboot = wx.ListBox(sizer.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
                                   fastboot_choices, style=wx.LB_EXTENDED)
     button = wx.Button(sizer.GetStaticBox(), wx.ID_ANY, u"刷新", wx.DefaultPosition, wx.DefaultSize, 0)
     button.Bind(wx.EVT_BUTTON, self.on_refresh)
     sizer.Add(d_tilte, 0, wx.EXPAND | wx.ALL, 0)
     sizer.Add(self.lb_devices, 1, wx.EXPAND | wx.ALL, 0)
     sizer.Add(f_title, 0, wx.EXPAND | wx.TOP, 5)
     sizer.Add(self.lb_fastboot, 1, wx.EXPAND | wx.ALL, 0)
     sizer.Add(button, 0, wx.EXPAND | wx.ALL, 0)
     return sizer