Skip to content

Conversation

@taooceros
Copy link
Member

Related to Later discussion in #461

@taooceros
Copy link
Member Author

@AnthonMS I will be afk soon, so if you would like to test it earlier, you can check out the ci build artifact directly after it has done its job.

@taooceros taooceros self-assigned this Jun 7, 2021
@taooceros taooceros added this to the 1.8.0 milestone Jun 7, 2021
@taooceros taooceros added the bug Something isn't working label Jun 7, 2021
@jjw24 jjw24 merged commit c7358f0 into dev Jun 7, 2021
@jjw24 jjw24 deleted the FixPythonEscapeIssue branch June 7, 2021 09:56
@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

@jjw24 & @taooceros

I will continue the conversation here, I don't know which issue is the correct to use.
I get new errors now that I dont know how to decipher.

2021-06-07.txt

@taooceros
Copy link
Member Author

@jjw24 & @taooceros

I will continue the conversation here, I don't know which issue is the correct to use.
I get new errors now that I dont know how to decipher.

2021-06-07.txt

Just discuss here no problem. The log is weird, which should only happens if your python path is not set correctly in Flow. Would you please check the Python Path setting in Flow?

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

Just discuss here no problem. The log is weird, which should only happens if your python path is not set correctly in Flow. Would you please check the Python Path setting in Flow?

Oh that can make sense, I tested it on another pc. And I don't know if python path i correct on this pc. I will test again when I'm home on my personal computer again. I know the python path is correct on that. Sorry about that.

@taooceros
Copy link
Member Author

No problem. If python is installed, you can checkout the python path by typing where.exe python in cmd.

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

No problem. If python is installed, you can checkout the python path by typing where.exe python in cmd.

Oh I didn't know about that command on windows, thanks. I do have python installed and it does find it in my path.

Output:
C:\Users\ams\AppData\Local\Programs\Python\Python39\python.exe
C:\Users\ams\AppData\Local\Microsoft\WindowsApps\python.exe

@taooceros
Copy link
Member Author

No problem. If python is installed, you can checkout the python path by typing where.exe python in cmd.

Oh I didn't know about that command on windows, thanks. I do have python installed and it does find it in my path.

Output:
C:\Users\ams\AppData\Local\Programs\Python\Python39\python.exe
C:\Users\ams\AppData\Local\Microsoft\WindowsApps\python.exe

Try setting them in Flow's setting? Not include the exe like C:\Users\ams\AppData\Local\Programs\Python\Python39

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

Try setting them in Flow's setting? Not include the exe like C:\Users\ams\AppData\Local\Programs\Python\Python39

Is that the settings.json in the appdata/roaming/FlowLauncher/Settings folder? and is it this setting:
"PythonDirectory": "C:\\Users\\ams\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\"
Should that be like this then:
"PythonDirectory": "C:\Users\ams\AppData\Local\Programs\Python\Python39"

This is the only place I can find anything named python in the settings.json file

@taooceros
Copy link
Member Author

Yes, you are right, but I guess it would be more easy to directly set this with Flow's setting window hhh

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

Yes, you are right, but I guess it would be more easy to directly set this with Flow's setting window hhh

This is definitely a stupid question, but what do you mean? Haven't used Flow's setting window before.

@taooceros
Copy link
Member Author

image
image

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

Thank you! I appreciate all the help to a newcomer like me. Sorry I keep finding new bugs xD

But it actually looks like it works now. It at least created the test.txt file and wrote the line in it. I do get a single line error when executing the query.
2021-06-07 13:21:34.3595|ERROR|JsonRPCPlugin.Execute|Empty standard output and standard error.

I don't know if that's something I am doing wrong or just some output you have set to show for now.

@taooceros
Copy link
Member Author

Thank you as well! Finding and fixing bugs are what we always need to encounter when building a better program! Thank you so much for helping us discovering these bugs that exist in our python plugin system!

But it actually looks like it works now. It at least created the test.txt file and wrote the line in it. I do get a single line error when executing the query.
2021-06-07 13:21:34.3595|ERROR|JsonRPCPlugin.Execute|Empty standard output and standard error.

This is not quite a significant bug, and if you like, you can ignore it. If you would like to remove this warning, simply create another message back at the end of the callback method as what's been done in the query method. This is used for executing Flow's API after finishing up the callback method.

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

Thank you as well! Finding and fixing bugs are what we always need to encounter when building a better program! Thank you so much for helping us discovering these bugs that exist in our python plugin system!

I'm really just happy to help. I was so close to loosing interest, but you guys have been more than helpful with my issues. And have been nice to talk to. So I will help as much as I can. I will probably try to stitch some kind of documentation together for Python Plugin development when I have gotten it to work. But I have never made pull requests to larger projects before, so expect an issue/question about that in the near future :)

This is not quite a significant bug, and if you like, you can ignore it. If you would like to remove this warning, simply create another message back at the end of the callback method as what's been done in the query method. This is used for executing Flow's API after finishing up the callback method.

There will be some instances where I will wan't to do that, but for now it's fine. But I will go home and play around with it later, now that I can finally get something working. Just excited to see if I can get the FlowLauncherAPI to work. So when the user selects a certain query, it will call the FlowLauncherAPI.ChangeQuery function. But you have already mentioned you don't know how to invoke the API functions from python. So I will just play around with the syntax.

@taooceros
Copy link
Member Author

Sure. Remember to reach out if you find something weird happens. Even though I am not sure what's the right way to do that, the understanding of how Flow deal with certain callback messages makes me easy to understand what's going wrong.

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

@taooceros Every time I write something in Flow Launcher, I get some errors that I dont know why are coming. I'm not certain it has anything to do with my specific plugin though.
2021-06-07.txt

It does execute the function correctly but no matter if I set the "dontHideAfterAction" to false or true, it still displays the flow launcher. I would like to close it down when the query is selected.

If you would like to remove this warning, simply create another message back at the end of the callback method as what's been done in the query method. This is used for executing Flow's API after finishing up the callback method.

And regarding what you said earlier about I could send another message back at the end of the callback. How do I do this, I'm not quite sure I am following what needs to be done.

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

I do think this exception is causing some problems though:

2021-06-07 19:43:38.1119|ERROR|JsonRPCPlugin.ExecuteAsync|-------------------------- Begin exception --------------------------
2021-06-07 19:43:38.1119|ERROR|JsonRPCPlugin.ExecuteAsync|Exception for filename <C:\Users\Anthon\AppData\Local\Programs\Python\Python37\pythonw.exe> with argument <>
2021-06-07 19:43:38.1119|ERROR|JsonRPCPlugin.ExecuteAsync|Exception full name:
 <System.OperationCanceledException>
2021-06-07 19:43:38.1119|ERROR|JsonRPCPlugin.ExecuteAsync|Exception message:
 <The operation was canceled.>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|Exception stack trace:
 <   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at System.Threading.CancellationToken.ThrowIfCancellationRequested()
   at Flow.Launcher.Core.Plugin.JsonRPCPlugin.ExecuteAsync(ProcessStartInfo startInfo, CancellationToken token) in C:\projects\flow-launcher\Flow.Launcher.Core\Plugin\JsonRPCPlugin.cs:line 209>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|Exception source:
 <System.Private.CoreLib>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|Exception target site:
 <Void ThrowOperationCanceledException()>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|Exception HResult:
 <-2146233029>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|-------------------------- End exception --------------------------
2021-06-07 19:43:40.0144|ERROR|JsonRPCPlugin.Execute|Empty standard output and standard error.

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

Okay now I got it to close after the query is clicked. But that's not the function I was trying to figure out. Now I am trying to figure out the FlowLauncherAPI change query function, and no matter how the syntax is or where I call the funtion, it just closes the launcher. No error messages in the logs. (Or there where error messages when I had the wrong syntax and it couldn't find the function. So it can apparently find the flowlauncher api functions and calls them, but it closes the launcher.

This is the script. I have also tried by calling the "this_is_a_test_function" with line 37 uncommented. And it has the same result.

@AnthonMS
Copy link

AnthonMS commented Jun 7, 2021

@taooceros @jjw24 And I can also say now that I am testing some more, there is something very wrong with everything. Why is the title the same on the 2 queries when you can see in the code that it should be different. You can see this in the screenshot I have attached. The code should return a query with title "Get Entities" and another query with title "Get States" But both of them has the title "Get States".

image

And I have also tested the HelloWorldJavascript and HelloWorldTypescript plugin, and they are not even working at all. A ton of errors are thrown in the log files, that I will not even try to mention, because then we can start a new with those languages.

I think you guys need to test some more on your own with these plugins made in python, javascript, typescript and the others. Because I think I have given up trying to get this to work, at least with python or any of the other languages, except C#. (And I have no idea how to set up a development environment in C# for this. So unless you can point me to some documentation to do this, then I won't even try that on my own.)

Unless we can set up some kind of workshop over discord in the weekend, where we can do this together. Because this process is taking too much of my time without getting any closer to getting anywhere really. Timezones don't matter. I can stay up late in the weekend.

But you really need to look into the api with the different languages, except C# since I imagine this is the only working language to create interactable plugins in at the moment.

I'm sorry I'm not more helpful, but this project is just not that important to me. I would love to help! Don't get me wrong, but I also have other stuff going on and this process is just too tedious to keep doing. Because every time you guys fix a bug I find, a new bug pops up, and it's not even because I'm trying to do anything crazy. I'm just trying to do as I'm supposed to. But again, if you wanna fix all these bugs while talking on discord, so we can get some actual work done, I'm down. Just give me time and place :)

@taooceros
Copy link
Member Author

I do think this exception is causing some problems though:

2021-06-07 19:43:38.1119|ERROR|JsonRPCPlugin.ExecuteAsync|-------------------------- Begin exception --------------------------
2021-06-07 19:43:38.1119|ERROR|JsonRPCPlugin.ExecuteAsync|Exception for filename <C:\Users\Anthon\AppData\Local\Programs\Python\Python37\pythonw.exe> with argument <>
2021-06-07 19:43:38.1119|ERROR|JsonRPCPlugin.ExecuteAsync|Exception full name:
 <System.OperationCanceledException>
2021-06-07 19:43:38.1119|ERROR|JsonRPCPlugin.ExecuteAsync|Exception message:
 <The operation was canceled.>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|Exception stack trace:
 <   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at System.Threading.CancellationToken.ThrowIfCancellationRequested()
   at Flow.Launcher.Core.Plugin.JsonRPCPlugin.ExecuteAsync(ProcessStartInfo startInfo, CancellationToken token) in C:\projects\flow-launcher\Flow.Launcher.Core\Plugin\JsonRPCPlugin.cs:line 209>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|Exception source:
 <System.Private.CoreLib>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|Exception target site:
 <Void ThrowOperationCanceledException()>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|Exception HResult:
 <-2146233029>
2021-06-07 19:43:38.1267|ERROR|JsonRPCPlugin.ExecuteAsync|-------------------------- End exception --------------------------
2021-06-07 19:43:40.0144|ERROR|JsonRPCPlugin.Execute|Empty standard output and standard error.

Hi, I just get up. This error is not supposed to be thrown. Don't care about it.

@taooceros
Copy link
Member Author

@taooceros @jjw24 And I can also say now that I am testing some more, there is something very wrong with everything. Why is the title the same on the 2 queries when you can see in the code that it should be different. You can see this in the screenshot I have attached. The code should return a query with title "Get Entities" and another query with title "Get States" But both of them has the title "Get States".

image

And I have also tested the HelloWorldJavascript and HelloWorldTypescript plugin, and they are not even working at all. A ton of errors are thrown in the log files, that I will not even try to mention, because then we can start a new with those languages.

I think you guys need to test some more on your own with these plugins made in python, javascript, typescript and the others. Because I think I have given up trying to get this to work, at least with python or any of the other languages, except C#. (And I have no idea how to set up a development environment in C# for this. So unless you can point me to some documentation to do this, then I won't even try that on my own.)

Unless we can set up some kind of workshop over discord in the weekend, where we can do this together. Because this process is taking too much of my time without getting any closer to getting anywhere really. Timezones don't matter. I can stay up late in the weekend.

But you really need to look into the api with the different languages, except C# since I imagine this is the only working language to create interactable plugins in at the moment.

I'm sorry I'm not more helpful, but this project is just not that important to me. I would love to help! Don't get me wrong, but I also have other stuff going on and this process is just too tedious to keep doing. Because every time you guys fix a bug I find, a new bug pops up, and it's not even because I'm trying to do anything crazy. I'm just trying to do as I'm supposed to. But again, if you wanna fix all these bugs while talking on discord, so we can get some actual work done, I'm down. Just give me time and place :)

Thank you so much for your help! Don't give yourselves so much pressure. Sorry that I believe one of our previous change has brought too much bugs than our expected.
It is a fun thing to develop a plugin. Don't make yourselves feel pressure on it. I really understand how terrible we will feel when something is not working properly even we try every method we can.
We will setup a more comprehensive testing environment in the future (sorry that the bugs make you so terrible).

Give me a few time to check what's going wrong.

@taooceros
Copy link
Member Author

@taooceros @jjw24 And I can also say now that I am testing some more, there is something very wrong with everything. Why is the title the same on the 2 queries when you can see in the code that it should be different. You can see this in the screenshot I have attached. The code should return a query with title "Get Entities" and another query with title "Get States" But both of them has the title "Get States".

I found the issue for this. It is not Flow's bug, but the template bug. The template uses the same reference for Template for every single message, which results in that if you would like to send two message with the template, it will not work as you expected. You can solve it by adding .copy() after referencing the TEMPLATE.

image

@taooceros
Copy link
Member Author

I will leave a pr there to fix it.

@taooceros
Copy link
Member Author

Unable to hide is my bad. I forget to add that property name with our last fix.

@taooceros
Copy link
Member Author

Okay now I got it to close after the query is clicked. But that's not the function I was trying to figure out. Now I am trying to figure out the FlowLauncherAPI change query function, and no matter how the syntax is or where I call the funtion, it just closes the launcher. No error messages in the logs. (Or there where error messages when I had the wrong syntax and it couldn't find the function. So it can apparently find the flowlauncher api functions and calls them, but it closes the launcher.

There's some issue with the new Json Library that won't immediately change the value type, which makes invoking kindly hard. I will try to find a solution toward that. (Also, there's some hard-coding issue there and I will post the fix as well).

@taooceros
Copy link
Member Author

@AnthonMS There's already a deepcopy in @Zeroto521 's Python Template😂😂

@taooceros
Copy link
Member Author

I post the fix for executing callback in #466. Sorry for the various bug brought by Json Library Change

@AnthonMS
Copy link

AnthonMS commented Jun 8, 2021

Sorry about my frustration yesterday. I just felt so lost.

The deepcopy is obviously my bad, I was trying to make it easier to work with for my own sake while testing. I also felt like it was weird it had the same title and action, since it was working before I started using the template and just made the json objects from scratch in the beginning. I was not sure how the deepcopy worked, but I set the template json in the first call, so obviously it is already set in the second, I could have told myself that, if I had just used some common sense instead of just giving up immediately.

Again, I'm sorry about my long rant. I have not given up yet, and will try again tonight.

Thanks for the help!

@AnthonMS
Copy link

AnthonMS commented Jun 8, 2021

@AnthonMS There's already a deepcopy in @Zeroto521 's Python Template😂😂

I'm so dumb.... 😂

@AnthonMS
Copy link

AnthonMS commented Jun 8, 2021

@taooceros or @jjw24 I was wondering if I can find artefacts with hotfixes myself, or you guys have to compile it and upload? Because I don't want to be burden more than I already have, but I would love to test these new fixes from #466

@taooceros
Copy link
Member Author

@taooceros or @jjw24 I was wondering if I can find artefacts with hotfixes myself, or you guys have to compile it and upload? Because I don't want to be burden more than I already have, but I would love to test these new fixes from #466

Yes, you can. Here's the link. https://ci.appveyor.com/api/buildjobs/kwpa3s1trlsculid/artifacts/Output%2FPackages%2FFlow-Launcher-v1.7.2.exe

image

Here's where you can find the artifact for pull request.

@AnthonMS
Copy link

AnthonMS commented Jun 9, 2021

Unable to hide is my bad. I forget to add that property name with our last fix.

Finally got time to test out the hot fix you posted in last comment. It seems as if it's still not hiding flow launcher when I set the "dontHideAfterAction" to False. I do not get any errors in the log and the function is still executed.

And I still can't get change query function to work. I have tried both this approach:
self.sendActionMess("Action Message 2", "Subtitle: Args: {}".format(args), "Flow.Launcher.ChangeQuery", ["ha new test query", False], False)
And I have tried calling a local function like:
self.sendActionMess("Action Message 1", "Subtitle: Args: {}".format(args), "this_is_a_test_function", [args], False)
And then in the "this_is_a_test_function" function, I call the change query function like:
FlowLauncherAPI.change_query("ha this is a test query lolololol", True)

When I do the last option, it just closes the launcher, and the first option, nothing happens and no errors are thrown in the log.

Here is the script. I will come back in a couple months and hopefully these issues has been addressed, tested and known to work by that time.

@taooceros
Copy link
Member Author

Hmmm it's not working? That's weird, because I do successfully change the query. I will check it again.

Anyway, thank you so much for all the time spending on this. We are sorry that our release version contains so much bugs for python plugin that wasn't discovered before.

It's time to write more unit test.

@taooceros
Copy link
Member Author

@AnthonMS My bad, I make one logic wrong. So the DontHideAfterAction only works when you have a reply for callback method.

When I do the last option, it just closes the launcher, and the first option, nothing happens and no errors are thrown in the log.

It close the launcher, but also change the query.

@taooceros taooceros mentioned this pull request Jun 10, 2021
@AnthonMS
Copy link

@AnthonMS My bad, I make one logic wrong. So the DontHideAfterAction only works when you have a reply for callback method.

What kind of reply is it listening for? Because I tried some different return strings and objects and it didn't seem to make a difference.

@AnthonMS
Copy link

Anyway, thank you so much for all the time spending on this. We are sorry that our release version contains so much bugs for python plugin that wasn't discovered before.

You're welcome, I have enjoyed helping you guys. And I will still do some more testing when I have more free time.

@taooceros
Copy link
Member Author

@AnthonMS My bad, I make one logic wrong. So the DontHideAfterAction only works when you have a reply for callback method.

What kind of reply is it listening for? Because I tried some different return strings and objects and it didn't seem to make a difference.

You will need to print out the resulted json value. I will modify the template to make that process easier. That will only be useful when you would like to execute Flow api after executing the callback method.

@taooceros
Copy link
Member Author

action = copy.deepcopy(ACTION_TEMPLATE)["JsonRPCAction"]
        
        action["method"] =  "Flow.Launcher.ChangeQuery"
        action["parameters"] = ["ha new test query", False]
        
        print(demjson.encode(action))

Something like this. Let me try to make the library do that easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants