Error using python script
Closed this issue · 2 comments
SofroN commented
When use winotify from my python script, i ger error:
Исключение при вызове "LoadXml" с "1" аргументами: "Исключение из HRESULT: 0xC00CE504"
~\AppData\Local\Temp\tmp.ps1:19 знак:1
+ $SerializedXml.LoadXml($Template)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : Exception
Исключение при вызове "Show" с "1" аргументами: "Параметр задан неверно.
Параметр задан неверно.
"
~\AppData\Local\Temp\tmp.ps1:24 знак:1
+ $Notifier.Show($Toast);
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException
When launch from command line error doesn't appear
The error occurs due to an unfilled launch
parameter.
I fill launch
parameter and run my script from console, work fine.
Run this script no console winotify
work, but showing powershell window
versa-syahptr commented
Thanks for using winotify. I found a bug when launch
parameter is unfilled, gonna fix it in the next release.
For appearing powershell window, can you provide the code that create the problem?
SofroN commented
to reproduce the problem, you need to run the script not from the console.
I run script from .lnk
D:\QtYandexMusic\venv\Scripts\pythonw.exe d:\QtYandexMusic\QtYandexMusic.pyw
For fix
# Run with hidden console window
subprocess.run([
"powershell.exe",
"-ExecutionPolicy", "Bypass",
"-WindowStyle", "Hidden",
"-file", file.name
], stdout=PIPE, stderr=STDOUT, creationflags=CREATE_NO_WINDOW)
for reproduce
import asyncio
from winotify import Notification
async def notify():
toast = Notification('MyApp', 'My Title', 'Hello world. Привет мир')
toast.launch = ' '
toast.build().show()
if __name__ == '__main__':
asyncio.run(notify())