Ejemplo n.º 1
0
def rss_view(code, select):
    db, res = adb.Adb(), ''
    try:
        db.execute("SELECT `url` FROM weather_table WHERE `code`=%(code)s;",
                   {"code": code})
        rs = db.fetchone()
        data = fd.parse(rs[0])
        if select == "list":
            location = data.entries[0].content[0].value.split('</location>')
            res = [{
                "city":
                loc.split('<city>')[1].split('</city>')[0],
                "data": [{
                    "time": d.split('<tmef>')[1].split('</tmef>')[0],
                    "text": d.split('<wf>')[1].split('</wf>')[0],
                    "min": d.split('<tmn>')[1].split('</tmn>')[0],
                    "max": d.split('<tmx>')[1].split('</tmx>')[0]
                } for d in loc.split('<data>')[1:]]
            } for loc in location[:-1]]
        elif select == "all":
            ents = data.entries[0]
            date = ents['title'].split('-')[-1]
            res = ents['wf']
        return True, res
    except Exception as e:
        return False, repr(e)
    finally:
        db.close()
Ejemplo n.º 2
0
def city_list():
    db = adb.Adb()
    try:
        db.execute("SELECT * FROM weather_table;")
        return db.fetchall_dict()
    except:
        return []
    finally:
        db.close()
Ejemplo n.º 3
0
    def __init__(self, *args, **kw):
        Fuse.__init__(self, *args, **kw)

        self.adb = adb.Adb('/home/napier/bin/adb')

        class wrapped_file_class(AdbFile):
            def __init__(self2, *a, **kw):
                AdbFile.__init__(self2, self.adb, *a, **kw)

        self.file_class = wrapped_file_class

        self.cache = {}
Ejemplo n.º 4
0
 def apply_config(self):
     # ADB
     adb_path = self._config.get("adb.path")
     self._adb = adb.Adb(adb_path)
     if adb_path is "":
         self.SetStatusText("Please set a path to the ADB.")
     else:
         self.SetStatusText("Configuration loaded.")
     # Custom buttons
     self.custom1_button.SetLabelText(self._config.get("custom1.label"))
     self.custom2_button.SetLabelText(self._config.get("custom2.label"))
     self.custom3_button.SetLabelText(self._config.get("custom3.label"))
     # Load table contents
     self.host_list.DeleteAllItems()
     for host in self._config.get("hosts"):
         self.host_list.AppendItem([host["host"], host["name"], ""])
Ejemplo n.º 5
0
def loginFn(data):
    INFO = {
        "id": data.get('id', ''),
        "pwd": sha512(data.get('pwd', '').encode('utf-8')).hexdigest()
    }
    db = adb.Adb()
    try:
        db.execute(
            "SELECT COUNT(*) FROM user WHERE `id`=%(id)s AND `pwd`=%(pwd)s",
            INFO)
        rs = db.fetchone()[0]
        return (True, INFO['id']) if rs else (False, "없는 계정입니다.")
    except:
        return False, "LOGIN E"
    finally:
        db.close()
Ejemplo n.º 6
0
def launch():

    for name, path in emulator_paths.items():
        if os.path.exists(path):
            logging.info(f'{name} is installed')

            base_name = os.path.basename(path)
            process_found = False
            if base_name in get_process_list():
                logging.info(f'{name} process is running')
                process_found = True
            else:
                logging.info(f'{name} process is not found. Trying to execute {name}')
                subprocess.Popen([path])
                time.sleep(20)

                for sec in range(10):
                    if base_name in get_process_list():
                        logging.info(f'{name} is successfully executed')
                        process_found = True
                        break
                    
                    time.sleep(1)
                    logging.info('Sleep 1 sec')

            if not process_found:
                logging.warning(f'Please run the {name} manually')
                continue
            
            logging.info('Executed Score! Match app')
            client = adb.Adb()
            client.start_app()
            time.sleep(20)

        else:
            logging.warning(f'{name} is not installed')
Ejemplo n.º 7
0
def signupFn(data):
    INFO = {
        "id": data.get('id', '').strip(),
        "name": data.get('name', '').strip(),
        "phone": ''.join(re.findall("\d+",
                                    data.get('phone', '').strip()))
    }
    pwd1 = data.get('pwd1', '').strip()
    pwd2 = data.get('pwd2', '').strip()
    if pwd1 != pwd2:
        return False, "비밀번호를 확인해주세요."
    elif not INFO['id']:
        return False, "ID를 입력해주세요."
    elif not INFO['name']:
        return False, "이름을 입력해주세요."
    elif not INFO['phone'] or len(INFO) > 11:
        return False, "이동전화번호를 입력해주세요."
    db = adb.Adb()
    try:
        db.execute("SELECT COUNT(*) FROM user WHERE `id`=%(id)s",
                   {"id": INFO['id']})
        cnt = db.fetchone()[0]
        if cnt:
            return False, "중복된 아이디입니다."
        INFO['pwd'] = sha512(pwd1.encode('utf-8')).hexdigest()
        sql = """
        INSERT INTO user (`id`, `pwd`, `name`, `phone`)
        VALUES (%(id)s, %(pwd)s, %(name)s, %(phone)s)
        """
        db.execute(sql, INFO)
        db.commit()
        return True, "가입되었습니다."
    except Exception as e:
        return False, "signUp E"
    finally:
        db.close()
Ejemplo n.º 8
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.º 9
0
# ecoding=utf-8
from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
import os
import adb
ad = adb.Adb()

# Create your views here.
from django.views.decorators.csrf import csrf_exempt


def index(request):
    return render(request, 'index.html')


@csrf_exempt
def setuptools(request):
    url = os.getcwd()
    os.system('python {}/run.py'.format(url))
    return HttpResponse('True')


@csrf_exempt
def getMemData(request, filename):
    user_rst = []
    total_rst = []
    url = '{}/device_info/meminfo/{}.txt'.format(os.getcwd(), filename)
    with open(url, 'r') as f:
        for x in f.readlines():
            user_rst.append(x.strip().split(',')[2].strip())
            total_rst.append(x.strip().split(',')[0].strip())