• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3#
4# Copyright (c) 2023 Huawei Device Co., Ltd.
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17
18import time
19
20from pywinauto.application import Application
21
22
23def end_burn(dlg):
24    timeout = 300
25    while True:
26        if timeout < 0:
27            return
28        mode = dlg.window(control_type="Tab").window_text()
29        if mode == 'Found One MASKROM Device':
30            dlg.Button16.click()
31            print("image burnning finished")
32            return
33        else:
34            print("please wait for a while...")
35            time.sleep(5)
36            timeout -= 5
37
38
39def auto_burn():
40    app = Application(backend='uia').start('RKDevTool.exe')
41    dlg = app.top_window()
42
43    while True:
44        mode = dlg.window(control_type="Tab").window_text()
45        if mode == 'Found One LOADER Device':
46            print('start burning')
47            dlg.window(title="Run").click()
48            time.sleep(100)
49            end_burn(dlg)
50            return
51        else:
52            time.sleep(1)
53
54
55if __name__ == "__main__":
56    auto_burn()
57