示例#1
0
文件: mat.py 项目: timb-machine/mat
def _run():
    if settings.jsonprint:
        Report.print_report(settings.jsonprint)
    elif settings.type == 'ios':
        _run_ios()
    elif settings.type == 'android':
        _run_android()
示例#2
0
    def train_model(self, X_train, X_test, y_train, y_test):
        le = LabelEncoder()
        le.fit(y_train)
        y_train = le.transform(y_train)
        y_test = le.transform(y_test)
    
        if self.solver_value == 4 or self.solver_value == 7:
            parameters = "-s {} -c {} -B 1 -q".format(self.solver_value, self.c_value)
        else:
            parameters = "-s {} -n {} -c {} -B 1 -q".format(self.solver_value, self.jobs_number, self.c_value)
        param = parameter(parameters)
        prob = problem(y_train, X_train)
        model = train(prob, param)
        
        p_label, p_acc, p_val = predict(y_test, X_test, model)

        #Convert predicted value from float to int
        y_pred = [int(label) for label in p_label]
        y_test = le.inverse_transform(y_test)
        y_pred = le.inverse_transform(y_pred)

        self.report = Report(y_test, y_pred)
        
        save_model(f"{self.model_name}", model)
        return y_pred
示例#3
0
文件: mat.py 项目: timb-machine/mat
def _run_android():
    androidutils = AndroidUtils()
    if settings.runchecks:
        passed = androidutils.check_dependencies(['full'],
                                                 silent=False,
                                                 install=True)
        Log.w('Checks passed: {result}'.format(result=passed))
        androidutils.clean()
        return

    if not settings.apk and not settings.package:
        androidutils.clean()
        _die('Error: No APK or Package specified.')

    # fixes problems with APK files in same folder
    if settings.apk and '/' not in settings.apk:
        settings.apk = './{apk}'.format(apk=settings.apk)

    if settings.listapps:
        androidutils.list_apps()

    elif settings.compile:
        androidutils.check_dependencies(['static', 'signing'], silent=True)
        androidutils.compile(settings.compile)

    else:
        if settings.static:
            androidanalysis = AndroidAnalysis(androidutils,
                                              apk=settings.apk,
                                              package=settings.package)
            settings.results = androidanalysis.run_analysis('static')

        else:
            if not settings.device or not androidutils.online(settings.device):
                androidutils.clean()
                _die('Error: Device {device} not found online'.format(
                    device=settings.device))

            androidanalysis = AndroidAnalysis(androidutils,
                                              apk=settings.apk,
                                              package=settings.package)
            settings.results = androidanalysis.run_analysis()

        if settings.results:
            report = Report(output_path=settings.output,
                            alias=androidanalysis.PACKAGE,
                            assessment_type='Android')
            if not settings.SILENT:
                report.report_to_terminal(settings.results)
            report.report_to_json(settings.results)

    androidutils.clean()
示例#4
0
def main():
    """Refresh data"""
    r = Report()
    r.refresh()
示例#5
0
        elif options.model_name == "DenseNet":
            neuralNet: DenseNetModel = DenseNetModel(options=options,
                                                     n_classes=len(classes))
        elif options.model_name == "Inception":
            neuralNet: InceptionV4Model = InceptionV4Model(
                options=options, n_classes=len(classes))
        else:
            neuralNet: SmallVGGNet = SmallVGGNet(options=options,
                                                 n_classes=len(classes))

        neuralNet.build()
        history = neuralNet.fit(train_x, train_y, test_x, test_y)

        report = Report(neuralNet,
                        test_x,
                        test_y,
                        classes,
                        output_dir=options.output_dir)
        report.evaluation_report()
        report.chart(history)

        model_output_path = os.path.join(
            options.output_dir, '[{}]model.hdf5'.format(neuralNet.name))
        classes_output_path = os.path.join(
            options.output_dir, '[{}]classes.txt'.format(neuralNet.name))
        answers_output_path = os.path.join(
            options.output_dir, '[{}]options.json'.format(neuralNet.name))

        neuralNet.save(model_output_path)
        with open(classes_output_path, 'w') as fw:
            fw.write('\n'.join(classes))
示例#6
0
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import sys
sys.path.insert(1, "./libs")
from utils.report import Report

import argparse

parser = argparse.ArgumentParser(
    description='EAS RFC Configuration Comparator.')
parser.add_argument('--bases',
                    type=str,
                    default='bases_',
                    help='Regexp of BASE configurations to compare with')
parser.add_argument('--tests',
                    type=str,
                    default='tests_',
                    help='Regexp of TEST configurations to compare against')
parser.add_argument('--results',
                    type=str,
                    default='./results_latest',
                    help='Folder containing experimental results')

if __name__ == "__main__":
    args = parser.parse_args()
    Report(args.results, compare=[(args.bases, args.tests)])
示例#7
0
文件: mat.py 项目: timb-machine/mat
def _run_ios():
    if settings.modify:
        binary, find, replace = settings.modify
        if not _exists(binary):
            _die('Error: {file} not found'.format(file=binary))

        Log.w('Modifying: {bin}'.format(bin=binary))

        with open(binary, 'r') as f:
            content = f.read()

        if find.decode('hex') not in content:
            _die(
                'Error: String {find} not found in the file'.format(find=find))

        if content.find(find.decode('hex')) != content.rfind(
                find.decode('hex')):
            _die('Error: More than one instance of {find} was found.'.format(
                find=find))

        Log.w('Backing up file to {file}.bk'.format(file=binary))
        with open('{file}.bk'.format(file=binary), 'w') as f:
            f.write(content)

        Log.w('Replacing {file}'.format(file=binary))
        with open(binary, 'w') as f:
            f.write(content.replace(find.decode('hex'), replace.decode('hex')))

        return

    iosutils = IOSUtils()
    if not settings.static:
        iosutils.start_tcp_relay()

    if settings.install:
        iosutils.install(settings.install)

    elif settings.unproxy:
        if not iosutils.check_dependencies(['proxy'], True, True):
            _die('Error: Missing dependency - activator.')

        iosutils.set_proxy()

    elif settings.proxy:
        if not iosutils.check_dependencies(['proxy'], True, True):
            _die('Error: Missing dependency - activator.')

        iosutils.set_proxy(settings.proxy[0], int(settings.proxy[1]))

    elif settings.update:
        iosutils.update_apps_list()
        iosutils.list_apps()

    elif settings.runchecks:
        passed = iosutils.check_dependencies(['full', 'proxy'],
                                             silent=False,
                                             install=True)
        Log.w('Checks passed: {result}'.format(result=passed))

    elif settings.listapps:
        iosutils.list_apps()

    elif settings.app or settings.ipa:
        iosanalysis = IOSAnalysis(utils=iosutils,
                                  app=settings.app,
                                  ipa=settings.ipa)
        settings.results = iosanalysis.run_analysis(
            'static' if settings.static else 'full')

        if settings.results:
            report = Report(output_path=settings.output,
                            alias=iosanalysis.APP_INFO['CFBundleExecutable'],
                            assessment_type='iOS')
            if not settings.SILENT:
                report.report_to_terminal(settings.results)
            report.report_to_json(settings.results)

    else:
        _die('Error: No IPA or APP specified.')

    iosutils.clean()
示例#8
0
SEND_REPLY = 0

# Commands rendering
COMMANDS = ("/italia - Dati aggregati a livello nazionale\n"
            "/regione - Dati per regione\n"
            "/provincia - Dati per provincia\n"
            "/positivi\_regione - Attualmente positivi per ogni regione\n"
            "/nuovi\_regione - Casi per ogni regione\n"
            "/nuovi\_provincia - Casi per ogni provincia\n"
            "/feedback - invia un feedback o segnala un problema\n"
            "/help - Istruzioni di utilizzo\n"
            "/legenda - Legenda per capire i dati\n"
            "/credits - Informazioni su questo bot\n\n")

# the main report object
R = Report()


def send_typing_action(func):
    """Sends typing action while processing func command."""
    @wraps(func)
    def command_func(update, context, *args, **kwargs):
        context.bot.send_chat_action(chat_id=update.effective_message.chat_id,
                                     action=ChatAction.TYPING)
        return func(update, context, *args, **kwargs)

    return command_func


def get_keyboard(keyboard_name):
    """get an generate a keyboard using stored data"""
示例#9
0
文件: main.py 项目: ntghoney/newapi
    def after_test(self, result_set):
        self.end_time = time.time()
        for result in result_set:
            # 将执行结果写入数据库
            self.db_local.insert_data(RESULTTABLE, **result)
        time_consum = self.end_time - self.start_time  # 测试耗时
        case_count = self.db_local.query_all(
            "SELECT caseId FROM {}".format(RESULTTABLE))  # 执行用例
        fail_case = self.db_local.query_all("SELECT caseId "
                                            "FROM {} WHERE ispass='******'".format(
                                                RESULTTABLE, FAIL))  # 执行失败的用例
        block_case = self.db_local.query_all(
            "SELECT caseId FROM {} WHERE ispass='******'".format(
                RESULTTABLE, BLOCK))  # 执行阻塞的用例
        success_case = self.db_local.query_all(
            "SELECT caseId FROM {} WHERE ispass='******'".format(
                RESULTTABLE, PASS))  # 执行成功的用例

        if case_count is None:
            case_count = 0
        else:
            case_count = len(case_count)
        if fail_case is None:
            fail_case = 0
        else:
            fail_case = len(fail_case)
        if block_case is None:
            block_case = 0
        else:
            block_case = len(block_case)
        if success_case is None:
            success_case = 0
        else:
            success_case = len(success_case)
        result_info = "本次测试执行完毕,本次测试环境为:{}," \
                      "共耗时{}秒,共执行用例:{}条," \
                      "成功:{}条,失败:{}条,阻塞:{}条" \
            .format("fp01", float("%.2f" % time_consum),
                    case_count, success_case,
                    fail_case, block_case)
        log.info(result_info)
        # 生成excel报告
        report = Report()
        report.set_result_info(result_info)
        exc_path = report.get_report(result_set)

        # 生成html报告
        import datetime
        html_title = "%s接口自动化测试报告" % (
            datetime.datetime.now().strftime("%Y/%m/%d"))
        html_path = get_html_report(
            total=case_count,
            starttime=time.strftime(FORMORT, time.localtime(self.start_time)),
            endtime=time.strftime(FORMORT, time.localtime(self.end_time)),
            during=time_consum,
            passd=success_case,
            fail=fail_case,
            block=block_case,
            titles=html_title,
            details=result_set)
        self.db_local.close()
        self.db_server.close()

        # 测试完成发送邮件
        if fail_case == 0 and block_case == 0:
            send_email_for_all(msg=result_info,
                               part_path=[exc_path, html_path])