FAQ

On Jan 12, 10:07?pm, r0g wrote:
Jo?o wrote:
On Jan 12, 8:05 pm, r0g wrote:
Jo?o wrote:
Someone please?
Haven't seen your original post yet mate, usenet can be flaky like that,
might have been a good idea to quote your original post!
Roger.
Thanks Roger.
Jo?o wrote:
Someone please?
Hi.
I'm trying to figure out how to force URLencoding in my Python 2.4.3
environment, receiving data as an input argument but I'm really at a loss
here.
What am I doing wrong?
headers = ?{ ??User-Agent? ?: ?user_agent ?}
Those quotes need to be either " or ' i.e.

headers = ?{ ?'User-Agent' ?: ?user_agent ?}

If that doesn't sort it then it would be helpful to see a traceback or,
if it is not crashing, get a description of how it is failing to do what
you expect.

Cheers,

Roger.
Weird, I had the correct quotes in my script, maybe I've pasted with
some error.
This is my current script,

(and though I got it working with the subprocess.call I don't know how
to use a pure Python version.

for the following data,
authentication = "UID=somestring&"
message = 'PROBLEM severity High: OperatorX Plat1(locationY) global
Succ. : 94.470000%'
dest_number = 'XXXXXXXXXXX'

url_values = urlencode({'M':message})
enc_data = authentication + url_values + dest_number


I'm getting null for
full_url = Request(url, enc_data, headers)

and thus,
response = urlopen(full_url).read()
returns,
TypeError: <exceptions.TypeError instance at 0x2b4d88ec6440>

)

#!/usr/bin/env python
import sys
import os
import subprocess
from urllib import urlencode, urlopen
from urllib2 import Request

destination = sys.argv[1]
msg = sys.argv[2]

authentication = "UID=somestring&"
dest_number = "&N=%s" % destination

message = '%s' % msg
url_values = urlencode({'M':message})

enc_data = authentication + url_values + dest_number

url = 'http://10.112.28.221:38080/GwHTTPin/sendtext'

subprocess.call('echo "%s" | /usr/bin/POST -P "%s"' % (enc_data, url),
shell=True)

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 14 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedJan 11, '10 at 2:00p
activeJan 18, '10 at 8:50p
posts14
users2
websitepython.org

2 users in discussion

João: 9 posts R0g: 5 posts

People

Translate

site design / logo © 2022 Grokbase