[GRASS-user] Trying python scripts.

OK, right after a wrote that, I thought I was being too bold.

Should I go for:

svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
grass64_release

or this one?

svn checkout
https://svn.osgeo.org/grass/grass/tags/release_20090609_grass_6_4_0RC5
grass640_rc5

Thanks again and sorry for all the questions.

Best regards,
Marcello.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5119849.html
Sent from the Grass - Users mailing list archive at Nabble.com.

This is a script that I wrote this morning to grab the latest 6.4 svn
sources and the addons, and then compile the addons that I want and
install grass. the sources are checked out to
~/sources/grass/grass64_release and ../grass-addons. I don't know if
you are on *nix, but this has made me a happy camper. Any tweaks to
this would be helpful if there is a glaring error in my logic, but is
did work.
kindest regards,

Stephen

###bash script below###
#!/bin/bash

sudo -v

#change when major version number changes
grass_dir='grass64_release'

#get latest GRASS Sources
svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
/home/$USER/source/grass/$grass_dir

#get latest grass-addons
svn checkout https://svn.osgeo.org/grass/grass-addons
/home/$USER/source/grass/grass-addons

cd /home/$USER/source/grass/$grass_dir

#ubuntu configuration for Grass 6.5
CFLAGS="-g -Wall" ./configure \
     --with-libs=/usr/lib64 \
     --with-cxx --with-freetype=yes \
     --with-postgres=no --with-sqlite=yes --enable-largefile=yes \
     --with-tcltk-includes=/usr/include/tcl8.4 \
     --with-freetype-includes=/usr/include/freetype2 \
     --with-python=/usr/bin/python2.6-config \
     --with-wxwidgets=yes \
     --with-nls --enable-largefile \
     --with-proj-share=/usr/share/proj \
     --with-readline \
     --with-cairo

make -j4

cd /home/$USER/source/grass/grass-addons/raster
cp -r r.stream* /home/$USER/source/grass/$grass_dir/raster
cd /home/$USER/source/grass/$grass_dir/raster

#make r.stream* modules
folders=$(ls | grep r.stream)
for k in $folders ; do
cd $k
make -j4
cd /home/$USER/source/grass/$grass_dir/raster
done

cd /home/$USER/source/grass/$grass_dir

sudo make install

On Sun, May 30, 2010 at 5:11 PM, Marcello Gorini <gorini@gmail.com> wrote:

OK, right after a wrote that, I thought I was being too bold.

Should I go for:

svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
grass64_release

or this one?

svn checkout
https://svn.osgeo.org/grass/grass/tags/release_20090609_grass_6_4_0RC5
grass640_rc5

Thanks again and sorry for all the questions.

Best regards,
Marcello.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5119849.html
Sent from the Grass - Users mailing list archive at Nabble.com.
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

                -K. Mullis

On Monday 31 of May 2010 00:11:00 Marcello Gorini wrote:

OK, right after a wrote that, I thought I was being too bold.

Should I go for:

svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
grass64_release

or this one?

svn checkout
https://svn.osgeo.org/grass/grass/tags/release_20090609_grass_6_4_0RC5
grass640_rc5

Not sure about the extent of the differences. Go for the releasebranch, should
be the latest if I am not wrong.

FYI, there is also <http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu&gt;
which might not be 100% up-to-date but should do it.

Nikos

stephen sefick wrote:

This is a script that I wrote this morning to grab the latest 6.4 svn
sources and the addons, and then compile the addons that I want and
install grass. the sources are checked out to
~/sources/grass/grass64_release and ../grass-addons. I don't know if
you are on *nix, but this has made me a happy camper. Any tweaks to
this would be helpful if there is a glaring error in my logic, but is
did work.
kindest regards,

Stephen

###bash script below###
#!/bin/bash

sudo -v

#change when major version number changes
grass_dir='grass64_release'

#get latest GRASS Sources
svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
/home/$USER/source/grass/$grass_dir

#get latest grass-addons
svn checkout https://svn.osgeo.org/grass/grass-addons
/home/$USER/source/grass/grass-addons

cd /home/$USER/source/grass/$grass_dir

#ubuntu configuration for Grass 6.5
CFLAGS="-g -Wall" ./configure \
     --with-libs=/usr/lib64 \
     --with-cxx --with-freetype=yes \
     --with-postgres=no --with-sqlite=yes --enable-largefile=yes \
     --with-tcltk-includes=/usr/include/tcl8.4 \
     --with-freetype-includes=/usr/include/freetype2 \
     --with-python=/usr/bin/python2.6-config \
     --with-wxwidgets=yes \
     --with-nls --enable-largefile \
     --with-proj-share=/usr/share/proj \
     --with-readline \
     --with-cairo

make -j4

cd /home/$USER/source/grass/grass-addons/raster
cp -r r.stream* /home/$USER/source/grass/$grass_dir/raster
cd /home/$USER/source/grass/$grass_dir/raster

#make r.stream* modules
folders=$(ls | grep r.stream)
for k in $folders ; do
cd $k
make -j4
cd /home/$USER/source/grass/$grass_dir/raster
done

cd /home/$USER/source/grass/$grass_dir

sudo make install

Stephen Sefick

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Now you got a problem, because I want to make this script work bad,
especially the add-on part, so you need to help me :slight_smile:

And the big problem is that I am VERY limited, but "GOD rewards the
patient...." (I just made that out :))

First I just ran the script and obviously, problems ocurred with respect to
the folders it was looking at.
This line for instance:

/home/$USER/source/grass/grass-addons

implies that I must have this folder already in my computer, right? The
script is not creating it, right?

Assuming I am right, I created all the folders the script points to, before
running it again. But it creates a folder called releasebranch_6_4 and then
one called grass-addons in my home directory (because that is where I ran
the script).
So when you do:
cd /home/$USER/source/grass/$grass_dir
There is nothing there.

But then, trying to make it right, I cd to the folder releasebranch_6_4 and
tried to keep going with the code.
Then after:
CFLAGS="-g -Wall" ./configure \
     --with-libs=/usr/lib64 \
     --with-cxx --with-freetype=yes \
     --with-postgres=no --with-sqlite=yes --enable-largefile=yes \
     --with-tcltk-includes=/usr/include/tcl8.4 \
     --with-freetype-includes=/usr/include/freetype2 \
     --with-python=/usr/bin/python2.6-config \
     --with-wxwidgets=yes \
     --with-nls --enable-largefile \
     --with-proj-share=/usr/share/proj \
     --with-readline \
     --with-cairo

I got the following result:

checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler (gcc -g -Wall ) works... yes
checking whether the C compiler (gcc -g -Wall ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking for Cygwin environment... no
checking for mingw32 environment... no
checking for executable suffix... no
checking for full floating-point support... yes
checking for pwd... /bin/pwd
checking for source directory... /home/marcello/releasebranch_6_4
checking for build directory... /home/marcello/releasebranch_6_4
checking for MacOSX App... no
checking for MacOSX architectures... no
checking for MacOSX SDK... no
checking how to build libraries... shared
checking for ranlib... ranlib
checking how to run the C preprocessor... gcc -E
checking if 64bit support is requested... no
checking if 64bit Sparc VIS support is requested... no
checking system version (for dynamic loading)... Linux-2.6.31-21-generic
checking for dlopen in -ldl... yes
checking for ar... ar
checking for additional include dirs...
checking for additional library dirs... /usr/lib64
checking for a BSD compatible install... /usr/bin/install -c
checking for flex... lex
checking for yywrap in -ll... no
checking for lex... no
configure: error: *** Unable to locate lex.

And then that's it.

Am I COMPLETELY wrong in everything? Can you help me with that?
I was just waiting (because I just got here) to ask for help in the list
with respect to installing add-ons (I really need those fuzzy add-ons), when
you sent me this great script, so now....LET'S GET IT ON!! :slight_smile:

Best regards,
Marcello.

P.S. I use Ubuntu 9.10 64 bits.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5120096.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On Monday 31 of May 2010 00:11:00 Marcello Gorini wrote:

Should I go for:

svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
grass64_release

or this one?

>svn checkout
>https://svn.osgeo.org/grass/grass/tags/release_20090609_grass_6_4_0RC5
>grass640_rc5

Nikos wrote:

Not sure about the extent of the differences. Go for the releasebranch,

should

be the latest if I am not wrong.

FYI, there is also <http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu&gt;
which might not be 100% up-to-date but should do it.

Sorry, I just saw your e-mail. I guess it might answer some of my questions.
I am going into http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu right
now.

Thank you Nikos.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5120112.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Marcello wrote:

checking for lex... no
configure: error: *** Unable to locate lex.

...

P.S. I use Ubuntu 9.10 64 bits.

you need to install all the "Build-depends" packages listed here:

http://svn.debian.org/viewsvn/pkg-grass/packages/grass/trunk/debian/control

( http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu#Dependencies )

Hamish

hamish-2 wrote:

Marcello wrote:

checking for lex... no
configure: error: *** Unable to locate lex.

...

P.S. I use Ubuntu 9.10 64 bits.

you need to install all the "Build-depends" packages listed here:

http://svn.debian.org/viewsvn/pkg-grass/packages/grass/trunk/debian/control

( http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu#Dependencies )

Hamish

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

YES!!!!!!!!!!! Everything working with all the fuzzy modules already !!!!!!

I went through the steps in
http://grass.osgeo.org/wiki/Compile_and_Install_Ubunt, read the INSTALL file
and used Stephen's script and everything went OK! Great!

Thank you everyone!! Really! Now I am fully enjoying and understanding what
the FOSS community is, and especially the GRASS community. I really hope one
day I will know enough to be able to contribute as well.

Thank you Nikos, Carlos, Martin, Hamish, thank you Stephen for your script
that is a piece of art!!

Sorry for the small talk...but THANK YOU!

Cheers,

Marcello.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5120201.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Marcello Gorini wrote:

hamish-2 wrote:

Marcello wrote:

checking for lex... no
configure: error: *** Unable to locate lex.

...

P.S. I use Ubuntu 9.10 64 bits.

you need to install all the "Build-depends" packages listed here:

http://svn.debian.org/viewsvn/pkg-grass/packages/grass/trunk/debian/control

( http://grass.osgeo.org/wiki/Compile_and_Install_Ubuntu#Dependencies )

Hamish

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

YES!!!!!!!!!!! Everything working with all the fuzzy modules already
!!!!!!

I went through the steps in
http://grass.osgeo.org/wiki/Compile_and_Install_Ubunt, read the INSTALL
file and used Stephen's script and everything went OK! Great!

Thank you everyone!! Really! Now I am fully enjoying and understanding
what the FOSS community is, and especially the GRASS community. I really
hope one day I will know enough to be able to contribute as well.

Thank you Nikos, Carlos, Martin, Hamish, thank you Stephen for your script
that is a piece of art!!

Sorry for the small talk...but THANK YOU!

Cheers,

Marcello.

And guess what?! The python script works perfectly in this new version!

So I guess we can finally get out of this topic, huh? :slight_smile:

Or change it for "RUNNING python scripts."

I am really happy!

Cheers,
Marcello.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5120222.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On Mon, May 31, 2010 at 12:11 AM, Marcello Gorini <gorini@gmail.com> wrote:

OK, right after a wrote that, I thought I was being too bold.

Should I go for:

svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
grass64_release

Yes.

Subsequently, it is sufficient to run

cd grass64_release
svn update

No need to "checkout" again and again since "update" will download
the changes.

Markus

On Mon, May 31, 2010 at 12:11 AM, Marcello Gorini <gorini@gmail.com> wrote:

OK, right after a wrote that, I thought I was being too bold.

Should I go for:

svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4
grass64_release

Markus:

Yes.

Subsequently, it is sufficient to run

cd grass64_release
svn update

No need to "checkout" again and again since "update" will download
the changes.

Good, thanks for the tip.
Great that I am already in the new version. Everything is going to be easier
now.
Cheers,
Marcello.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5121589.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi,

2010/5/30 Nikos Alexandris <nikos.alexandris@felis.uni-freiburg.de>:

Marcello Gorini:

Yes, I think I need to move on and download a newer version.
I will probably try to install GRASS 7.

Gr7 is under continuous development. For real work better to use latest Gr64.

or GRASS 6.5 (wxGUI is frozen for several months in GRASS 6.4)

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

On Mon, May 31, 2010 at 5:39 AM, Daniel Lee <Lee.Daniel.1986@googlemail.com> wrote:
Hi Marcello,

Great that everything’s working for you :wink: I’m also a beginner and loving GRASS and Linux… Anyway, 'nuff said. To Python: Your script worked in the new >version? That means in the new 6-4?

Hello Daniel, how are you?
Yes, I mean https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 .

I’ve also tried running Python scripts and have had problems, I ended up switching over to shell scripts because my work was very time sensitive, but I really >like working with Python and I know it better than shell scripting. I noticed in your post earlier that you used the command:

>python myscript.py raster1=map1 raster2=map2 output=outmap

Following questions:

  • Is it necessary to input “python” in front of the script name?

No, you can use ./ only.

  • I was under the impression that Python scripts can be saved into the script directory (/opt/grass/scripts, if I’m not mistaken, right now I’m on another >computer so I can’t check); is that necessary? If not, do you just enter the entire path to the script?

Yes, you can also save it in the scripts directory and run it directly or you can enter the entire path in terminal and ./script.

  • I was also under the impression, that since you tell GRASS what kind of a script it is in the first line (#!/usr/bin/env python), that you don’t need to save it >as .py. Am I mistaken there?

You are also right. I renamed it without the .py extension and it worked as well.

I’ve always saved my python scripts into the script directory and then tried to run them from the GRASS wxPython GUI. It always seemed to find the script >and then fail to parse it correctly. Perhaps it was because I was leaving off the “python” at the beginning of the command line; everything else should be the >same, the script was executable, etc. Any other thoughts? I sadly can’t give any examples at the moment because I’m on another computer and after my new >nstallation I don’t have the failed script outputs as examples any more.

I saved it as r.myscript in the script directory and was able to run directly from the gui or the terminal with no problems. So I guess it is not because of the “python” in the command line. If your version is the same as mine now, I would check the code itself. But I am really a beginner in everything so I wouldn’t listen to me very much.
At least, I think I showed you that you are right in everything. If you can post some examples of your failed scripts later on, I (and everybody else) could try them for you. It would be good for my learning as well.

Thanks!
Daniel

No, I thank you, since you are the first person I might be helping a little little bit in this list. It is good to at least try to contribute.

Best regards,

Marcello.

2010/5/31 Marcello Gorini <gorini@gmail.com>

[back to ML]

Hi,

2010/5/31 Nikos Alexandris <nikos.alexandris@felis.uni-freiburg.de>:

or GRASS 6.5 (wxGUI is frozen for several months in GRASS 6.4)

Yet, 65 has more bugs (in general) right? In the wiki a _discouraging_ of its
use has been signaled [/] specifically for end-users.

right, on the other hand please note that 6.4.0 is 1.5 year in RC
stage!!! (which is unusually very long time for RC stage in which the
development of new features should be frozen). In the result e.g.
wxGUI will be quite out-dated in 6.4.0 compared to 6.5.

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Hi Martin,

Martin Landa:

[back to ML]

it was not my intention to send this off-list. Mis-clicked a button and did
not notice it.

>> or GRASS 6.5 (wxGUI is frozen for several months in GRASS 6.4)

Nikos Alexandris:

> Yet, 65 has more bugs (in general) right? In the wiki a _discouraging_ of
> its use has been signaled [/] specifically for end-users.

right, on the other hand please note that 6.4.0 is 1.5 year in RC
stage!!! (which is unusually very long time for RC stage in which the
development of new features should be frozen). In the result e.g.
wxGUI will be quite out-dated in 6.4.0 compared to 6.5.

Thanks for the info, Nikos

On Mon, May 31, 2010 at 3:19 PM, Martin Landa <landa.martin@gmail.com> wrote:
...

right, on the other hand please note that 6.4.0 is 1.5 year in RC
stage!!! (which is unusually very long time for RC stage in which the
development of new features should be frozen). In the result e.g.
wxGUI will be quite out-dated in 6.4.0 compared to 6.5.

I hope that this will be addressed in 6.4.1 then.

IMHO the RC cycle was started too early. Well, can happen in 25+ years
of development :slight_smile:

cheers
Markus

Marcello Gorini wrote:

>- I was also under the impression, that since you tell GRASS what kind of a
script it is in the first line (*#!/usr/bin/env python*), that you don't
need to save it >as .py. Am I mistaken there?

You are also right. I renamed it without the .py extension and it worked as
well.

Windows needs the .py extension, Unix doesn't.

--
Glynn Clements <glynn@gclements.plus.com>