Search code examples
python-2.7flashpyqt5argparseqwebengineview

Running script with fixed internal commands arguments to include Qwebengine pepflashplayer


I made a PyQt5 QWebengine app i wanna make portable. I found out that flash weren't working in the app. After a lot of reading i found out that having pepflashplayer64_*.dll & manifest.json in folder

C:\Windows\System32\Macromed\Flash\ is working.

However i wanna ship the pepflashplayer with app, and adding custom flash folder to PATH env var, do not have effect , or sys.path.insert()

the command

myapp.py --ppapi-flash-path=C:\Flash\pepflashplayer64_27_0_0_187.dll

works , but how to pass extra augments internally when script is launched ?

i tried dirty hack to run sys.arg[0] script with extra command but no success.

if __name__ == "__main__":
    # print sys.argv
    flash = (' --ppapi-flash-path=C:\Flash\pepflashplayer64_27_0_0_187.dll').split()
    # print flash
    noooo =  (sys.argv[0] + flash[0]).split()  
    import sys
    app = QtWidgets.QApplication(noooo)
    # ... the rest of your handling: `sys.exit(app.exec_())`, etc.

Solution

  • okay i got it to work so i can make app the app with browser portable , and solution was simpler than i thought. Parsing second internal argument like this.

    if __name__ == "__main__":
        programname = os.path.dirname(sys.argv[0]) #get current script full folder path
        pepperpflash = ' --ppapi-flash-path=' + programname + '/Flash/pepflashplayer64_27_0_0_187.dll' 
        try:
            app = QtWidgets.QApplication(sys.argv + [pepperpflash])
        except:
            app = QtWidgets.QApplication(sys.argv)
        # ... the rest of your handling: `sys.exit(app.exec_())`, etc.