-
-
Notifications
You must be signed in to change notification settings - Fork 452
Add JsonRPCPlugin.cs Rerun implementation #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
So excited to try this out! Is it ready for test? The build is failed 😄 |
Yeah you can test it out. It is not a complex change so I believe my logic (haven't tested it out myself XD). |
I would like to implement this after #653, but currently it should work fine. |
Tested the @Garulf yo check this out! Is this what you request? 😄 Plugin code, generate random number, rerun every 200ms import json
import sys
def main():
request_data = sys.argv[1]
request_dictionary = json.loads(request_data)
if request_dictionary['method'] == 'query':
import random
response_dictionary = {
'result': [
{
"Title": f"{random.random()}",
"SubTitle": "This is my hello world",
"IconPath": "favicon.ico",
"JsonRPCAction": {
'method': 'Flow.Launcher.ShowApp',
'parameters': [],
},
},
],
"RerunDelay":200,
}
response_converted_to_json_string = json.dumps(response_dictionary)
print(response_converted_to_json_string)
if __name__ == '__main__':
main() |
its... its beautiful!!! @taooceros you're awesome! Going to try this out as soon as I can! |
Any chance to have the loading bar trigger while a rerun is scheduled? For example when polling a external web API you dont want to hit it too often. But it may be beneficial to indicate that Flow is still working. Edit: Edit2: Yeah, log shows scheduled reruns are not halting after Flow's window closes. Flow is closed yet its still rerunning in the background. Edit3: selection jumping to top on each rerun if you use arrow keys to select you're selection will keep jumping to the top of the list. |
Yeah we do, let me change a bit. |
@taooceros Quick consult, do you see this code have any obvious problem? This breaks after a merge this PR to my personal code (have customized debug logs). It breaks if I typing fast on a Python plugins. I'll make a detail bug report later if needed. JsonRPCPlugin.cs:246 // Mutate intercept source
// Upstream `source`
// await using var source = process.StandardOutput.BaseStream;
await using var mySource = process.StandardOutput.BaseStream;
var debugOuput = mySource.ReadToEnd();
Log.Debug($"|JsonRPCPlugin.ExecuteAsync|result:<{debugOuput}>");
var bytesOutput = Encoding.UTF8.GetBytes(debugOuput);
await using var source = new MemoryStream(bytesOutput); |
Could you upload it as a branch in your fork, so I can see more code which leads to the problem. |
Oh probably if you type faster, the request will be canceled? So only the last one may be log. |
@taooceros Here is the code that breaks, it just for log out the RPC response of python plugin These lines are the only different compare to this PR // await using var source = process.StandardOutput.BaseStream;
await using var mySource = process.StandardOutput.BaseStream;
var debugOuput = mySource.ReadToEnd();
Log.Debug($"|JsonRPCPlugin.ExecuteAsync|result:<{debugOuput}>");
var bytesOutput = Encoding.UTF8.GetBytes(debugOuput);
await using var source = new MemoryStream(bytesOutput); |
Have you merged upstream/dev? You may need to fetch first. Or simply |
Check out https://github.com/pc223/Flow.Launcher/tree/JsonRPCRerun on my repo, I modified directly base on this PR |
Getting errors with latest build: df62935
|
Yeah I change the method of query rerun to "query_rerun" to indicate it is a rerun. |
Ah! I see. |
Seems |
Yeah that's true. |
Probably it doesn't work because you didn't seek to origin, so the getbytes is creating nothing. You can do it like this. try
{
// token expire won't instantly trigger the exception,
// manually kill process at before
await source.CopyToAsync(buffer, token);
}
catch (OperationCanceledException)
{
await buffer.DisposeAsync();
return Stream.Null;
}
+ buffer.Seek(0, SeekOrigin.Begin);
+ var debugOuput = await new StreamReader(buffer).ReadToEndAsync();
+
+ Log.Debug($"|JsonRPCPlugin.ExecuteAsync|result:<{debugOuput}>"); |
It is also possible that the process is killed so the stream won't read anything |
#635