Jump to content

spongeblink

Member
  • Posts

    20
  • Joined

  • Last visited

Reputation Activity

  1. Like
    spongeblink got a reaction from vitor in Automation Task "Strip Last Line" Malfunctions   
    Got it! Thanks for the explanation and the work, @vitor
  2. Haha
    spongeblink reacted to Stephen_C in Automation Task "Strip Last Line" Malfunctions   
    @spongeblink we may have the key in this:
     
     
    My file did have an empty 6th line. When it does not I can reproduce your result.
     
    Edit: Yes, same version of Automation Tasks.
     
    Stephen
  3. Thanks
    spongeblink reacted to vitor in Catching errors from automation tasks   
    The original case in this issue, which is indeed valid, is also highly specific. You wouldn’t really want Alfred’s red debugger text to be shown as a notification because not all errors are relevant. Those message are what’s sent to STDERR. You’ll note from that description that it’s used (emphasis mine) for error messages or diagnostics. That’s a bit weird, right? Couldn’t we have a separate STDDIAG or STDWARN or something? Unfortunately we’re all half a century too late for that now. Computer systems pile on what came before and we need to use what we have.

    Plenty of tools use STDERR for informative messages. Have you ever used curl to download something or make a web request? That self-updating progress you see in the terminal is being sent to STDERR. But why? It’s not an error. Indeed, but the alternative would have been to munge it with STDOUT and making a mess of whatever data you’re trying to retrieve when redirecting or piping to another command. Again, we need to make do with what we have and that’s true for all projects.

    Now picture if all STDERR messages from all tools and all libraries in all workflows were notifying you left and right of every little thing. Pretty soon we’d all be asking for Alfred to not show those messages. Or worse, ignoring them without paying attention because they’d be irrelevant too often.
  4. Like
    spongeblink got a reaction from zeitlings in Do Slower Part of the Script Later in Script Filter   
    Thank you so much for modifying my code! 👍👍 Than's exactly how I would like it to work!
     
    Looked at my original code and found out that the quick part does not trigger a rerun of itself to let user_prompt and former_user_prompt sync since os.getenv("former_user_prompt") == os.getenv("user_prompt") is no longer true. 
     
    Your solution is way better! Thanks in advance!
  5. Thanks
    spongeblink reacted to zeitlings in Do Slower Part of the Script Later in Script Filter   
    This seems to do the trick:
    #!/usr/bin/env python3 # -*- coding: utf-8 -*- import json import os import sys import uuid import time def get_query() -> str: """Join the arguments into a query string.""" return " ".join(sys.argv[1:]) def provide_history(): """Provide the history of the user.""" prompt = get_query() if os.getenv("did_rerun") is None or (prompt != os.getenv("former_user_prompt")): uuid_ = str(uuid.uuid1()) pre_history_dict = { "variables": { "former_user_prompt": prompt, "did_rerun": True }, "rerun": 0.1, "items": [ { "type": "default", "title": prompt, "subtitle": f"Talk to {prompt} 💬".strip(), "arg": [uuid_, prompt], "autocomplete": "prompt", } ], } sys.stdout.write(json.dumps(pre_history_dict)) else: #slow part time.sleep(1) response_dict = { "variables": { "former_user_prompt": prompt, }, "items": [ { "type": "default", "title": "slow part", "subtitle": f"Talk to {prompt} 💬".strip(), "arg": [os.getenv("uuid_"), prompt], "autocomplete": prompt, } ], } sys.stdout.write(json.dumps(response_dict)) provide_history()  

  6. Like
    spongeblink reacted to zeitlings in Do Slower Part of the Script Later in Script Filter   
    You may want to have a look at the "rerun" key.
     
     
    On the first run, return the results that are loaded quickly, immediately rerun, then execute the slow script and return the results. If the Alfred window is still open, the first results will be replaced. (You could pass a variable that acts as a token to indicate that the slow script should be run now).
  7. Like
    spongeblink reacted to vitor in Script Filter Gives Wrong Result Despite Script Running Correctly in Terminal   
    That is due to NSTask decomposition. Normalising it is the way to go.
×
×
  • Create New...