Go Down

Topic: Using Geany for development in Linux (Read 578 times) previous topic - next topic

noweare

I just switched from Windows 10 to Linux mint and trying to use Geany for arduino development
.
I followed Robins instructions from past threads on the subject.

I can verify and download using the command line interface using :
joe@joe-450-a114 ~ $ python pythonbuild.py dev/Arduino/sample/sample.ino

When trying to run from Geany I get the error
Invalid working directory ""/home/joe/dev/Arduino/sample/sample.ino""   

That is a valid path and I have permission to both the folder and file.

When i remove the "%d/%f" from the cmd the terminal opens with the error:
/tmp/geany_run_script_1KVMJZ.sh: 7: /tmp/geany_run_script_1KVMJZ.sh: /home/joe/pythonbuild.py: Permission denied.

it looks like from Geany I can not get python to execute for some reason.

Any help is appreciated. I know this is kind of non-main stream topic.

Robin2

What command have you entered in Set Build Commands in Geany?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

noweare

Hello Robin,

Under Exectute commands

Command:      ~/bin/pythonbuild.py

Working directory:  "%d/%f"




Working directory is /home/joe/dev/Arduino/sample
File is : sample.ino

error is ;Invalid working directory ""/home/joe/dev/Arduino/sample/sample.ino""

Robin2

Hello Robin,

Under Exectute commands

Command:      ~/bin/pythonbuild.py

Working directory:  "%d/%f"


I think you should do this
Code: [Select]
Command:      ~/bin/pythonbuild.py "%d/%f"

Working directory:


In other words leave the working directory box empty

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

noweare

I made the change you suggested.

I still get "Permission denied"

I don't understand how it will build from the command line.

I can run from the command line until I figure it out.

Thanks for that script.

I have not gotten to it yet but do you have syntax highlighting and auto complete working in Geany?

Robin2

What happens if you enter the command from Geany at a terminal
Code: [Select]
~/bin/pythonbuild.py

it should run my Python program although it will fail because it does not have a .ino file to work on. If it does not run my Python program then your command is wrong.

Another thought is to enter the command which python

On my PC it gives /usr/bin/python which leads me to think you should not have the tilde at the start of your command.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

noweare

The ~/bin is where the pythonbuild.py file is, which is home/joe/bin folder

When i run the command without tilde I get pythonbuild.py: not found

When I run the command  with the tilde I get ; permission denied

"which python" returns /usr/bin/python which is a shortcut to python 2.7

I used "python ~/bin/pythonbuild.py"  as the command and the script ran.
I got an out of range error since  %d/%f was not used as the working directory, so that makes sense.

When I did give it the %d/%f I got this error:
Invalid working directory "/home/joe/dev/Arduino/4X20OLED/4X20OLED.ino"

But that is the correct path so I don't know what it isn't liking.

The "shebang" in the script with the correct path to python so it I should not have to add python to the command.

Thanks for your help.





Robin2

#7
May 23, 2018, 09:33 am Last Edit: May 23, 2018, 09:36 am by Robin2
The ~/bin is where the pythonbuild.py file is, which is home/joe/bin folder
Sorry, I got myself confused. I was thinking of the location of the python interpreter


have you got this line
Code: [Select]
#!/usr/bin/env python
at the top of your pythonbuild.py file
(It may need to be a different location on your system)

And is the file pythonbuild.py set as executable and do you have execute permission?


Another possibility is to change the command to
Code: [Select]
python ~/bin/pythonbuild.py

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

noweare

Yes, I have the shebang in the file.

I going to re-install the software to see if that helps

This is not making sense. I've spent hours fiddling around,
reading the manual and it should of worked.

Do you have syntax highlighting and autocomplete working ?

Thanks for your help.


Robin2

Yes, I have the shebang in the file.
If that is working then my Python program should run (albeit do nothing) when you enter
Code: [Select]
~/bin/pythonbuild.py
in a terminal.

You said you get "permission denied" so that seems to be the main problem because you said it does work when you enter
Code: [Select]
python pythonbuild.py dev/Arduino/sample/sample.ino
and I presume it will run my program when you enter
Code: [Select]
python pythonbuild.py


You have not said if you tried using Geany with the command
Code: [Select]
python ~/bin/pythonbuild.py "%d/%f"


Quote
Do you have syntax highlighting and autocomplete working ?
Yes, but the syntax highlighting is not identical to the Arduino IDE. To be honest the colours are meaningless.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

noweare

If that is working then my Python program should run (albeit do nothing) when you enter
Code: [Select]
~/bin/pythonbuild.py
in a terminal.

"bad interpreter" when run as above. I had to put python in front, like the shebang isn't recognized

You said you get "permission denied" so that seems to be the main problem because you said it does work when you enter
Code: [Select]
python pythonbuild.py dev/Arduino/sample/sample.ino

Yes, when entered at the terminal
 
and I presume it will run my program when you enter
Code: [Select]
python pythonbuild.py

Yes, it does at both the command line and Geany, but will run errors out in Geany if I enter
the %d/%f



You have not said if you tried using Geany with the command
Code: [Select]
python ~/bin/pythonbuild.py "%d/%f"
I get the invalid working directory error

Yes, but the syntax highlighting is not identical to the Arduino IDE. To be honest the colours are meaningless.
I am told ver 3.2 and later has arduino filetypes. I was using ver 2.7
...R
[/quote]

Thanks for your help Robin. I need to walk away from this for a couple of days. When I figure it out
I will post what if anything was going on. If I can figure it out. May just take a fresh re-install.

Robin2

#11
May 23, 2018, 06:57 pm Last Edit: May 23, 2018, 06:58 pm by Robin2
The way you have responded to my comments (by typing inside the quote) means I cannot quote your responses easily.

Quote
"bad interpreter" when run as above. I had to put python in front, like the shebang isn't recognized
Are you sure you have set pythonbuild.py as executable?

What shebang have you actually got in your file?

Quote
Yes, it does at both the command line and Geany, but will run errors out in Geany if I enter
the %d/%f
Quote
I get the invalid working directory error
Copy and post the exact error messages

Quote
I am told ver 3.2 and later has arduino filetypes. I was using ver 2.7
Those sound like Python version numbers. Code highlighting is something in Geany. It is not part of the Python language. Especially as the code you want to highlight is C++, not Python.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

noweare

joe@joe-450-a114 ~ $ ls -l pythonbuild.py
-rwxrwxr-x 1 joe joe 7126 May 21 19:39 pythonbuild.py
joe@joe-450-a114 ~ $ pythonbuild.py
bash: /home/joe/bin/pythonbuild.py: /usr/bin: bad interpreter: Permission denied
joe@joe-450-a114 ~ $


//shebang
#!/usr/bin python

command  /  working directory
~/pythonbuild.py     %d/%f
15:49:00: Invalid working directory "/home/joe/dev/Arduino/sample/sample.ino"

When I was talking about code highlighting I meant ino file in Geany, not python

noweare

I can run your script from Geany now.

The shebang looked like this  #!/usr/bin python but my system liked it like  #!/usr/bin/python (without space)

In Geany I was still getting "invalid working directory" with the %d/%f so I took your suggestion and moved in

in with the command. Then it all worked.

Thanks again for all your help Robin.

Robin2

#14
May 24, 2018, 10:45 am Last Edit: May 24, 2018, 10:47 am by Robin2
Glad you have it working.

Quote
The shebang looked like this  #!/usr/bin python but my system liked it like  #!/usr/bin/python (without space)
All systems will require it with the / instead of the space.

Quote
When I was talking about code highlighting I meant ino file in Geany, not python
I know. That's why I did not understand your reference to versions 3.2 and 2.7

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up