soap - sessions ?

2007-06-08 Thread gcmartijn
H!

When I use php code nusoap everything works but with python I get
everytime "Your session key does not exist or has expired"

I use this code below:

test = SOAPpy.SOAPProxy("http://secure.easynic.com/com/iomart/
easynicWSv2.cfc?wsdl")
data = test.login(_id='test',_pass='pass')
for item in data:
for item2 in item:
if item2['key']=='KEY':
EASYKEY = item2['value']

# now I have the EASYKEY

# create a customer with the key,
# print output = "Your session key does not exist or has
expired"
print test.createOrUpdateContact(key=EASYKEY,
title=row[0],
firstname=row[2],
initials=row[3],
lastname=row[4],
company=row[5],
phone=row[9],
fax='',
email=row[13],
address1=straat,
address2='',
address3='',
area=row[12],
city=row[8],
country=row[12],
postcode=row[7],
acc_username='',
acc_password='',
domaincontactid='')

# logout , and this works ! (using the same key)
test.logout(key=EASYKEY)

With php this works:

// get the key $_SESSION[CODElogin]
$result = $soapClient->call('login',$params,$_SESSION[serverip],
$_SESSION[serverip])

// make a customer
   $params = array(
'key'   => $_SESSION[CODElogin],
'title' => $_POST[title],
'firstname' => $_POST[firstname],
'initials'  => $_POST[initials],
'lastname'  => $_POST[lastname],
'company'   => $_POST[company],
'phone' => $_POST[phone],
'fax'   => $_POST[fax],
'email' => $_POST[email],
'address1'  => $_POST[address1],
'address2'  => $_POST[address2],
'address3'  => $_POST[address3],
'area'  => $_POST[area],
'city'  => $_POST[city],
'country'   => $_POST[area],
'postcode'  => $_POST[postcode],
'acc_username'  => $_POST[acc_username],
'acc_password'  => $_POST[acc_password],
'domaincontactid'=> $_POST[domaincontactid]
);

// send
$result = $soapClient->call('createOrUpdateContact',$params,'http://
secure.easynic.com/com/iomart/easynicWSv2.cfc?wsdl','http://
secure.easynic.com/com/iomart/easynicWSv2.cfc?wsdl');

and everything works, what can I do to make this with python ?
or must I use exec("phpprogram.php") ? (I hope not)

Thanks

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


Re: soap - sessions ?

2007-06-08 Thread gcmartijn
When I use
SOAPpy.Config.dumpSOAPOut = 1
SOAPpy.Config.dumpSOAPIn = 1

will display:

*** Outgoing SOAP
**

http://schemas.xmlsoap.org/soap/encoding/";
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance";
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
  xmlns:xsd="http://www.w3.org/1999/XMLSchema";
>























fsdfsd
sdfsad
NL
+31.243770011
M
3432VD
EASYNICAPI2_3057578_53854283
dfasdf
dfasdf 3
safasdf
[EMAIL PROTECTED]
fsdfas



*** Incoming SOAP
**

http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema";
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance";>
 
  
   
  
  http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:ns1="http://xml.apache.org/xml-soap";>
   
http://www.w3.org/2001/
XMLSchema">RESPONSECODE
http://www.w3.org/2001/
XMLSchema">999
   
   
http://www.w3.org/2001/
XMLSchema">RESPONSETEXT
http://www.w3.org/2001/
XMLSchema">Your session key does not exist or has expired
   
  
 



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


BeautifulSoup - extract the

2007-06-18 Thread gcmartijn
I'm trying to extract something like this:

http://download.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=7,0,19,0" width=640 height=400>


http://www.macromedia.com/go/
getflashplayer type=application/x-shockwave-flash width=640 height=400
bgcolor=#00 scale= showall>




I don't know how I can get the param

# below don't work
for test in soup.fetch('object'):
print test # nothing

# nothing
print soup.findAll('param',{'name':'movie'})

# nothing
print soup.findAll('object')

Is it possible with BeautifulSoup to extract the object tag with his
child param ?
I have made everything in BeautifulSoup so I hope its possible :S

Thanks anyway,
GCMartijn

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


BaseHTTPRequestHandler reading .html with python code

2007-04-06 Thread gcmartijn
H!

I was wondering how I can do something like this.

file.html
-
hello world

print 'hello world'
#or display str(time.localtime()[7])


webserver.py
-
def do_GET(self):
try:
if self.path.endswith(".html"):
f = open(curdir + sep + self.path) #self.path has /
test.html
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
# now display the hello world and run the python code.
self.wfile.write(f.read())
f.close()
return

I saw the mod python for apache and some PSP but I really want to know
how they do this.
Is there are special module for doing this ?

Or is there something like this:
---
1. a running python program
2. include with write(f.read()) a extra python code inside the already
running python program.

How they handle this ?

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


bin2chr("01110011") # = 15 function ?

2008-02-25 Thread gcmartijn
H!

I'm searching for a simple
bin2chr("01110011") function that can convert all my 8bit data to a
chr so I can use something like this:

def bin(i):
l = ['', '0001', '0010', '0011', '0100', '0101', '0110',
'0111',
 '1000', '1001', '1010', '1011', '1100', '1101', '1110',
'']
s = ''.join(map(lambda x, l=l: l[int(x, 16)], hex(i)[2:]))
if s[0] == '1' and i > 0:
s = '' + s
return s

print ord("s") # = 115
print bin(ord("s")) # = 01110011

test= open('output.ext,'wb')
test.write(bin2chr("01110011"))
test.write(bin2chr("0011"))
test.write(bin2chr("01110111"))
test.close()

I think this is very easy but I'm not very good in python.
In a other program I use I do something like this

Function bin2int(b$)
blen=Len(b)
For f=1 To blen
n=n Shl 1 + (Mid(b,f,1)="1")
Next
Return n
End Function
-- 
http://mail.python.org/mailman/listinfo/python-list


print command don't work (subscripted) word[2:4]

2008-10-07 Thread gcmartijn
Why is this not working ?

bla = 'hondenriem'
print bla[0:4]  # correct ! (= hond)
print bla[3:2]  # nothing ! (= en)
print bla[6:3]  # nothing ! (= riem)

Why don't bla[3:2] and bla[6:3] won't work ?

I use this version:
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32

http://docs.python.org/tutorial/introduction.html#strings
word = 'HelpA'
>>> word[4]
'A'
>>> word[0:2]
'He'
>>> word[2:4]
'lp'
--
http://mail.python.org/mailman/listinfo/python-list


pythoncom InternetExplorer.Application don't work in vista || firefox pythoncom ?

2008-07-05 Thread gcmartijn
H!

I using a script that opens a internet page in a small window (what I
can control)
In XP everything was working fine, but now I'm using Vista with IE7
and this is what happends now:

First a small window opens at the postion x0 y0 (like I want) but then
IE thinks "Hey lets open a other main window too".
And that window opens the url 'http://www.google.nl'

It seems that I can't control/use my first window anymore, and that
IE7/vista is forcing to open it in a big new window.

The code below is what I'm using.

def webbrowser(url=None):
import pythoncom
from win32com.client import Dispatch

ie = pythoncom.CoCreateInstance("InternetExplorer.Application",
None,pythoncom.CLSCTX_SERVER,pythoncom.IID_IDispatch)
ie = Dispatch(ie)
ie.Top = 0.0
ie.Left = 0.0
ie.Height = 400
ie.Width = 400
ie.AddressBar = False
ie.MenuBar  = False
ie.Resizable = False
ie.StatusBar = False
ie.ToolBar = False
ie.Visible = 1
return ie

w = webbrowser()
w.Navigate('http://www.google.nl')

--
ow and why can't I find a pythoncom.CoCreateInstance.FireFox example ?

Thanks for helping.
--
http://mail.python.org/mailman/listinfo/python-list


Re: pythoncom InternetExplorer.Application don't work in vista || firefox pythoncom ?

2008-07-06 Thread gcmartijn
On 5 jul, 15:27, Terry Reedy <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > H!
>
> > I using a script that opens a internet page in a small window (what I
> > can control)
> > In XP everything was working fine, but now I'm using Vista with IE7
> > and this is what happends now:
>
> > First a small window opens at the postion x0 y0 (like I want) but then
> > IE thinks "Hey lets open a other main window too".
> > And that window opens the url 'http://www.google.nl'
>
> Perhaps on XP you changed the IE homepage to about:blank.  On your Vista
> machine, it is set to Google, perhaps by the manufacturer (for a fee).
> Try changing it.

Nope when its about:blank I get that google page (because I say that
in the script)
--
http://mail.python.org/mailman/listinfo/python-list


Re: pythoncom InternetExplorer.Application don't work in vista || firefox pythoncom ?

2008-07-06 Thread gcmartijn
On 5 jul, 14:14, "Méta-MCI \(MVP\)" <[EMAIL PROTECTED]>
wrote:
> Hi!
>
> Your code run OK for me (Vista Ultimate).
> This other version run also OK :
>
> def webbrowser(url=None):
>     import win32com.client, time
>
>     ie=win32com.client.Dispatch('InternetExplorer.Application')    
>     while ie.Busy==True:
>         time.sleep(0.125)
>     ie.Top = 0
>     ie.Left = 0
>     ie.Height = 400
>     ie.Width = 400
>     ie.AddressBar = False
>     ie.MenuBar  = False
>     ie.Resizable = False
>     ie.StatusBar = False
>     ie.ToolBar = False
>     ie.Visible = 1
>     return ie
>
> w = webbrowser()
> w.Navigate('http://www.google.nl')
>
> @-salutations
> --
> Michel Claveau

I use your script now but I'm still getting 2 windows I uploaded a
screenshot how it looks.
1 at the background my window (but that is loading nothing)
1 at on top with the site http://www.google.nl (because that is in the
script)

http://img376.imageshack.us/img376/5506/capturess8.jpg
--
http://mail.python.org/mailman/listinfo/python-list


Re: pythoncom InternetExplorer.Application don't work in vista || firefox pythoncom ?

2008-07-07 Thread gcmartijn
On 6 jul, 16:00, "Méta-MCI \(MVP\)" <[EMAIL PROTECTED]>
wrote:
> H...  I have a similary problem, in another circumstances.
> It's often a problem of configuration of IE (for news customers).  But,
> it is not easy, because IE has many parameters.
>
> Good luck!
>
> Michel Claveau

IE have many options, you say that the code is working so I was hoping
that you could answer these questions:
- Is your tabbed browsing on ?
- Do you use the default 'securiy' settings ?
- Do you use by privacy option: Medium ?
- The advanced options are to much to ask here :(

Greetings,
GCMartijn
--
http://mail.python.org/mailman/listinfo/python-list


re.findall(a patern,'function(dsf sdf sdf)')

2008-07-26 Thread gcmartijn
H!

First I have some random string below.

bla = """ 
// <![CDATA[

var bla = new Blaobject("argh 1a", "argh 2a", "24", 24, 345)

function la( tec )
{
  etc etc
}

function other thing( ){

  var two = new BlaObject("argh 1b", "argh 2b", ""+(sv), 
""+(2f),
"4");

  bla die bla
}

// ]]>
   """


Now I'm trying to get each BlaObject with the first (variable)
function argument

And I can say that this isn't working
for a in re.findall(r'([BlaObject ])(.*)([)] *)',bla):
print a

The output must be something like:
# ('BlaObject','argh 1a')
# ('BlaObject','argh 1a')
or
# Blaobject("argh 1a", "argh 2a", "24", 24, 345)
# BlaObject("argh 1b", "argh 2b", ""+(sv), ""+(2f), "4");


My simple idea was to
a. the start position is the BlaObject
b. the stop position is the character )  (not ); because its a
javascript function)
c. the output [a (everything between) b]

Who knows the answer ?

Thanks very much,
GCMartijn
--
http://mail.python.org/mailman/listinfo/python-list


Re: re.findall(a patern,'function(dsf sdf sdf)')

2008-07-26 Thread gcmartijn
> In short, the regular expression you used doesn't seem to be an effort
> to solve the problem. In other words, you haven't read the regular
> expression docs:http://docs.python.org/lib/module-re.html. In other
> words, it's useless to talk with you until then.
>

Its a combination
- I don't understand english very good (yet)
- For me its hard to learn the re , I will try to search again at
google for examples and do some copy past things.

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


Re: re.findall(a patern,'function(dsf sdf sdf)')

2008-07-26 Thread gcmartijn
On 26 jul, 14:25, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > - For me its hard to learn the re , I will try to search again at
> > google for examples and do some copy past things.
>
> this might be useful when figuring out how RE:s work:
>
>      http://kodos.sourceforge.net/
>
> also, don't forget the following guideline:
>
>     "Some people, when confronted with a problem, think 'I know,
>     I'll use regular expressions.'   Now they have two problems."
>
> some advice:
>
> - Keep the RE:s simple.  You can often simplify things a lot by doing
> multiple searches, or even by applying a second RE on the results from
> the first.  In this case, you could use one RE to search for BlaObject,
> and then use another one to extract the first argument.
>
> - Ordinary string methods (e.g. find, partition, split) are often a very
> capable alternative (in combination with simple RE:s).  In your case,
> for JavaScript code that's as regular as the one in your example, you
> can split the string on "BlaObject(" and then use partition to strip off
> the first argument.
>
> - only use RE:s to read specialized file formats if you know exactly
> what you're doing; there's often a ready-made library that does it much
> better.
>
> - The regular expression machinery is not a parser.  You cannot handle
> all possible syntaxes with it, so don't even try.
>
> 

Thanks for the info, I will download that program later so I can build
a re (i hope)

Because I can't wait for that re, I have made a non re solution what
is working for now.

for a in bla.split():
if a.find('BlaObject')<>-1:
print a[11:].replace("'","").replace('"',"").replace(",","")

(I know this is not the best way, but it helps me for now)
--
http://mail.python.org/mailman/listinfo/python-list