python学习--打包

pyinstaller -F -i xx.ico setup.py 打包指定exe图标打包

#! /usr/bin/python3
# -*- encoding:utf-8 -*-

import sys
import os
#import get_api_list
#import python
from PyQt5.QtWidgets import (QWidget,QApplication,QPushButton,QLabel,QLineEdit,QHBoxLayout,QVBoxLayout, QGridLayout, QTextEdit)
#import PyQt5.Qt
#from PyQt5.QtGui import QIcon

CODE_DIR = os.getcwd()
#func = sys.argv[1]
#print(CODE_DIR)

class Fuzzerbox(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()
        self.funcName = ''

    def initUI(self):
        self.btn = QPushButton("start", self)
        self.btn.resize(self.btn.sizeHint())
        self.funcEdit = QLineEdit()
        self.funcEdit.resize(100,10)
        resultLabel = QLabel('result')
        result = QLabel('none')
        logEdit = QTextEdit()

        #layout
        #button + funcName
        hbox = QHBoxLayout()
        hbox.addWidget(self.btn)
        hbox.addWidget(self.funcEdit)
        hbox.addStretch(1)

        #result + pass/fail
        hbox1 = QHBoxLayout()
        hbox1.addWidget(resultLabel)
        hbox1.addWidget(result)
        
        #log
        hbox2 = QHBoxLayout()
        hbox2.addWidget(logEdit)

        vbox = QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addLayout(hbox1)
        vbox.addLayout(hbox2)
        self.setLayout(vbox)

        #single handle
        self.funcEdit.textChanged.connect(self.funcChanged)
        self.btn.clicked.connect(self.startTest)

        #window title  16:9
        self.setGeometry((QApplication.desktop().width() - self.width())/2, (QApplication.desktop().height() - self.height())/2, 960, 540)
        self.move((QApplication.desktop().width() - self.width())/2, (QApplication.desktop().height() - self.height())/2)
        self.setWindowTitle('fuzzerTest')
        self.show()

    def funcChanged(self, funcName):
        #if (funcName)需要判断funcName合法性
        self.funcName = funcName

    def startTest(self):
        #需要判断self.funcName是否为null
        print(self.funcName)

        try:
            os.system('rm -rf crash*')
            os.system('rm -rf slow*')
            
            #模糊测试函数的生成
            python.get_common_file()
            python.dir_pro(CODE_DIR)
            for fileName in fileNames:
                if './lib' in name:
                    continue
                python.file_chk(name, sys.argv[1])

            #编译
            os.system('make clean')
            os.system('export PATH=/bin:$PATH')
            os.system('make ssp4_test_fuzzer VERSION=RELEASE _GCC_TYPE=SSPFUZZER')
            os.system('chmod 777 fuzzer_main')
            os.system('./fuzzer_main -max_len=4096 -max_total_time=3 2>&1 | tee ${sys.argv[1]}.log')
            exeResult = os.system("cat ${func}.log | grep 'Done'")
            
            if (0 == exeResult)
            {
                qlb.setText('pass')
            }
            else
            {
                logStr = os.popen("cat ${func}.log")
                qlb.setText('fail')
                qle.setText(str(logStr))
            }

        except Exception:
            return 0

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Fuzzerbox()
    sys.exit(app.exec_())
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值