Jump to content

Butler

Member
  • Posts

    3
  • Joined

  • Last visited

Butler's Achievements

Helping Hand

Helping Hand (3/5)

0

Reputation

  1. Thanks for your comments. My problem there was not python, but Alfred as far as I understand it. I had the problem that the German "Umlaute" like ä,ö,ü weren't properly transmitted to the python script, unicodedata did not solve this problem, QUERY=$(iconv -f UTF-8-MAC <<<"{query}") did. When I used Umlaute in a query defined in the script or passed to the script from the terminal there was no problem because as you said python3 is unicode aware but somewhere in a forum somebody said that somewhere in Alfred umlaute aren't properly processed. I do it like that because I use the same script somewhere else and I don't want to copy all changes into the workflow every time. I don't understand what "That’s a legacy mode for backwards compatibility." means, do you have some site where I can read about this or could you explain? But I will try it. fair point, I did not think about that. Thanks Oh I did not think somebody would want to recreate it to debug it. I hoped to receive some tipps about what could it be. In fact the rest of the code is nothing special and as the code works in principle and does not throw an error in the terminal I tought it might be unnecessary.
  2. hey, I need help because I habe no Idea where to find my mistake: I wrote a Python Script to facilitate my vocabulary learning. In the end it is a pretty easy script which takes the word as an input, runs a request, scrapes the translation and prints me this translation on the screen. I didn't want to open my browser every time. In fact this worked pretty well until some time ago and I have no idea why it stopped working. The workflow is pretty easy to: Keyword with argument runs a scipt in my shell which start parses the input in UTF8 and then starts the srcript, the output of the scipt is printet to the sdtout, which is either the terminal or the in the case of Alfred a large type popup. QUERY=$(iconv -f UTF-8-MAC <<<"{query}") python3 -u "/Users/***/Engl.py" $QUERY if I put this directly into the terminal and run in, it looks like this MacBook-Pro  ~ QUERY=$(iconv -f UTF-8-MAC <<<"häßlich") MacBook-Pro  ~ echo $QUERY häßlich MacBook-Pro  ~ python3 -u "/Users/**/Engl.py" $QUERY häßlich ----- uglier adj unsightlier adj ugly adj unpleasant adj hideous adj nasty adj unsightly adj loathsome adj häßlich (comparative häßlicher, superlative am häßlichsten) Formerly standard spelling of hässlich which was deprecated in the spelling reform (Rechtschreibreform) of 1996. But when I run the same from alfred there is no output as it used to be. Stil I know that the script works because the script also writes into a database, which works. Only the printing suddenly seem to have stopped working. I also tried to use the import sys s = sys.stdout for a in my_input: s.write(a + '\n') Instead of just printing in python but no change. To test the printing function I also ran an easy script from alfred which only prints "hey". This also worked so as I see it every part of the worklow works itself just not as whole. Here is the part of the script which should print out the stuff if __name__ == "__main__": if len(sys.argv) == 1: webbrowser.open("https://www.linguee.de/deutsch-englisch/") elif len(sys.argv) == 2: query = sys.argv[1] print(query + "\n" + "-----") abc= request_Linguee(query, buff=1)["Translation"] print(abc) defenglish = definition_english(query) print(defenglish) else: query = "" ag1 = len(sys.argv) for i in sys.argv[1:ag1]: query += i + " " #print (query) print(query + "\n" + "-----") print(request_Linguee(query, buff=1)) else: print("Nope: ") print("__name__") I'm thankful for every idea, where there could be a problem.
  3. Hey! I have a little Problem. I wrote a little Python Script to help me with Vocabulary. It's not a big thing: I type in the keyword and the vocabulary I'm searching for, Alfred takes the query, opens the python script via shell (detour via shell because it needs to be python3 and alfred uses the python2 interpreter), passes on the query via argv, the python script requests the page of linguee, takes the translation and passes it back to alfred. This way I do not have to start the browser everytime I search a word and alfred passes on the word I searched into a txt so I know which words I have to learn. The problem know is, that when I evoke the script from my normal shell, it works perfectly. The argv is passed on into python, python prints the translation into the terminal, great. But when I evoke the same scripts with the same shell from alfred, python doesn't find the words. The status code is 200, the page is saved in the "soup" varible the search for soup1 and 2 doesn't work, alfred prints "loop3, none, none" so in the if...elif..else it takes the third turn. I really don't understand why. It is the same shell same python script, the same python interpreter.... Why does it work in the terminal but not in alfred? Thanks already for your help!
×
×
  • Create New...