class PluginPath:
    _CURRENT_DIR = Path(__file__).parent
    _STORAGE = Path(lyrebird.get_plugin_storage())
    _PLIST = _STORAGE / 'plist'
    _DEFAULT_CONF = Path(_CURRENT_DIR, './config/conf.json')

    def get_config(self):
        """
        Path of conf.json
        
        :return:  conf.json
        """
        return self._STORAGE / 'conf.json'

    def get_plist(self, device_id):
        """
        Path of plist
        
        :param device_id: 
        :return: device_id.plist
        """
        if not self._PLIST.exists():
            self._PLIST.mkdir()
        return os.path.join(self._PLIST, '%s.plist' % device_id)

    def get_default_conf(self):
        """
        Path of plugin's default conf
        
        :return: conf.json
        """
        with codecs.open(self._DEFAULT_CONF, 'r', 'utf-8') as f:
            return json.loads(f.read())
Exemple #2
0
    def save_report(self):
        """
        保存测试报告API
        """
        report_data_path = os.path.join(os.path.dirname(__file__),
                                        'report_template/data/report-data.js')
        with codecs.open(report_data_path, 'w+', 'utf-8') as f:
            f.write('var reportCaseData=' + json.dumps(
                {'result': app_context.result_list}, ensure_ascii=False))
            f.write('\n')
            f.write('var baseData=' +
                    json.dumps(app_context.config, ensure_ascii=False))
            f.write('\n')
            f.write('var detailCollection=' +
                    json.dumps(app_context.content, ensure_ascii=False))
            f.write('\n')
        report_path = os.path.join(os.path.dirname(__file__),
                                   'report_template')
        target_path = os.path.abspath(
            os.path.join(lyrebird.get_plugin_storage(), 'report'))
        if os.path.exists(target_path):
            shutil.rmtree(target_path)
        shutil.copytree(report_path, target_path)

        return context.make_ok_response()
def get_custom_start_files():
    storage = get_plugin_storage()
    workspace = Path(storage) / 'launch_config'

    if not workspace.exists():
        workspace.mkdir(parents=True, exist_ok=True)

    workspace_files = _load_dir_file(workspace, '.json')
    return workspace_files
class PluginPath:
    _CURRENT_DIR = Path(__file__).parent
    _STORAGE = Path(lyrebird.get_plugin_storage())
    _PLIST = _STORAGE / 'plist'

    def get_plist(self, device_id):
        """
        Path of plist
        
        :param device_id: 
        :return: device_id.plist
        """
        if not self._PLIST.exists():
            self._PLIST.mkdir()
        return os.path.join(self._PLIST, '%s.plist' % device_id)
Exemple #5
0
import os
import time
import socket
import codecs
import lyrebird
from . import config
from lyrebird import context
from .device_service import DeviceService
from flask import request, jsonify, send_from_directory


device_service = DeviceService()
storage = lyrebird.get_plugin_storage()
tmp_dir = os.path.abspath(os.path.join(storage, 'tmp'))
anr_dir = os.path.abspath(os.path.join(storage, 'anr'))
screenshot_dir = os.path.abspath(os.path.join(storage, 'screenshot'))

if not os.path.exists(tmp_dir):
    os.makedirs(tmp_dir)


class MyUI(lyrebird.PluginView):

    def index(self):
        """
        插件首页        
        """
        return codecs.open(self.get_package_file_path('templates/index.html'), 'r', 'utf-8').read()

    def info(self):
        device_info = {'device': None, 'app': None}
Exemple #6
0
import uuid
import jinja2
import socket
import codecs
import requests
from pathlib import Path
from urllib.parse import urlparse
from flask import request, send_from_directory
from . import config
from . import template_loader
from .device_service import DeviceService
from lyrebird.mock.context import make_ok_response, make_fail_response
from lyrebird import application, get_plugin_storage, add_background_task, publish

device_service = DeviceService()
storage = get_plugin_storage()
tmp_dir = os.path.abspath(os.path.join(storage, 'tmp'))
anr_dir = os.path.abspath(os.path.join(storage, 'anr'))
screenshot_dir = os.path.abspath(os.path.join(storage, 'screenshot'))
launch_config_path = Path(storage) / 'launch_config'
apk_dir = Path(storage) / 'apk'

if not os.path.exists(tmp_dir):
    os.makedirs(tmp_dir)


def check_env():
    msg = device_service.check_env()
    if device_service.status == device_service.RUNNING:
        return make_ok_response()
    else:
import json
import codecs
import lyrebird
from hashlib import md5
from pathlib import Path
from packaging import version

logger = lyrebird.log.get_logger()

BUGIT_STORAGE = lyrebird.get_plugin_storage()
CACHE_ROOT = Path(BUGIT_STORAGE) / 'cache'
LAST_SELECT_TEMPLATE_FILENAME = 'selected_template'
BUGIT_SYSTEM_FILENAME = [LAST_SELECT_TEMPLATE_FILENAME]
DRAFT_INFO_FILE_SUFFIX = '.info'
DEFAULT_DRAFT_NAME = 'Default'
DRAFT_VERSION_V_1_7_0 = version.parse('1.7.0')
DRAFT_VERSION_V_1_8_0 = version.parse('1.8.0')


def get(template_key):
    return _read_cache_from_file(template_key)


def put(template_key, data):
    _save_cache_to_file(template_key, data)


def delete(template_key):
    _delete_cache_from_file(template_key)

Exemple #8
0
import codecs
import json
import os
import time

import lyrebird

from lyrebird_api_coverage.client.context import app_context

from lyrebird_api_coverage.client.merge_algorithm import mergeAlgorithm

CURRENT_DIR = os.path.dirname(__file__)

PLUGINS_CONF_DIR = lyrebird.get_plugin_storage()
PLUGINS_DATA_DIR = os.path.join(PLUGINS_CONF_DIR, 'data')
PLUGINS_DUMP_DIR = os.path.join(PLUGINS_CONF_DIR, 'dump')

if not os.path.exists(PLUGINS_DATA_DIR):
    os.makedirs(PLUGINS_DATA_DIR)

if not os.path.exists(PLUGINS_DUMP_DIR):
    os.makedirs(PLUGINS_DUMP_DIR)
"""
ResultHandler 测试结果处理器
保存测试结果、续测、清空测试结果

"""


class ResultHandler:
    def make_result_dir(self):
import codecs
import json
import os
import lyrebird
from lyrebird.mock import context
from lyrebird_api_coverage.client.context import app_context
from lyrebird_api_coverage.client.jsonscheme import check_filter_schema

CURRENT_DIR = os.path.dirname(__file__)
PLUGIN_DIR = lyrebird.get_plugin_storage()
FILTER_CONF = os.path.join(PLUGIN_DIR, 'filter_conf.json')


'''
过滤处理器
'''

class FilterHandler:
    def init_filter_conf(self):
        if not os.path.exists(FILTER_CONF):
            self.copy_conf_file(FILTER_CONF)

    def copy_conf_file(self, target_path):
        os.path.abspath(os.path.join(CURRENT_DIR, '..', './default_conf/filter_config.json'))
        f_from = codecs.open(os.path.abspath(os.path.join(CURRENT_DIR, '..', './default_conf/filter_config.json')), 'r',
                             'utf-8')
        f_to = codecs.open(target_path, 'w', 'utf-8')
        f_to.write(f_from.read())
        f_to.close()
        f_from.close()