RE: Dealing with apos; (suds)

2013-06-21 Thread Ombongi Moraa Fe
Hello,

I'm working with suds to send send messages to smsc. I've notices the
messages with apos; are really not processed on my side (which could mean
an error occurs somewhere - most probably in my php script). SMSC has also
asked that I 'take care of the apos;' as it's the reason my subscribers
may not be receiving the responses.

How can i 'take care of apos; ' so it doesn't give me problems in future?

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


RE: Passing special characters in soap data

2013-04-30 Thread Ombongi Moraa Fe
Hi Team,

My provider sends soap data to me as they receive from subscriber. as
expected the messages with special characters like quotes are received as
html entities.

like the message below had a quote:

?xml version=1.0 encoding=utf-8 ?soapenv:Envelope
...messageIapos;ll shape it up myself/message...
/soapenv:Body/soapenv:Envelope


Since i pass this data into my python script as a command line call, i get
the error:

/bin/sh: Syntax error: Unterminated quoted string



how can i resolve this and any other html entities i receive?

Saludos

Ombongi Moraa Faith
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: xml.etree.ElementTree if element does not exist?

2013-04-29 Thread Ombongi Moraa Fe
Good Afternoon,

Among other elements values that my script finds is value for sepid

sepid = content.find(.//{http://www.huawei.com.cn/schema/common/v2_1}sepid
).text


however, if i pass xml data that DOES NOT contain sepid element, i get an
error:

Traceback (most recent call last):
  File /usr/local/bin/receive.py, line 21, in module
sepid = content.find(.//{
http://www.huawei.com.cn/schema/common/v2_1}sepid;).text
AttributeError: 'NoneType' object has no attribute 'text'


some messages i receive will have the sepid parameter, other will not have
this parameter. How can i cater for this? kinda like an if .. else
implementation for xml.etree.ElementTree  ?



Thanks in advance.

Saludos

Ombongi Moraa Faith
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xml.etree.ElementTree if element does not exist?

2013-04-29 Thread Ombongi Moraa Fe
Hi Stefan, Group

Thanks for the thumbs up.

Worked perfectly.

Saludos

Ombongi Moraa Faith


On 29 April 2013 14:22, Stefan Holdermans ste...@vectorfabrics.com wrote:

 Ombongi,

  however, if i pass xml data that DOES NOT contain sepid element, i get
 an error:
 
  Traceback (most recent call last):
File /usr/local/bin/receive.py, line 21, in module
  sepid = content.find(.//{
 http://www.huawei.com.cn/schema/common/v2_1}sepid;).text
  AttributeError: 'NoneType' object has no attribute 'text'
 
 
  some messages i receive will have the sepid parameter, other will not
 have this parameter. How can i cater for this? kinda like an if .. else
 implementation for xml.etree.ElementTree  ?

 What about simply testing whether the value returned by find is None? For
 example:

   $ cat test.py
   from xml.etree import ElementTree

   myTree = ElementTree.fromstring('test /')
   myElement = myTree.find('orange')

   if myElement is None:
   print 'tree does not contain a child element orange'
   else:
   print myElement.text


   $ python test.py
   tree does not contain a child element orange

 HTH,

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


RE: subprocess.call

2013-04-19 Thread Ombongi Moraa Fe
Hi Team,

In my python script, I have this:

command=lynx -dump
'phpscript?param1=%sparam2=%sparam3=%sparam4=%sparam5=%s'%(value1,value2,value3,value4)

result=subprocess.call(command,shell=True)
print 'xml message'

However, the response from running the php script is also printed on output
screen. I don't want this output.

How can i ensure that only the last print 'xml response' is returned?

Saludos

Ombongi Moraa Faith
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing soap result

2013-04-18 Thread Ombongi Moraa Fe
Hi Burak, Team,

Your solution worked perfectly thanks.

Could you share the logic of this solution?

Saludos

Ombongi Moraa Faith


On 18 April 2013 00:41, Burak Arslan burak.ars...@arskom.com.tr wrote:

  On 04/17/13 16:50, Ombongi Moraa Fe wrote:

  My

 client.service.gere(ri)

 method call logs the below soap response in my log file.

 ?xml version=1.0 encoding=utf-8 ?soapenv:Envelope xmlns:soapenv=
 http://schemas.xmlsoap.org/soap/envelope/; xmlns:xsi=
 http://www.w3.org/2001/XMLSchema-instance;soapenv:Bodyns1:gere
 xmlns:ns1=http://www.csapi.org/schema/parlayx/sms/send/v2_2/local
 ns1:resultaddress254727/addressdeliveryStatusDeliveredToNetwork/deliveryStatus/ns1:result/ns1:gere/soapenv:Body/soapenv:Envelope


  If I assign the client.service.gere(ri) to a variable, i get the output
 on my screen:

 result=client.service.gere(ri)

 output:
 [(DeliveryInformation){
address = 254727
deliveryStatus = DeliveredToNetwork
  }]

  string functions replace() and strip don't work.

 how do I use xml.etree.ElementTree to print the parameters address and
 deliveryStatus? Or is there a better python method?


 hi,

 try:

 result[0].deliveryStatus

 or

 result[0].DeliveryInformation.deliveryStatus


 and let us know.

 best,
 burak


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


Parsing soap result

2013-04-17 Thread Ombongi Moraa Fe
My

client.service.gere(ri)

method call logs the below soap response in my log file.

?xml version=1.0 encoding=utf-8 ?soapenv:Envelope xmlns:soapenv=
http://schemas.xmlsoap.org/soap/envelope/; xmlns:xsi=
http://www.w3.org/2001/XMLSchema-instance;soapenv:Bodyns1:gere
xmlns:ns1=http://www.csapi.org/schema/parlayx/sms/send/v2_2/local
ns1:resultaddress254727/addressdeliveryStatusDeliveredToNetwork/deliveryStatus/ns1:result/ns1:gere/soapenv:Body/soapenv:Envelope


If I assign the client.service.gere(ri) to a variable, i get the output on
my screen:

result=client.service.gere(ri)

output:
[(DeliveryInformation){
   address = 254727
   deliveryStatus = DeliveredToNetwork
 }]

string functions replace() and strip don't work.

how do I use xml.etree.ElementTree to print the parameters address and
deliveryStatus? Or is there a better python method?

Thanks in advance.

Saludos

Ombongi Moraa Faith
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Iterating dictionary items + if statement results in problems

2013-04-15 Thread Ombongi Moraa Fe
hello Team,

I have this fairly simple script to iterate the dictionary items and check
if the items match certain values;

dictionary={'1234567890':001, '0987654321':002}
for k, v in dictionary.iteritems():
.
.  #suds client statements;

if (k == '1234567890' and v == 001):
criteria='Test'
elif (k == '0987654321' and v == 002):
criteria='Running'
client.service.methodcall(value1,value2,criteria)



During the first run of the dictionary items, the client.service.methodcall
is called only once as expected; and a success initiation response is
received from server. However, during the second run, the
client.service.methodcall is called twice - when i check the log files, i
see the client send request is done twice. Duplicate send requests of the
same parameters results in a error in inititating a connection.

Someone please show me why my second run results in the
client.service.methodcall() running twice. I can't seem to get a hang on
it.

Saludos

Ombongi Moraa Faith
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iterating dictionary items + if statement results in problems

2013-04-15 Thread Ombongi Moraa Fe
Hello Team,

Thanks for your input.

|Possibly it's not matching because of your mistaken use of octal.  Octal
won't hurt for ints below 8, but you probably don't restrict it in the real
code.  For example,  v = 030 will not match equal in the following:

I've changed the key,value pairs in the dictionary because of privacy
commitment with my provider;

|My guess is that this is not your actual code at all, and you're trying to
simplify it for us.  You probably have more than |two items in the dict,
and one of them is NOT matching any of the if/elif tests.

Currently, I only have 2 items in the dictionary. However, this
is a test environment and in the product environ, my items will be as many
as the number of services created on server for my connection. Currently,
the production has 10 services (key,value pairs)

I will only have a set number of key,value pairs and I cannot use other
items outside this range. The connection to providerr wouldn't be establish
for anything out of the allowed item ranges;

|That's not the whole script, since at the least, you need some code to
import or create client, value1 and value2.

The other portion of script to import the client and get values of
parameters value1 and value2 works well. I have tested the script without
using dictionaries by manually changing the items within the dictionary,
inside the code and it works successfully, establishing a connection for
both items; Now I need to iterate this for the sake of numerous items in
the production environment. And that's where I thought to bring in the if
statement.

|What makes you think there should be one call given the code above?
client.service.methodcall must be called for every |loop iteration, so
there's one call with criteria 'test' and one with 'Running'.  Note there's
no guarantee that the calls will |always take place in the same order.

Yes, I do understand that the items in the dictionary are not ordered. And
what I expect is one call with criteria 'Test' and one with 'Running'. From
my logs file, the duplicate call always occurs at the last iteration of the
dictionary items.

In short, my problem arises after I include the if statement inside the
loop. I am new to python but I am pretty sure my program syntax is correct
here. If I run  a print statement instead of the
client.service.methodcall(value1,
value2), my output is just

Test
Running

2 of the services in the production environment will require the criteria
value. For the rest of the services, the method call will simply be

client.service.methodcall(value1, value2)

I need this criteria value in order to establish a service specific
connection for these 2 matching key,value pairs; instead of a generalised
connection as will be the case for any additional keys.this is where the
else default statement will come in later on. Right now I need to be able
to resolve the problem with my script as-it-is (with 2 dictionary items)

Thanks in advance.


Saludos

Ombongi Moraa Faith
-- 
http://mail.python.org/mailman/listinfo/python-list


Return a value from a function result

2013-04-11 Thread Ombongi Moraa Fe
Hello Team,

My perl script a.pl calls python script b.py and passes arguments to
it; expecting a return value;

b.py uses suds to facilitate soap-based communication with another server
which then returns some value (deliveryStatus)

basically, my b.py script has these 3 major parts;

#part 1 of code to receive arguments from perl script and process them
accordingly
..
.
#part 2 of code - function to get delivery status
def deliveryStatus():
   .
   return parameters # or return client.last_received()

#part 3- print output of the function
print deliveryStatus()



running b.py script with the return parameters  prints this output:

[(DeliveryInformation){
   address = phone_number
   deliveryStatus = DeliveredToNetwork
 }]


running the same script with   return client.last_received()  instead
prints the soap output

?xml version=1.0 encoding=UTF-8?
soapenv:Envelope
   soapenv:Body
  ns1:deliveryStatusResp
 ns1:result
addressphone_number/address
deliveryStatusDeliveredToNetwork/deliveryStatus
 /ns1:result
  /ns1:deliveryStatusResp
   /soapenv:Body
/soapenv:Envelope


With either kind of output returned to my perl script, my table entry is
updated as failed since the returned value is basically an undefined
value; what I need therefore is a way to return only the value
DeliveredToNetwork so that the database update on my perl script could be
correct; A solution using either the soap output or the array output will
be appreciated.

Someone help me. Thanks in advance.


Saludos

Ombongi Moraa Faith
-- 
http://mail.python.org/mailman/listinfo/python-list


Passing soap response to python script

2013-04-05 Thread Ombongi Moraa Fe
Hello Group,

I am newbie to python and getting my way around. However, my first project
that introduced me to the language deals with SOAP requests.

The server I communicate with basically sends me 2 soap responses; One with
a requestIdentifier which I should use to query the delivery status of the
message originally sent. Therefore, my main.py script already calls the
client.last_received() which contains 1 value for requestIdentifier.

I have another script getDelivery.py; In this script I need to pass 6
parameters which we used in the main.py script and add the
requestIdentifier parameter - total 7 paramters.

I want to call the getDelivery.py script at the end of main.py script after
the client.last_received().

q1) How do I get the requestIdentifier parameter that is received through
the client.last_received() method call?

q2)  How do I pass these 7 parameters to the method call from the main.py
script?

q3) And how do I receive these passed parameters in the getDelivery.py
script?

I am conversant with the php post/get but still having trouble doing the
same in python. I've checked on urllib2 and request modules but still
having trouble understanding their implementation.

Thanks In Advance/


Saludos

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


Re: Passing soap response to python script

2013-04-05 Thread Ombongi Moraa Fe
Hi Burak,

Thanks a lot.

I've been working with suds in this project and I am amazed at how much
little code I am using compared to my original php scripts;

from your answer, I realized my major headache was not assigning the value
of client.last_received method call to another object.

With this assignation and the function call, I've solved a lot of problems
and been able to use my parameters to update my database tables as I
required.


Thanks again.



On 5 April 2013 15:06, Burak Arslan burak.ars...@arskom.com.tr wrote:

 ast = client.last_received




Saludos

Ombongi Moraa Faith
-- 
http://mail.python.org/mailman/listinfo/python-list