[Pipet Devel] Peep

deanne at density.biop.umich.edu deanne at density.biop.umich.edu
Thu Jun 1 21:03:03 EDT 2000


Last weekend, I got the basic form of peep running, which is using the
Cmd.cmd class. I've pasted a sample "dummy" session below to show you what
it'll look like. I put the code at the end. Brad helped me in choosing to
use python dictionaries instead of lists...

I was debating whether to send this to the list, since it's so damn
simple, but heck. You may not like the use of the cmd class. 

If you put in something that's not in the interpretation list
(do_<blah>) you just get a "Unknown syntax" error. If you hit return for a
blank line, it repeats the last command, though I'm sure I can override
that.

This will allow you to limit input in peep to a handful (or more) of
commands as well as include a built-in help handler. Simple and
effective...

D

Sample of peep front end
---------------------------------------

density:~/python> python peep_input.py

Welcome to Peep! Type 'help' for help.
<peep> help

Documented commands (type help <topic>):
========================================
EOF             nodelist        nodeset

Undocumented commands:
======================
help            jobscan


<peep> help nodeset 

Allows you to set the node name, number, and IP address for a
node instance. Nod e number should be an integer of where the node falls
in your process. You can r eview this with 'nodelist' (see 'help
nodelist')

<peep> nodeset

Enter the number of  the new node: 1
Enter new node type: type1
Enter the remote IP or name for this node: 121.00.00.00
Node number:  1     Node Type:  type1     Remote IP:  121.00.00.00

<peep> nodeset

Enter the number of  the new node: 2
Enter new node type: type2
Enter the remote IP or name for this node: 121.00.00.01
Node number:  2     Node Type:  type2     Remote IP:  121.00.00.01

<peep> nodeset

Enter the number of  the new node: 3
Enter new node type: type3
Enter the remote IP or name for this node: 12.1.11.0
Node number:  3     Node Type:  type3     Remote IP:  12.1.11.0

<peep> nodelist

Current Configured Nodes
------------------------
Node #    Node Type      IP address
=========================================
   1      type1       121.00.00.00
   2      type2       121.00.00.01
   3      type3       12.1.11.0
<peep> EOF
Exiting peep...
density:~/python>
--------------------------
import cmd
import sys
import string

print "Welcome to Peep! Type 'help' for help."
class Peep_Input(cmd.Cmd):

	def __init__(self):
		self.prompt = "<peep> "
		self.node_domain_num={}
                node_num=0

	def help_nodeset(self):
		print "Allows you to set the node name, number, and IP address for a node instance. Node number should be an integer of where the node falls in your process. You can review this with 'nodelist' (see 'help nodelist')"

	def do_nodeset(self,node_num):
		node_num1= raw_input("Enter the number of  the new node: ")
 		node_name = raw_input("Enter new node type: ")
 		domain_name = raw_input("Enter the remote IP or name for this node: ")
                node_num=string.atoi(node_num1)
		self.node_domain_num[node_num]=(node_num,node_name,domain_name)
		print "Node number: ", node_num, "    Node Type: ", node_name,"    Remote IP: ", domain_name

	def help_EOF(self):
		print "Quits the program."
	def do_EOF(self, line):
		print "Exiting peep..."
		sys.exit()

     	def help_nodelist(self):
		print "Gives you the list of current nodes and IP addresses."
	def do_nodelist(self,line):
		print "Current Configured Nodes"
		print "------------------------"
		print "Node #    Node Type      IP address"

		node_nums = self.node_domain_num.keys()
                if node_nums == []: return

 		node_nums.sort()

		print '='*41
		for i in node_nums:
			print "  ",self.node_domain_num[i][0],"    ",self.node_domain_num[i][1],"     ",self.node_domain_num[i][2]
                     

	def do_jobscan(self,line):
		print "Status of Current Jobs"
		print "----------------------"
		




if __name__ == '__main__':
	peep= Peep_Input()
	peep.cmdloop()



-------------
Deanne Taylor		        	     Biophysics Graduate Program
lilyth at umich.edu				University of Michigan
http://www.umich.edu/~lilyth		              Ann Arbor 	






More information about the Pipet-Devel mailing list