Jump to content

Recommended Posts

1 hour ago, Buchholdt said:

Does this mean anything to you?

 

Looking at the error message and the code, you’ve forgotten to set the pythonDir variable.

 

Looks like a bug, tbh. From the workflow's description, setting the variable is supposed to be optional, but it's absolutely required by the code.

 

If it were me, I would change the tinypng and tinypng_api Script Filters from:

 

"$pythonDir" tiny_key_options.py {query}

 

to:

export PATH=/opt/homebrew/bin:/usr/local/bin:$PATH

python3 tiny_key_options.py {query}

 

Link to comment

Thanks again, it's really appreciated.

I have done the changes and its like I'm almost there, once I paste the API I get the following:

 

[14:03:43.668] TinyPNG[Script Filter] Queuing argument ''
[14:03:43.725] TinyPNG[Script Filter] Script with argv '(null)' finished
[14:03:43.727] TinyPNG[Script Filter] {"items": [{"title": "Set API key to ...", "subtitle": "Set API key to ...", "valid": false}, {"title": "Get a new API key", "subtitle": "Open https://tinypng.com/developers to get a new API key", "arg": "WEBSITE", "valid": true}]}
[14:03:45.479] TinyPNG[Script Filter] Queuing argument 'GF4qGlzLMPr0fnV1mF9hDfxq9GH8f9rZ'
[14:03:45.535] TinyPNG[Script Filter] Script with argv '(null)' finished
[14:03:45.538] TinyPNG[Script Filter] {"items": [{"title": "Set API key to \"GF4qGlzLMPr0fnV1mF9hDfxq9GH8f9rZ\"", "subtitle": "Set API key to \"GF4qGlzLMPr0fnV1mF9hDfxq9GH8f9rZ\"", "arg": "GF4qGlzLMPr0fnV1mF9hDfxq9GH8f9rZ", "valid": true}]}
[14:03:46.638] TinyPNG[Script Filter] Processing complete
[14:03:46.640] TinyPNG[Script Filter] Passing output 'GF4qGlzLMPr0fnV1mF9hDfxq9GH8f9rZ' to Conditional
[14:03:46.641] TinyPNG[Conditional] Processing complete
[14:03:46.641] TinyPNG[Conditional] Passing output 'GF4qGlzLMPr0fnV1mF9hDfxq9GH8f9rZ' to Run Script
[14:03:46.642] TinyPNG[Conditional] Passing output 'GF4qGlzLMPr0fnV1mF9hDfxq9GH8f9rZ' to Post Notification
[14:03:46.652] ERROR: TinyPNG[Run Script] /bin/bash: : command not found
[14:03:46.654] TinyPNG[Run Script] Processing complete
[14:03:46.655] TinyPNG[Run Script] Passing output '' to Conditional
[14:03:46.655] TinyPNG[Conditional] Processing complete
[14:03:46.656] TinyPNG[Conditional] Passing output '' to Run Script
[14:03:46.656] TinyPNG[Conditional] Passing output '' to Post Notification

 

So it's like the API has not been accepted.

 

Link to comment
On 11/26/2021 at 3:25 PM, deanishe said:

 

There are two scripts that need editing.

 

Remove your API key from your post.

Thanks again.
If you have the time, can you clarify a bit more about the 2 scrips I need to edit?

 

Also, I did change som characters in the API, so no issue there.

 

Also, just another question.
I'm Used to use Alfred some years ago, before having to with to a PC (work), and now I'm very happy to be back again. I don't remember that I needed so much knowledge to activate a Alfred app. Has the apps become much more complex, or does this seem to be 1/100 times were you need to do a bit more work?

Link to comment

 

3 hours ago, Buchholdt said:

If you have the time, can you clarify a bit more about the 2 scrips I need to edit?

 

It’s the same error message as before, which means that $pythonDir still isn’t set. Presumably, this means you only fixed one of the tinypng and tinypng_api scripts, and the error is coming from the other one.

 

3 hours ago, Buchholdt said:

Has the apps become much more complex

 

It's just the way the workflow is built. @shmulvad chose to use a language that isn't installed by default, so you're going to need to install that to use this particular workflow. TinyPNG requires an API key, so the workflow requires some unavoidable configuration, too.

 

The former (needing to install a language) is going to become very common in the future, however, as Apple have been steadily removing non-Apple languages from macOS over the past few years.

Link to comment

I found that I could also change the "$pythonDir" in the file "/bin"bash" files:522425546_Screenshot28_11.2021-09_21.png.f4c4fa7a8ebb8d7eb7029d34ad59db70.png

 

But it did not quite get me there. 

 

Looking more into the files, I wounder if I kan insert the API directly into the "/usr/bin/osascript" as either the "API_KEY" or "{query}":

 

set bundleID to (system attribute "alfred_workflow_bundleid")

tell application id "com.runningwithcrayons.Alfred"
    set configuration "API_KEY" to value "{query}" in workflow bundleID
end tell

 

Can you tell if this code is like fx. javascript?

As you mention, there will probably be more need for some basic code knowledge in the future. I have for some time thought about learning a language, to get a better understanding, and it seems like Javascript is quite popular, and if I can use it here in Alfred, it might be the language for me to try out.

 

Link to comment
46 minutes ago, Buchholdt said:

Looking more into the files, I wounder if I kan insert the API directly into the "/usr/bin/osascript" as either the "API_KEY" or "{query}"

 

Not worth the hassle. The variables are all ultimately set in the workflow's configuration sheet. At this point, your best bet is probably to just reinstall a pristine version of the workflow and edit the variables.

 

That's the simplest thing for a user to do. The fix I'm talking about is what @shmulvad should do so users don't have this problem in the future.

 

46 minutes ago, Buchholdt said:

Can you tell if this code is like fx. javascript?

 

Don't know. What is that?

 

In any case, there's no JavaScript in the workflow. It's written in a combination of Python 3 and AppleScript.

 

46 minutes ago, Buchholdt said:

it seems like Javascript is quite popular, and if I can use it here in Alfred, it might be the language for me to try out.

 

I wouldn't call JavaScript "popular" exactly because an awful lot of programmers despise the language. It is extremely common, however. Its status as the only language supported by web browsers ensures that. Almost every programmer knows a bit of JavaScript.

 

Personally, I'd recommend starting with Ruby or Python. They're more sensible, better designed languages. JS and its community have a reputation for being nuts. I'd argue that the best place to start learning to code is probably not out on what most coders consider a lunatic fringe.

Edited by deanishe
Link to comment
  • 2 weeks later...

Hi again,

I manage to understand it now, and I happy too tell that the app now works for me.

 

And regarding the coding, I will give Python a go, as I have read some good things about this as well. And this way I will stay clear of the "lunatics" 🙂

 

Thank you very much for the help, I really appreciate it. I have just send some beer money money your way, I hope it buys you a cold one.

 

 

Link to comment
  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...