Site Sponsors:
LTM on Godaddy (CentOS 6 : Tomcat 6 : MySQL 5.5) 
NOTE: GODADDY Cloud Servers GONE as of December 31, 2017.

In as much as it is now extremely affordable to toss server installs around in-the-cloud, we decided to set up a Linux, Tomcat & MySQL (LTM) stack on CentOS.

Why CentOS, you might ask?

Easy: Those SCLs make the job far too easy!

Here is what we had to do:
    sudo bash
yum install centos-release-SCL
yum update
yum install mysql55
yum update
yum -y install tomcat6 tomcat6-webapps tomcat6-admin-webapps
yum update
Thereafter, editing /etc/tomcat6/tomcat-users.xml to add an 8080 login:
  <role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="admin" roles="admin,manager"/>
... followed by ...
    service tomcat6 start
Worked great!

Also, if your browsing to 8080 did not work (mine did - just had to wait for a 'few the first time! (Java ... ... ... yo!)), then don't forget to unblock those ports!


For those who are convinced that they will need access to MySQL under Tomcat:
    yum -y install mysql-connector-java

[ view entry ] ( 617 views )   |  permalink  |  related link
Tomcat 7 on Ubuntu 
NOTE: GODADDY Cloud Servers GONE as of December 31, 2017

In an earlier post I mentioned that - while capable - that AWS was a box of frogs. While we might wonder aloud as we hear-tell of what is bumping around inside, once the 'pandora has been braved one will surely crave a far more native-English way of getting things done!

So it was with no little trepidation that I created a cloud server on GoDaddy today. While the prohibition on the static IP address remains, please allow me to report that - for a mere $5 a month - that the Open Stack experience is presently far, far easier to work with.

For those of you whom might be wanting to get Tomcat7 up and running on Ubuntu, please note that doing so was a breeze!

sudo bash
apt-get update
apt-get install openjdk-7-jdk
apt-get update
javac # Just for laughs ...
apt-get install tomcat7
apt-get update

Thereafter, editing /etc/tomcat7/tomcat-users.xml to add those 8080 login-roles worked after Tomcat was restarted, as usual.

When it came time to switch from the default port of 8080 however, try as I might there was no way to do so without re-directing the port. Even that classical:
nano /etc/default/tomcat7
~ changed to ~

As well as:
nano /etc/default/server.xml
~ changed to ~

Followed by the obligatory:
sudo /etc/init.d/tomcat7 restart

-as well as a server reset or three, simply did not work as expected on 14.04 LTS. (*)

For those facing a similar conundrum, note that port mapping was one way to get the job done:

/sbin/iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT

/sbin/iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT

/sbin/iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

While I feel certain that there is a far, far better way to get the job done, so far forwarding ports at the iptable-level is the best way to map Tomcat's default (and much beloved :) port 8080 over to 80 on my new 'experimentals.

Ultimately, never forget to
shutdown -r 0
-as your user community permits!

Sharing is caring,


p.s: CentOS / RedHat users can do this.

(*) NOTE: authbind works only with IPv4. Do not enable it when using IPv6.

[ view entry ] ( 491 views )   |  permalink  |  related link
Paginated item-picker for console listings in Python 3 
Adding to the critical mass of things that many want to do - yet cannot find a nice example on how to do - submitted for your approval please find a little class I chose to call PrintPickerList:

Opportunity to support the pagination of a list so
as to allow a console user to select an item therefrom.

class PrintPickerList:

def __init__(self, array=[]):
Initilize the class for assignment

:return: An item with an empty list
self.last_selection = -1
self.pages = array
self.page_size = 20

def use_list(self, zlist, szpage=20):
:param zlist: a list() full of string items to choose from
:param szpage: The size of the page to scroll around.
:return: True if all was well
if type(zlist) is not type(self.pages):
return False
self.last_selection = -1
self.pages = zlist
self.page_size = szpage
return True

def print_header(self):
An opportunity to print a column header - called once per page view
:return: Nothing

def print_item(self, zbss):
The default row-printing logic. Feel free to use inheritance to replace
and / or otherwise update this vector as you require / desire

:param zbss: The zero-based subscript of the item to print.
:return: Nothing
print("{0:02d}:\t[{1:^50}]".format(zbss+1, self.pages[zbss]))

def pick_item(self):
Allow the console user to page up and down thru list,
looking for an item to select. Once selected, the
array-adjusted element number will be returned.

:return: Array-subscript selected. -1 if no item was selected.
page = 0
max = len(self.pages)
if max == 0:
return -1

while True:
for item in range(page, max):
nzi = item + 1
if nzi % self.page_size == 0:
print("p = prev, n = next, q = quit, `n` = choice")
sel = input("Enter selection: ").strip()
if sel.isnumeric():
self.last_selection = -1 # jic
sel = int(sel)

self.last_selection = sel
self.last_selection -= 1 # array is n-1
if sel == 'p':
page -= self.page_size
if sel == 'n':
page += self.page_size
if sel == 'q':
self.last_selection = -1 # Done - no selection

except Exception as ex:

while page >= max:
page -= self.page_size
if page < 0:
page = 0

# Clean-up the results:
if self.last_selection >= max:
self.last_selection = max - 1
if self.last_selection is not -1 and self.last_selection < 0:
self.last_selection = 0
return self.last_selection

if __name__ == '__main__':
doc = list()
for ref in range(100):
doc.append("Selection number" + str(ref))
pager = PrintPickerList()
if pager.use_list(doc) is False:
print("Big problem")
sel = pager.pick_item()
selected = "No item selected."
if sel is not -1:
selected = doc[sel]
print("You selected '" + selected + "'")

The 'docstrings pretty much say it all. Yet allow us to note that we can paginate many other types - as well print column headers - by either updating, and / or inheriting + overriding:

    def print_header(self):

def print_item(self, zbss):
print("{0:02d}:\t[{1:^50}]".format(zbss+1, self.pages[zbss]))

So if you have ever wanted to allow a user to scroll thru a large list of items - certainly if that list is far too large to readily fit on the screen - then you might enjoy putting PrintPickerList to work in your own Pythonic masterpieces. --It's 'kinda like having a more++ for use from within the Python console 'ui.

Enjoy the journey,



[ view entry ] ( 432 views )   |  permalink

<<First <Back | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Next> Last>>