|
Post by vovchik on Jul 6, 2018 23:48:11 GMT 1
Dear Joe, I came across this bit on Erco's Cheat Sheet. It might just eliminate the need to determine what terminal the user might be using, since it emulates one as a widget, so the problem disappears.The compile instructions are at the top (fltk-config --compile dumbterm.cxx). And sudo can work in the demo by typing: echo mypasssword | sudo -S apt-get --help in the terminal widget, for example. With kind regards, vovchik Attachments:dumbterm.cxx.tar.gz (1.29 KB)
|
|
|
Post by bigbass on Jul 7, 2018 7:19:01 GMT 1
Hello vovchik Of course I had to add your suggestion/code ! I know we can have many uses for this so better to just get it inside as a trial and go from there Did an update of the first post added the terminal and log reader will fix how it parses the log file I will add some of Riks code in there too just sorting things out still but in the plans Thanks again vovchik (you are always so helpful) Joe
|
|
|
Post by vovchik on Jul 7, 2018 11:45:43 GMT 1
Dear Joe, Thanks. It all works nicely. I have also played with the terminal widget and have not incorporated it inot hug-fltk. It is here: hug-fltk. With kind regards, vovchik
|
|
|
Post by bigbass on Jul 8, 2018 22:50:03 GMT 1
Hey guys Got some nice formatting going for the logging of installed debs easy to read and simple updated first post with new version so easy to do with sed P.S would be nice to have BaCon a remove whole line ^starting with command Joe
|
|
|
Post by rikky on Jul 9, 2018 7:19:29 GMT 1
I think we already have a 'remove whole line' command with :
whole_text$ = DEL$(whole_text$ , pos , NL$)
EDIT: The problem with 'sed' is, that it is so incredibly illogical, that you need a lifetime to learn it, and once you haven't used it for over 2 months, you forget everything. Whereas with BaCon delimeted string manipulation , you need only a few hours on average to learn it, and it is so super logical, that you can abandon the whole thing for over 10 years, after which you need only ten minutes, to refresh your memory, and remember everything again. Or so, that is my opinion.
I've learnt 'sed' now trice, before I met BaCon, and I still cannot beak any bread from your 'sed' code.
Rik.
|
|
|
Post by vovchik on Jul 9, 2018 18:33:17 GMT 1
Dear Joe, I am glad the terminal bit was easy to incorporate. To do a sudo, without having to spawn anything, I use "echo -n mypasswd | sudo -S mycommand". There is an example in my hug version. In theory, all commands can be issued using the dumb terminal, making the application nicely self-contained. Thanks. With kind regards, vovchik
|
|
|
Post by bigbass on Jul 9, 2018 20:44:15 GMT 1
Hello Rik lets face it sed has really ugly looking syntax most of the time we agree but to be fair it can do somethings very well and I know most linux boxes have sed pre installed just so you don't think I cheated I tried with bacon first and almost got it done 90% but wasn't happy with the formatting and I knew what pattern I was looking for and it just seemed easy for me to do it in sed at the time that's all the problem was how to handle the whole line not just a matching string here is sed with comments later I will post my failed attempt doing it in pure bacon (whereas I haven't given up but just got lazy) maybe tonight I will give it another try after some more coffee Joe '--- read in log from apt EXEC$("cp /var/log/apt/term.log $PWD") '--- lets do some work with sed '--- the sed -i command lets you modify the file directly in place '--- without the need of open read file than write '--- the /d lets you do the whole line '--- get rid of the ^M from the fltk output EXEC$("sed -i 's/\r$//g' term.log") '--- remove all lines starting with Settings globally EXEC$("sed -i '/^Setting/d' term.log") '--- remove all lines starting with Processing globally EXEC$("sed -i '/^Processing/d' term.log") '--- remove all lines starting with Reading globally EXEC$("sed -i '/^(Reading/d' term.log") '--- remove all lines starting with Unpacking globally EXEC$("sed -i '/^Unpacking/d' term.log") '--- remove all lines starting with Preparing globally EXEC$("sed -i '/^Preparing/d' term.log") '--- remove all lines starting with Registering globally EXEC$("sed -i '/^Registering/d' term.log") '--- replace all lines starting with Selecting previously unselected package and '--- replace with the word INSTALLED the /g means globally EXEC$("sed -i -e 's/^Selecting previously unselected package/INSTALLED /g' term.log") MYINFILE$ = LOAD$("term.log")
|
|
|
Post by rikky on Jul 9, 2018 23:52:11 GMT 1
You're absolutely right Sed does a lot of things very well. It's just that I can not remember the sed instructions, for longer than 'say' 1 week. Apart from the sed -i 's/\r$//g' term.log For which I could not figure out what it means, exactly something like this. term_log$ = LOAD$("/var/log/apt/term.log") new_term_log$ = "" FOR this_line$ IN CHOP$(term_log$) STEP NL$ FOR this_word$ IN "Setting Processing Reading Unpacking Preparing Registering" IF HEAD$(this_line$,1) = this_word$ THEN CONTINUE 2 END IF NEXT this_word$ new_term_log$ = new_term_log$ & this_line$ & NL$ NEXT this_line$ term_log$ = REPLACE$(new_term_log$,"Selecting previously unselected package","installed") PRINT term_log$ Rik.
|
|
|
Post by vovchik on Jul 10, 2018 10:02:47 GMT 1
Dear Joe and Rik,
Or maybe just grab what is needed, rejecting everything else by default, as here:
log$ = CHOP$(LOAD$("/var/log/apt/term.log")) & NL$ mystring$ = "Selecting previously unselected package" FOR myline$ IN log$ STEP NL$ IF INSTR(myline$, mystring$) THEN new_log$ = new_log$ & REPLACE$(myline$, mystring$, "INSTALLED:") & NL$ END IF NEXT myline$ PRINT new_log$
With kind regards, vovchik
|
|
|
Post by bigbass on Jul 11, 2018 7:28:34 GMT 1
Thanks Rik and vovchik
Its always nice to see how someone else would go about solving a problem and seeing things from a different angle
I always prefer right to the point code when possible and would go the short route that vovchik did however if we comply with the date stamp we need to add more code really I dont need the date stamp anyway thanks
P.S the ugly part
sed -i 's/\r$//g' term.log
for some odd reason fltk in the display we get the ^M character which is a microsoft carriage return then a new line \r\n
so to get rid of the carriage return I used the reading it from right to left // replace with nothing g globally
line ending with $ a short hand symbol \r
vovchik did a clever work around by chopping of the \r\n the appending a NL$ which is a neat trick haven't tested that in fltk yet but should work
log$ = CHOP$(LOAD$("/var/log/apt/term.log")) & NL$
Joe
|
|
|
Post by bigbass on Jul 14, 2018 15:30:04 GMT 1
Hello Guys
Just added a package info for the package selected in the checkbox and small code clean ups
main post updated
Joe
|
|
|
Post by bigbass on Jul 28, 2018 23:29:00 GMT 1
Hey Guys
Hello Rik you commented about the dependencies of bacon and fltk being needed before installing the GUI app and its best we cover all the bases and have a pre-step script most likely no one would really need it (except myself I always boot clean ) but just to save time and have a fallback plan
Thanks for your code snippets and suggestions and also I cant test on the RPI3 to confirm anything so thanks for the feedback
simple but gets the job done
replace header with #!/bin/bash
Joe
|
|
|
Post by rikky on Jul 29, 2018 6:01:34 GMT 1
I see, test " $result_MY_OS" gives " armhf", and there isn't any debian package for it. I have adapted a little bacon_install_script with your sed and cut routine, which saved me over half of the size of the program, and I am sure that you can shorten the other half also with your sed and cut and awk skills. Hope it works. The post install part, especially the Geany post install is buggy. I had it all sorted out, but somehow lost it, and did not find the time yet. Sorry. if test "$result_MY_OS" == "armhf" ; then
apt-get install enscript -y apt-get install xterm -y apt-get install indent -y apt-get install libfltk1.3 -y
baconversion_raw=`curl -s http://www.basic-converter.org/stable/ | grep "tar.gz" | sed -e 's/<[^>]*>//g' | cut -f1 -d " "` cd /tmp echo "downloading remote package name : $baconversion_raw" wget -c "http://www.basic-converter.org/stable/$baconversion_raw" [ ! $? = 0 ] && echo " error downloading package" && exit 1 echo done echo "unpacking $baconversion_raw ... " tar -zxf $baconversion_raw [ ! $? = 0 ] && echo " error unpacking package" && exit 1 echo done
# works always ??? , can hardly believe it. length=${#baconversion_raw} length=$((length-7)) myfolder=${baconversion_raw:0:$length}
echo entering $(pwd)/${myfolder} [ -d $(pwd)/${myfolder} ] || ( echo "error : folder $myfolder doesnt exist" ; exit 1 )
cd $myfolder pwd ./configure [ ! $? = 0 ] && ( echo "error in configure" ; exit 1 ) make [ ! $? = 0 ] && ( echo "error in make" ; exit 1 )
sudo make install && echo "error in make install"
cd ./syntax sudo mkdir -p /usr/share/enscript/hl/ sudo cp ./bacon.st /usr/share/enscript/hl/ mkdir -p ~/.local/share/gtksourceview-2.0/language-specs/ cp ./bacon.lang ~/.local/share/gtksourceview-2.0/language-specs/ # should work, do this the next version # unfortunately the folowwings do not work on the pi # Do they have to go to the /usr/share/geany ?? cd ./geany cp ./filetype_extensions.conf /home/pi/.config/geany/filedefs/ cp ./filetypes.BaCon.conf /home/pi/.config/geany/filedefs/
echo echo "all done."
fi
Rik.
|
|
|
Post by bigbass on Jul 29, 2018 7:45:55 GMT 1
Hello Rik Thanks for posting the RPI code part I have to buy one of those someday!
will add your RPI routine to the pre-install script
just a personal habit ./configure --prefix=/usr
Joe
|
|
|
Post by vovchik on Jul 29, 2018 14:25:09 GMT 1
Dear Joe,
Thanks. I also prefer "./configure --prefix=/usr". About those genie config files that Rik mentions - I don't know exactly but end up copying them locally and in /usr/share/geany.
With kind regards, vovchik
|
|