Ejemplo n.º 1
0
 def analyser_picker(self, reviews):
     if self.ui.watsonRadioButton.isChecked():
         self.ui.listWidget.addItem("IBM Watson")
         # Анализ отзывов с помощью IBM Watson
         watson_analyser = watson.Watson(reviews)
         sentiment = watson_analyser.get_s_res()
         self.ui.listWidget.addItem(sentiment)
         watson_res = watson_analyser.get_res()
         self.add_chart(watson_res)
     elif self.ui.monkeyRadioButton.isChecked():
         self.ui.listWidget.addItem("MonkeyLearn")
         # Анализ отзывов с помощью MonkeyLearn
         review_list = [reviews]
         monkey_analyser = monkey.Monkey(review_list)
         monkey_res = monkey_analyser.get_res()
         self.ui.listWidget.addItem(monkey_res)
     else:
         self.ui.listWidget.addItem("MonkeyLearn")
         # Анализ отзывов с помощью MonkeyLearn и IBM Watson
         review_list = [reviews]
         monkey_analyser = monkey.Monkey(review_list)
         monkey_res = monkey_analyser.get_res()
         self.ui.listWidget.addItem(monkey_res)
         self.ui.listWidget.addItem("IBM Watson")
         watson_analyser = watson.Watson(reviews)
         sentiment = watson_analyser.get_s_res()
         self.ui.listWidget.addItem(sentiment)
         watson_res = watson_analyser.get_res()
         # Отрисовка графика для эмоций отзывов, определённых IBM Watson
         self.add_chart(watson_res)
    def __init__(self, L):
        # print(a)
        # cm = request.GET.get('name', '')
        self.mk = monkey.Monkey()
        self.cm = common.Common()
        self.cf = configparser.ConfigParser()
        self.L = L

        print(L)
Ejemplo n.º 3
0
    def create_players(self):
        """Create the players, consisting of monkeys and their bananas.

        Each player (monkey) gets a reusable banana to throw.
        Reuse the same banana so it remembers it's initial speed and angle.
        The players are implemented as canvas objects. Hence, if you clear
        the canvas the player images are destroyed, too.
        """
        # save the players in an array so we can easily switch references
        self.players = []
        canvas_width = int(self.canvas['width'])
        canvas_height = int(self.canvas['height'])
        # Create the players. The position will be updated in the
        # method add_players_to_game.
        for k in (0,1):
            player_x = 100 if k == 1 else canvas_width - 100
            player_y = canvas_height
            # Monkey constructor will create the monkey's banana
            player = monkey.Monkey(self.canvas, 'images/monkey.png', player_x, player_y)
            player.name = f"Gorilla {k+1}"
            # player 1 throws banana to the left, player 0 throws to right (the default)
            if k == 1: player.set_x_axis(tk.LEFT)
            self.players.append(player)
Ejemplo n.º 4
0
    def __init__(self):
        self.cm = common.Common()
        self.cf = ConfigParser.ConfigParser()
        self.cf.read('monkey.conf')
        self.ad = adb.Adb()
        self.mk = monkey.Monkey()
        self.workPath = ""

        master = Tk()
        master.title('Android_Tools  Design By Sven')

        Label(master, text='设备号').grid(row=0)
        Label(master, text='测试包名:-p com.weizq').grid(row=1)
        Label(master, text='日志地址').grid(row=2)
        Label(master, text='日志等级:-v').grid(row=3)
        Label(master, text='事件数量').grid(row=4)
        Label(master, text='延时').grid(row=5)
        Label(master, text='触摸事件:--pct-touch').grid(row=6)
        Label(master, text='手势事件:--pct-motion').grid(row=7)
        Label(master, text='缩放事件:--pct-pinchzoom').grid(row=8)
        Label(master, text='轨迹球事件:--pct-trackball').grid(row=9)
        Label(master, text='屏幕事件:--pct-rotation').grid(row=10)
        Label(master, text='导航事件:--pct-nav').grid(row=11)
        Label(master, text='主要事件:--pct-majornav').grid(row=12)
        Label(master, text='系统事件:--pct-syskeys').grid(row=13)
        Label(master, text='切屏事件:--pct-appswitch').grid(row=14)
        Label(master, text='键盘事件:--pct-flip').grid(row=15)
        Label(master, text='其他事件:--pct-anyevent').grid(row=16)
        Label(master, text="monkey进程").grid(row=17)
        Label(master, text="Android其他监控命令").grid(column=3, row=0, columnspan=3)
        Label(master, text="内存监控").grid(column=3, row=1)
        Label(master, text="cpu监控").grid(column=3, row=3)

        global log_path
        global ENTRYLIST
        global status

        device_name = Entry(master, fg='Red')
        package_name = Entry(master)
        log_path = Entry(master)
        log_level = Entry(master)
        count = Entry(master)
        delay = Entry(master)
        touch = Entry(master)
        motion = Entry(master)
        pinch = Entry(master)
        trackball = Entry(master)
        screen = Entry(master)
        nav = Entry(master)
        major = Entry(master)
        system = Entry(master)
        app = Entry(master)
        keyboard = Entry(master)
        anyevents = Entry(master)
        monkey_pid = Entry(master)
        status = Entry(master, width=50, fg='RED')
        mem_monitor = Entry(master)
        mem_monitor.insert(0, "请输入包名")
        self.memstatus = Entry(master)
        self.memstatus.insert(0, "尚未开始获取内存数据")
        cpu_monitor = Entry(master)
        cpu_monitor.insert(0, "请输入包名")
        self.cpustatus = Entry(master)
        self.cpustatus.insert(0, "尚未开始获取cpu数据")

        device_name.grid(row=0, column=1)
        package_name.grid(row=1, column=1)
        log_path.grid(row=2, column=1)
        log_level.grid(row=3, column=1)
        count.grid(row=4, column=1)
        delay.grid(row=5, column=1)
        touch.grid(row=6, column=1)
        motion.grid(row=7, column=1)
        pinch.grid(row=8, column=1)
        trackball.grid(row=9, column=1)
        screen.grid(row=10, column=1)
        nav.grid(row=11, column=1)
        major.grid(row=12, column=1)
        system.grid(row=13, column=1)
        app.grid(row=14, column=1)
        keyboard.grid(row=15, column=1)
        anyevents.grid(row=16, column=1)
        monkey_pid.grid(row=17, column=1)
        status.grid(row=18, column=0, columnspan=3)
        mem_monitor.grid(row=1, column=4)
        self.memstatus.grid(row=2, column=4)
        cpu_monitor.grid(row=3, column=4)
        self.cpustatus.grid(row=4, column=4)

        connect_text = Button(master,
                              text='获取设备号',
                              command=lambda: self.cm.set_text(
                                  device_name, self.ad.get_devices()))
        up_pknm_conf = Button(
            master,
            text='修改包名',
            command=lambda: self.cm.update_conf(
                status, 'package_name', self.cm.get_text(package_name)))
        up_log_path_conf = Button(
            master,
            text='修改日志地址',
            command=lambda: self.cm.update_conf(status, 'log_path',
                                                self.cm.get_text(log_path)))
        up_log_level_conf = Button(
            master,
            text='修改日志等级',
            command=lambda: self.cm.update_conf(status, 'log_level',
                                                self.cm.get_text(log_level)))
        up_count_conf = Button(master,
                               text='修改测试数量',
                               command=lambda: self.cm.update_conf(
                                   status, 'count', self.cm.get_text(count)))
        up_delay_conf = Button(master,
                               text='修改延时',
                               command=lambda: self.cm.update_conf(
                                   status, 'delay', self.cm.get_text(delay)))
        up_touch_conf = Button(master,
                               text='修改触摸事件',
                               command=lambda: self.cm.update_conf(
                                   status, 'touch', self.cm.get_text(touch)))
        up_motion_conf = Button(
            master,
            text='修改手势事件',
            command=lambda: self.cm.update_conf(status, 'motion',
                                                self.cm.get_text(motion)))
        up_pinch_conf = Button(master,
                               text='修改缩放事件',
                               command=lambda: self.cm.update_conf(
                                   status, 'pinch', self.cm.get_text(pinch)))
        up_trackball_conf = Button(
            master,
            text='修改轨迹球事件',
            command=lambda: self.cm.update_conf(status, 'trackball',
                                                self.cm.get_text(trackball)))
        up_screen_conf = Button(
            master,
            text='修改屏幕事件',
            command=lambda: self.cm.update_conf(status, 'screen',
                                                self.cm.get_text(screen)))
        up_nav_conf = Button(master,
                             text='修改导航事件',
                             command=lambda: self.cm.update_conf(
                                 status, 'nav', self.cm.get_text(nav)))
        up_major_conf = Button(master,
                               text='修改主要事件',
                               command=lambda: self.cm.update_conf(
                                   status, 'major', self.cm.get_text(major)))
        up_system_conf = Button(
            master,
            text='修改系统事件',
            command=lambda: self.cm.update_conf(status, 'system',
                                                self.cm.get_text(system)))
        up_app_conf = Button(master,
                             text='修改切屏事件',
                             command=lambda: self.cm.update_conf(
                                 status, 'app', self.cm.get_text(app)))
        up_keyboard_conf = Button(
            master,
            text='修改键盘事件',
            command=lambda: self.cm.update_conf(status, 'keyboard',
                                                self.cm.get_text(keyboard)))
        up_anyevents_conf = Button(
            master,
            text='修改其他事件',
            command=lambda: self.cm.update_conf(status, 'anyevents',
                                                self.cm.get_text(anyevents)))
        cat_monkey_pid = Button(master,
                                text='显示Monkey进程',
                                command=lambda: self.cm.set_text(
                                    monkey_pid, self.ad.get_monkey_id()))
        self.start_monkey = Button(master,
                                   text='开始Monkey',
                                   command=self.run_monkey)
        self.stop_monkey = Button(master,
                                  text='结束Monkey',
                                  state=DISABLED,
                                  command=self.stop_monkey)

        self.get_monkey = Button(master,
                                 text='获取Monkey',
                                 state=DISABLED,
                                 command=self.get_report)
        get_memm_info = Button(
            master,
            text='开始生成内存信息',
            command=lambda: self.get_meminfo(self.cm.get_text(mem_monitor)))
        stop_mem_info = Button(master,
                               text="停止生成内存信息",
                               command=self.stop_meminfo)

        get_cpu_info = Button(
            master,
            text="开始生成cpu信息",
            command=lambda: self.get_cpuinfo(self.cm.get_text(cpu_monitor)))
        stop_cpu_info = Button(master,
                               text='停止生成cpu信息',
                               command=self.stop_cpuinfo)

        connect_text.grid(row=0, column=2)
        up_pknm_conf.grid(row=1, column=2)
        up_log_path_conf.grid(row=2, column=2)
        up_log_level_conf.grid(row=3, column=2)
        up_count_conf.grid(row=4, column=2)
        up_delay_conf.grid(row=5, column=2)
        up_touch_conf.grid(row=6, column=2)
        up_motion_conf.grid(row=7, column=2)
        up_pinch_conf.grid(row=8, column=2)
        up_trackball_conf.grid(row=9, column=2)
        up_screen_conf.grid(row=10, column=2)
        up_nav_conf.grid(row=11, column=2)
        up_major_conf.grid(row=12, column=2)
        up_system_conf.grid(row=13, column=2)
        up_app_conf.grid(row=14, column=2)
        up_keyboard_conf.grid(row=15, column=2)
        up_anyevents_conf.grid(row=16, column=2)
        cat_monkey_pid.grid(row=17, column=2)
        self.start_monkey.grid(row=19, column=0)
        self.stop_monkey.grid(row=19, column=2)
        self.get_monkey.grid(row=19, column=1)
        get_memm_info.grid(row=1, column=5)
        stop_mem_info.grid(row=1, column=6)
        get_cpu_info.grid(row=3, column=5)
        stop_cpu_info.grid(row=3, column=6)

        self.cm.set_text(device_name, '点击右侧按钮查看设备号')
        self.cm.set_text(package_name,
                         self.cf.get('monkey_conf', 'package_name'))
        self.cm.set_text(log_path, self.cf.get('monkey_conf', 'log_path'))
        self.cm.set_text(log_level, self.cf.get('monkey_conf', 'log_level'))
        self.cm.set_text(count, self.cf.get('monkey_conf', 'count'))
        self.cm.set_text(delay, self.cf.get('monkey_conf', 'delay'))
        self.cm.set_text(touch, self.cf.get('monkey_conf', 'touch'))
        self.cm.set_text(motion, self.cf.get('monkey_conf', 'motion'))
        self.cm.set_text(pinch, self.cf.get('monkey_conf', 'pinch'))
        self.cm.set_text(trackball, self.cf.get('monkey_conf', 'trackball'))
        self.cm.set_text(screen, self.cf.get('monkey_conf', 'screen'))
        self.cm.set_text(nav, self.cf.get('monkey_conf', 'nav'))
        self.cm.set_text(major, self.cf.get('monkey_conf', 'major'))
        self.cm.set_text(system, self.cf.get('monkey_conf', 'system'))
        self.cm.set_text(app, self.cf.get('monkey_conf', 'app'))
        self.cm.set_text(keyboard, self.cf.get('monkey_conf', 'keyboard'))
        self.cm.set_text(anyevents, self.cf.get('monkey_conf', 'anyevents'))

        # <===========界面初始化结束==================>

        self.crashCount = 0
        self.anrCount = 0

        self.tasksCrashCount = 0
        self.tasksAnrCount = 0

        self.tasks = {}

        #self.ad.get_devices()

        # <===========常量数据==================>

        ENTRYLIST = [
            package_name, touch, motion, pinch, trackball, screen, nav, major,
            system, app, keyboard, anyevents, log_level, count
        ]

        # <===========常量数据==================>

        master.mainloop()
Ejemplo n.º 5
0
 def __init__(self):
     self.mk = monkey.Monkey()
     self.cm = common.Common()
     self.cf = ConfigParser.ConfigParser()
Ejemplo n.º 6
0
    epsilon_tuple = (epsilon_start, epsilon_end, n_epsilon)

    def epsilon(n):
        return (epsilon_start - epsilon_end)*\
            math.exp(-(n+1)/n_epsilon) + epsilon_end

    max_discount = 0.05
    CR_level = 2
    CR_block_index = 2

    # Create the map
    room_start = rg.rand_room(500, [0.03, 0, 0.05, 0.01])
    # Create brain to train
    monkey_brain = brain.BrainDecisionAI(gamma, 4, -1, -50)
    # Put brain in monkey in grid
    monkeys = [monkey.Monkey(monkey_brain)]
    monkeys[0].pos = (len(room_start[1]) // 2, len(room_start[2]) // 2)
    g = grid.Grid(monkeys, room_start)
    g_CR = grid.Grid(monkeys, room_start)

    # Make data paths for the monkeys
    paths = ['AIDATA\\AIData' + str(i) + 'CLEAN.txt' for i in range(50)][0:6]

    # rg.play_record('AIDATA\\AIData0CLEAN.txt')

    # train.clean_data(paths, [s.replace('.txt', 'CLEAN.txt') for s in paths])

    # # Load brain from permanent memory
    # monkey_brain.load_state_dict(torch.load('B6T1.brainsave'))

    # # Train the monkey
Ejemplo n.º 7
0
 def createMonkey(self):
     self.monkey = monkey.Monkey(2.3, 0.0)
     self.monkey.gravity = self.gravity