Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Flume Tutorial Error with Python Script

avatar
Contributor

I am working through this tutorial and I'm encountering the error shown below. I see that others have experienced it to from looking at the comments below the walk through. I believe I have successfully completed this tutorial before. Any ideas on how to resolve this?

[root@sandbox home]# python generate_logs.pyFile “generate_logs.py”, line 98return resultsSyntaxError: ‘return’ outside function
1 ACCEPTED SOLUTION

avatar
Master Guru

Just downloaded and ran the generate_logs file in the sandbox and it works fine for me. Are you sure you didn't modify the script somehow? Sometimes python is very sensitive to tab changes. Its easy for a return to suddenly be a couple characters more to the left or right and with that not in the function anymore.

View solution in original post

12 REPLIES 12

avatar
Master Guru

Just downloaded and ran the generate_logs file in the sandbox and it works fine for me. Are you sure you didn't modify the script somehow? Sometimes python is very sensitive to tab changes. Its easy for a return to suddenly be a couple characters more to the left or right and with that not in the function anymore.

avatar
Contributor

@Benjamin Leonhardi Thanks Benjamin. I'm currently completing the lengthy re-download and install of the SBX and will also re-download the script. Will let you know if I still receive an error.

avatar
Master Guru

And if you do and still have the problem, have a look into the script file. It is not that long and it should be pretty obvious if a return is not lined up with the function before it. The comment says that he saw some intendation errors. Since I do not have the problems they must have been added perhaps by opening the file in Windows or something. Or there was a bad version hosted that was updated? Not sure.

avatar
Contributor

@Benjamin Leonhardi I'm almost at the part where I should run the script. However, Ive noticed two other items about the tutorial.

  1. When I execute the mv command for flume.conf, I am told it already exists and will be overwritten.
  2. The log4jproperties file is already configured correctly.

avatar
Contributor

@Benjamin Leonhardi Same error message received. Below is what is in the script which I re-downloaded and unzipped. I would paste the code from the script but it exceeds the 600 character limit. Instead Ive attached pictures. I see no issues with indentation of return statements nor do I see anything on line 98.


py2.pngpy1.png

avatar
Master Guru

Can you have a look at the file in the sandbox ( cat vi ). Might be different from windows ( Thats notepad++ right? )

avatar
Contributor

@Benjamin Leonhardi Interesting! You are right, I was using Notepadd++. However, when I opened the script in vi, there are additional lines not visible in Notepad++. See the attached picture. I changed the return on line 98 to be commented as suggested on the tutorial comments and the script executed.py3.png

avatar
Master Guru

Did it also generate the logs? Its a bit weird, that is what I just downoaded from the tutorial link:

So for me it needed the return, it needs to be in the same line as the for and I don't have the main at the top you have.

2046-screen-shot-2016-02-11-at-40527-pm.png

avatar
Contributor

@Benjamin Leonhardi The main() at the top of mine is the one at the bottom of yours. My screenshot from vi is showing that line plus additional lines which were not visible in Notepad++. Sadly, no, nothing is being written to /flume/events