Re: calling python procedures from tcl using tclpython

2005-07-07 Thread chand
That is exactly i want to know. i.e...,how to provide the python code
path in tcl script file, that loads required function.

--BestRegards.,
--chandra

> definitions etc.

Michael Schlenker wrote:
> chand wrote:
> > Hi..
> >
> > I am writing a Gui in TCL and my backend code is python. I want to call
> > python procedure in tcl using tclpyhton. I want to know clearly how
> > this should be implemented.
> >
> > let's say I have procedure test_function(arg1,arg2 ...) defined in
> > test.py.
> > I want to call this procedure in tcl. Let me know how this should be
> > achieved.
> > The doubt basically have is how the tcl code knows in which .py file
> > this procedure is defined.
> >
> > currently I have wriiten this tcl code which is not working
> >
> > package require tclpython
> > set interpreter [python::interp new]
> > $interpreter eval {def test_function(): arg1,arg2} ;
> > python::interp delete $interpreter
> >
> What does not work? You never load your file test.py anywhere inside,
> you just evaluate 'def test_function(): arg1,arg2' so what are you
> expecting to happen?
>
> Your call to '$interpreter eval' lets you call arbitrary python code,
> but you have to provide the python code that loads your function
> definitions etc. I don't know python, but it should be a trivial code.
> 
> Michael

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: calling python procedures from tcl using tclpython

2005-07-07 Thread chand
Hi.,

can anyone help me how to provide the info about the python file
procedure in the tcl script which uses tclpython i.e., is there a way
to import that .py file procedure in the tcl script


--BestRegards
--Chandra

Michael Schlenker wrote:
> chand wrote:
> > Hi..
> >
> > I am writing a Gui in TCL and my backend code is python. I want to call
> > python procedure in tcl using tclpyhton. I want to know clearly how
> > this should be implemented.
> >
> > let's say I have procedure test_function(arg1,arg2 ...) defined in
> > test.py.
> > I want to call this procedure in tcl. Let me know how this should be
> > achieved.
> > The doubt basically have is how the tcl code knows in which .py file
> > this procedure is defined.
> >
> > currently I have wriiten this tcl code which is not working
> >
> > package require tclpython
> > set interpreter [python::interp new]
> > $interpreter eval {def test_function(): arg1,arg2} ;
> > python::interp delete $interpreter
> >
> What does not work? You never load your file test.py anywhere inside,
> you just evaluate 'def test_function(): arg1,arg2' so what are you
> expecting to happen?
>
> Your call to '$interpreter eval' lets you call arbitrary python code,
> but you have to provide the python code that loads your function
> definitions etc. I don't know python, but it should be a trivial code.
> 
> Michael

-- 
http://mail.python.org/mailman/listinfo/python-list


Warning when doubly linked list is defined gloablly

2005-08-24 Thread chand
Hi.,

In my api.py file 'g_opt_list' is defined globally
g_opt_list =[[],[],[],[],[],[],[]]

I am using this global list in the fucntion

def function ():
gloabl g_opt_list

when I run the py file, I am getting the Following Error

SyntaxWarning: name 'g_opt_list' is used prior to global declaration

Please let me know how to remove this error

--BestRegars.,
--Chandra

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Warning when doubly linked list is defined gloablly

2005-08-30 Thread chand
pts(layer_name,add_delete_flag,param_name):
global index
global g_opt_list
#param_name = "Null"
List =
Message_obj.showOptionalParameters(layer_name,add_delete_flag,"Null")
if (len(List)== 0)  :
return "None"

displayoptparams(List,layer_name,add_delete_flag,Message_obj._message_name)
if param_name == 'Null':
for i in g_opt_list[int(index)]:
if g_opt_list[int(index)].count(i) == 1:
optList =
Message_obj.showOptionalParameters(layer_name,add_delete_flag,i)
displayoptparams(optList,layer_name,0,"Null")
add_delete_flag = 1
return "None"



def main():

#choice = sys.argv[1]
print "### choice ",
#Process_GUI_Command("NEW")
#list=CMSR.showOptionalParameters("SCCP",0)
#CMSR.saveXMLfile("CMSR2.xml","CMSR")


if __name__ == '__main__':
main()


--Thanks and bestregards.,
--Chandra

Terry Reedy wrote:
> "chand" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi.,
> >
> > In my api.py file 'g_opt_list' is defined globally
> > g_opt_list =[[],[],[],[],[],[],[]]
> >
> > I am using this global list in the fucntion
> >
> > def function ():
> >gloabl g_opt_list
> >
> > when I run the py file, I am getting the Following Error
> >
> > SyntaxWarning: name 'g_opt_list' is used prior to global declaration
> >
> > Please let me know how to remove this error
>
> To expand slightly on previous answers:
>
> 1. Write a *minimal* file that gives you the error.  This means that
> removing any statement ceases to give you the error.  This may answer your
> questions.
>
> 2. If still puzzled, post again.  But cut and paste that *exact* file and
> also the *full* error traceback.
> 
> Terry J. Reedy

-- 
http://mail.python.org/mailman/listinfo/python-list


warning when doubly liked list is defined globally

2005-09-05 Thread chand
Hi.,

In my api.py file 'g_opt_list' is defined globally
g_opt_list =[[],[],[],[],[],[],[]]

when I run the py file, I am getting the Following Error

SyntaxWarning: name 'g_opt_list' is used prior to global declaration

Please let me know how to remove this error

Here is the code which gives the error...

Let me know exact reason for this Error and how to remove this
warning..

import os,sys,re,string,math
from xml.dom import minidom, Node
from Layer import Layer
from LMessage import *
from Param import *
from Message import *
from message_mapping import *
from protocol_mapping import *
from symbol_mapping import *
from opt_list_mapping import *
g_del_opt_list =[[],[],[],[],[],[],[]]
sflag = 0
index=0
del_index=0
radflag = 0
depth = 0
xmlflag = 0
opt_param_list = []
del_opt_param_list = []
#g_opt_list = []
MTAS_HOME="/home/chandras/XML_FILES/"
SIG_STANDARD_HOME = "/home/chandras/SIGNALLING_STANDARD/ANSI_SS7/"
symbols=['(',')','{','}','[',']','.']
reverse_symbols=['<','>','~']
layers=['MTP3','SCCP','IOS','CDTAPM2','CDTAPC2','ISUP','IS-41D-SQA']
GUI_API_COMMAND_LIST = [
"NEW",
"ADD_OPTIONAL_PARAM",
"DELETE_OPTIONAL_PARAM",
"DELETE_LAYER",
"RENAME"
]
BASE2 = "01"
BASE10 = "0123456789"
BASE16 = "0123456789ABCDEF"

Message_obj = Message()
filename =""
buffer = []
#LIST = []
def Process_GUI_Command(arg):
global Message_obj
global filename
print "### COMMAND ###", arg[0]
save_fd = os.dup(1)
if arg[0] ==  "DELETE_OPTIONAL_PARAM":
out_file = file('/tmp/te6.txt', 'w+')
elif arg[0] ==  "ADD_OPTIONAL_PARAM":
out_file = file('/tmp/te3.txt', 'w+')
else :
out_file = file('/tmp/te.txt', 'w+')
os.dup2(out_file.fileno(), sys.stdout.fileno())


if  arg[0]  ==  "NEW" :
global g_opt_list
Message_obj = Message()
layerList = listLayers("ANSI_Layers")
layerList = str(layerList)
layerList = layerList.replace(",","")
for i in range(0,len(g_opt_list)):
g_opt_list[i] = []
os.dup2(save_fd, 1)
return layerList


  elifarg[0]  ==   "ADD_OPTIONAL_PARAM" :
global g_opt_list
global layers
global index
message_name = ""
layer_name   = arg[1]
#print "Layer Name", layer_name
for layer in layers:
if layer == layer_name:
if
OPT_LIST_MAPPING.has_key(layer_name):
index =
OPT_LIST_MAPPING[layer_name]
break if arg[2] != 'Null':
optional_parameter_name =
str(arg[2]).replace("+",",")
for symbol in reverse_symbols:
if symbol in optional_parameter_name:
if
SYMBOL_REVERSE_MAPPING.has_key(symbol):
old_symbol =
SYMBOL_REVERSE_MAPPING[symbol]
optional_parameter_name
=optional_parameter_name.replace(symbol,old_symbol)


Message_obj.AddParam(message_name,layer_name,optional_parameter_name )
else : optional_parameter_name= 'Null'

add_delete_flag = 0
  param_name = optional_parameter_name
show_opts(layer_name,add_delete_flag,param_name)
if int(add_delete_flag) == 0:
add_delete_flag = 0
if  optional_parameter_name != "Null":
optList =
Message_obj.showOptionalParameters(layer_name,add_delete_flag,optional_parameter_name)

g_opt_list[int(index)].append(optional_parameter_name)
for i in g_opt_list[int(index)]:
if
g_opt_list[int(index)].count(i) == 1:
optList =
Message_obj.showOptionalParameters(layer_name,add_delete_flag,i)

displayoptparams(optList,layer_name,0,"Null")
i= "Null"
optional_parameter_name = "Null"
add_delete_flag = 1

os.dup2(save_fd, 1)
else:
print "Invalid Option"


def  show_opts(layer_name,add_delete_flag,param_name):
global index
global g_opt_list
#param_name = "Null"
List =
Message_obj.showOptionalParameters(layer_name,add_delete_flag,"Null")
if (len(List)== 0)  :
return "None"

displayoptparams(List,layer_name,add_delete_flag,Message_obj._message_name)
if param_name == 'Null':
for i in g_opt_list[int(index)]:

Re: Warning when doubly linked list is defined gloablly

2005-09-05 Thread chand
 global index
global g_opt_list
#param_name = "Null"
List =
Message_obj.showOptionalParameters(layer_name,add_delete_flag,"Null")
if (len(List)== 0)  :
return "None"

displayoptparams(List,layer_name,add_delete_flag,Message_obj._message_name)
if param_name == 'Null':
for i in g_opt_list[int(index)]:
if g_opt_list[int(index)].count(i) == 1:
optList =
Message_obj.showOptionalParameters(layer_name,add_delete_flag,i)

displayoptparams(optList,layer_name,0,"Null")
add_delete_flag = 1
return "None"



def main():

#choice = sys.argv[1]
print "### choice ",
#Process_GUI_Command("NEW")
#list=CMSR.showOptionalParameters("SCCP",0)
#CMSR.saveXMLfile("CMSR2.xml","CMSR")

if __name__ == '__main__':
main()






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































chand wrote:
> Hi.,
>
> In my api.py file 'g_opt_list' is defined globally
> g_opt_list =[[],[],[],[],[],[],[]]
>
> I am using this global list in the fucntion
>
> def function ():
> gloabl g_opt_list
>
> when I run the py file, I am getting the Following Error
>
> SyntaxWarning: name 'g_opt_list' is used prior to global declaration
>
> Please let me know how to remove this error
> 
> --BestRegars.,
> --Chandra

-- 
http://mail.python.org/mailman/listinfo/python-list


warning when doubly liked list is defined globally

2005-09-14 Thread chand
Hi.,

In my api.py file 'g_opt_list' is defined globally
g_opt_list =[[],[],[],[],[],[],[]]

when I run the py file, I am getting the Following Error

SyntaxWarning: name 'g_opt_list' is used prior to global declaration
SyntaxWarning: name 'layers' is used prior to global declaration

Please let me know how to remove these warnings.

I found that commenting 'g_opt_list' initialisation in "NEW" command
removes this warning message. But my requirement is that i want to
reset g_opt_list to empty list, whenever "NEW" command is called.


Here is the code which gives the error...

I have removed most of the unwanted code to reduce the size.

Let me know exact reason for this warning  and how to remove these
warnings..




import os,sys,re,string,math
g_opt_list =[[],[],[],[],[],[],[]]
SIG_STANDARD_HOME = "/home/chandras/SIGNALLING_STANDARD/ANSI_SS7/"
symbols=['(',')','{','}','[',']','.']
reverse_symbols=['<','>','~']
layers=['MTP3','SCCP','IOS','CDTAPM2','CDTAPC2','ISUP','IS-41D-SQA']

GUI_API_COMMAND_LIST = [
"NEW",
"ADD_OPTIONAL_PARAM",
]

Message_obj = Message()
def Process_GUI_Command(arg):
global Message_obj
global filename
out_file = file('/tmp/te.txt', 'w+')

if  arg[0]  ==  "NEW" :
global g_opt_list
for i in range(0,len(g_opt_list)):
g_opt_list[i] = []
return layerList

elifarg[0]  ==   "ADD_OPTIONAL_PARAM" :
global g_opt_list
global layers
global index
message_name = ""
add_delete_flag = 0

param_name = optional_parameter_name
g_opt_list[int(index)].append(optional_parameter_name)



def main():

print "### choice ",

if __name__ == '__main__':
main()

-- 
http://mail.python.org/mailman/listinfo/python-list


Removing Warning Messages .............

2005-09-19 Thread chand
Hi.,

In my api.py file 'g_opt_list' is defined globally
g_opt_list =[[],[],[],[],[],[],[]]

when I run the py file, I am getting the Following Error

SyntaxWarning: name 'g_opt_list' is used prior to global declaration
SyntaxWarning: name 'layers' is used prior to global declaration

Please let me know how to remove these warnings.

I found that commenting 'g_opt_list' initialisation in "NEW" command
removes this warning message. But my requirement is that i want to
reset g_opt_list to empty list, whenever "NEW" command is called.

Here is the code which gives the error...

I have removed most of the unwanted code to reduce the size.

Let me know exact reason for this warning  and how to remove these
warnings..

import os,sys,re,string,math
g_opt_list =[[],[],[],[],[],[],[]]
SIG_STANDARD_HOME = "/home/chandras/SIGNALLING_STANDARD/ANSI_SS7/"
symbols=['(',')','{','}','[',']','.']
reverse_symbols=['<','>','~']
layers=['MTP3','SCCP','IOS','CDTAPM2','CDTAPC2','ISUP','IS-41D-SQA']

GUI_API_COMMAND_LIST = [
"NEW",
"ADD_OPTIONAL_PARAM",
]

Message_obj = Message()
def Process_GUI_Command(arg):
global Message_obj
global filename
out_file = file('/tmp/te.txt', 'w+')

if  arg[0]  ==  "NEW" :
global g_opt_list
for i in range(0,len(g_opt_list)):
g_opt_list[i] = []
return layerList

elifarg[0]  ==   "ADD_OPTIONAL_PARAM" :
global g_opt_list
global layers
global index
message_name = ""
add_delete_flag = 0

param_name = optional_parameter_name

g_opt_list[int(index)].append(optional_parameter_name)

def main():

print "### choice ",

if __name__ == '__main__':
main()

-- 
http://mail.python.org/mailman/listinfo/python-list