Re: Human readable number formatting

2005-09-27 Thread J Correia
"Alex Willmer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> When reporting file sizes to the user, it's nice to print '16.1 MB',
> rather than '16123270 B'. This is the behaviour the command 'df -h'
> implements. There's no python function that I could find to perform this
> formatting , so I've taken a stab at it:
>
> import math
> def human_readable(n, suffix='B', places=2):
> '''Return a human friendly approximation of n, using SI prefixes'''
> prefixes = ['','k','M','G','T']
> base, step, limit = 10, 3, 100
>
> if n == 0:
> magnitude = 0 #cannot take log(0)
> else:
> magnitude = math.log(n, base)
>
> order = int(round(magnitude)) // step
> return '%.1f %s%s' % (float(n)/base**(order*step), \
>   prefixes[order], suffix)
>
> Example usage
> >>> print [human_readable(x) for x in [0, 1, 23.5, 100, 1000/3, 500,
> 100, 12.345e9]]
> ['0.0 B', '1.0 B', '23.5 B', '100.0 B', '0.3 kB', '0.5 kB', '1.0 MB',
> '12.3 GB']
>
> I'd hoped to generalise this to base 2 (eg human_readable(1024, base=2)
> == '1 KiB' and enforcing of 3 digits at most (ie human_readable(100) ==
> '0.1 KB' instead of '100 B). However I can't get the right results
> adapting the above code.
>
> Here's where I'd like to ask for your help.
> Am I chasing the right target, in basing my function on log()?
> Does this function already exist in some python module?
> Any hints, or would anyone care to finish it off/enhance it?
>
> With thanks
>
> Alex
>
>

This'll probably do what you want with some minor modifications.

def fmt3(num):
for x in ['','Kb','Mb','Gb','Tb']:
if num<1024:
return "%3.1f%s" % (num, x)
num /=1024

>>> print [fmt3(x) for x in [0, 1, 23.5, 100, 1000/3, 500, 100, 12.345e9]]
['0.0', '1.0', '23.5', '100.0', '333.0', '500.0', '976.6Kb', '11.5Gb']

HTH.




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


Re: Searching for txt file and importing to ms access

2005-10-21 Thread J Correia
"Mark Line" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello!
>
>


> I've also managed to connect to my access database, and just print out a
> field in a table, but I cant find anywhere on the web that will help me to
> import data?  Any help would be great?!
>
>


Another method of talking to MS Access is to set up an ODBC datasource...
Control Panel > Data Sources (ODBC).   Then download and import
the mx.ODBC module... this worked a lot faster in my setup than using the
win32com route and i find the clear SQL layout simpler to understand.

Attached is some sample code I used to quickly get some data from SQL Server,
process it, and load into Access, both set up as ODBC data sources.


import mx.ODBC.Windows

dbc1 = mx.ODBC.Windows.Connect('', user='',
password='xxx', clear_auto_commit=0)
dbc2 = mx.ODBC.Windows.Connect('', user='',
password='xxx', clear_auto_commit=0)

# Create cursors on databases.
crsr1 = dbc1.cursor()
crsr2 = dbc2.cursor()

# Get record(s)  from SQL Server database.
try:
crsr1.execute(
"""
SELECT product_id, image
FROM SUP_CATALOGUE_PRODUCT
""")
except Exception, err:
print "*** Error extracting records from SQL Server***"
print "Exception:", Exception, "Error:", err
sys.exit()
else:
results = crsr1.fetchall()  # fetch the results all at once into a
list.
if not len(results): # No records found to be processed.
print "No records returned from SQL Server table, aborting..."
sys.exit()
else:   # Have records to work with, continue processing
print len(results), "records to be updated..."

i = 0
for item in results:

  < processing of each record goes here.>


# Now update 1 record in the Access table.
try:
crsr2.execute(
"""
UPDATE SUP_CATALOGUE_PRODUCT
SET image = '%s'
WHERE product_id = %d
"""   %   (new_image, product_id)
)
except Exception, err:
print "*** Error updating records in MS Access***"
print "Exception:", Exception, "Error:", err
sys.exit()

i += 1

print "All done... records written:", i




HTH,

JC


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


Re: Pregunta sobre python

2005-11-14 Thread J Correia
Para Windows:

import win32api
handle = win32api.OpenProcess(1, False, pid_del_proceso)
win32api.TerminateProcess(handle, -1)
win32api.CloseHandle(handle)


"Yves Glodt" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Andres de la Cuadra wrote:
> > Hola, me llamo Andres de la cuadra, soy un usuario de python en chile y me
> > gustaría saber como puedo cerrer un programa a través de python. Yo se que
> > con la librería os puedo ejecutar programas, pero no e encontrado una
> > librería para poder cerrarlos
>
> Hola Andres,
>
> puedes cerrer un programa con os.kill, pero depende de tu plataforma,
> por ejemplo en linux (no se para windows):
>
> os.kill(pid_del_proceso, 9)
>
>
> p.s.
> Vas a tener mas excito si escribes en ingles, esta es une lista en
> ingles ;-)
>
>
> > Gracias
> >
> >


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

Re: how to start a process and get it's pid?

2005-11-14 Thread J Correia

"Peter Hansen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Fredrik Lundh wrote:
> > Daniel Crespo wrote:
> >>os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe")
> >>>1944
> >>
> >>I don't get the correct PID.
> >>
> >>When I do os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe")
> >>I get 168 (for example), while in the tasklist appears notepad.exe with
> >>the 2476 PID.
> >
> > not sure, but the return value looks like a PID, so maybe you're seeing the
> > PID for the cmd.exe instance used to run the program.  or something.
>
> I believe it's documented here
> http://docs.python.org/lib/os-process.html that the return value is not
> the PID but the "process handle".  I believe this can be converted to
> the PID with a convenient pywin32 call though at the moment I can't
> recall which.  Googling quickly suggests that
> win32process.GetWindowThreadProcessId(handle) will do the trick (the
> second item returned is the PID), but I'm fairly sure there's a simpler
> approach if you keep looking.  I recall there being a Cookbook recipe
> related to this too
>
> -Peter

Yep...
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/347462


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


Re: login website that using PHP

2005-06-20 Thread J Correia
"frost" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I am trying to login a website that using PHP and javascript. This is
> what happend if you browse that website using IE, after you login, you
> can go anywhere without enter your name and password again, as long as
> you keep that IE open, but after you close that IE, then later on open
> that website in a new window, you need to login again. I guess some
> session is created as long as your original login window dose not
> close.
>
> How I can handle this in python? I want get some information from that
> website. But the login page is not what I want, how can I simulate
> regular IE browser? I mean after I login, I can get to other pages from
> it, but I find my programe can't go other place except the login page.
>
> Hope you could understand my question. Thank you very much!
>

Check here for some other examples, specifically 'Submitting values
 and clicking buttons in IE'
 http://tinyurl.com/7n7xf


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


Re: Using win32com for web automation

2005-07-26 Thread J Correia
> from win32com.client import Dispatch
> from time import sleep
>
> ie = Dispatch('InternetExplorer.Application')
> ie.Visible = 1
> ie.Navigate("http://ispds-sepsr.prv:7500/cs/welcome.jsp";)
>
> while ie.ReadyState != 4:
> sleep(1)
>
> doc = ie.Document
>
> while doc.readyState != "complete":
> sleep(1)
>
> doc.loginForm.name.value = 'username'
> doc.loginForm.password.value = 'password'
> doc.loginForm.loginform.action = '/cs/login.do'

I can't get to that site to test.
Try the following instead of the last line above:

doc.loginForm.submit()


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


Re: How to get rid of FutureWarning: hex/oct constants...

2005-04-05 Thread J Correia
Assuming you're just trying to get rid of the message each time the program
runs, the following suppresses it:

import warnings
warnings.filterwarnings('ignore', category=FutureWarning)


HTH,


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


Re: Internet Explorer, COM+, Javascript and Python

2005-04-28 Thread J Correia

"Roger Upole" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Something like this should be close:
>
> import win32com.client, pythoncom
> ie=win32com.client.Dispatch('internetexplorer.application')
> ie.Visible=1
> ie.Navigate('somepagewithjavascript.html')
> id=ie.Document.Script._oleobj_.GetIDsOfNames('somejsfunction')
> res=ie.Document.Script._oleobj_.Invoke(id, 0, pythoncom.DISPATCH_METHOD,
> True,  )
>
>hth
>Roger

Yes, that definitely works.  Only one minor correction:  it seems that to
pass multiple parameters you need to pass them sequentially seperated by
commas instead of in a tuple, i.e.
res=ie.Document.Script._oleobj_.Invoke(id, 0, pythoncom.DISPATCH_METHOD,
True, param1, param2, param3, . )

Useful test sitefor above code:
http://www.cpplab.com/Articles/JSCalls/TestPage/JSCallTestPage.htm

HTH,

>
>
> "Ishpeck" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> >I need to make IE execute javascript in a web page with COM+ and
> > Python.
> >
> > Similarly to the way they do it in this article. . .
> >
> > http://www.codeproject.com/com/jscalls.asp
> >
>
>
>
> == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet
News==
> http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
> = East and West-Coast Server Farms - Total Privacy via Encryption
=



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


Re: Webbrowser On Windows

2005-05-01 Thread J Correia
><[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>It seems to me that there is no way to create a new instance of Internet
>Explorer (if there are already some IE windows opened).
>Does anyone know a possible solution? Or a workaround (without using
>startfile, maybe?) that will force IE to create a new instance?

>Should I suppose no solution exists?

>Thanks for every suggestions.

>Andrea


import pythoncom
from win32com.client import Dispatch

ie1 = pythoncom.CoCreateInstance("InternetExplorer.Application", None,\
 pythoncom.CLSCTX_SERVER,
 pythoncom.IID_IDispatch)
ie1 = Dispatch(ie1)
ie1.Visible = 1

ie2 = pythoncom.CoCreateInstance("InternetExplorer.Application", None,\
 pythoncom.CLSCTX_SERVER,
 pythoncom.IID_IDispatch)
ie2 = Dispatch(ie2)
ie2.Visible = 1

and so on for as many instances as you want.

HTH.





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


Re: Webbrowser On Windows

2005-05-02 Thread J Correia

"M.E.Farmer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I played around with it.
>

> import pythoncom
> from win32com.client import Dispatch
>

> def webbrowser(url=None):
> ie = pythoncom.CoCreateInstance("InternetExplorer.Application",
> None,
>  pythoncom.CLSCTX_SERVER,
>  pythoncom.IID_IDispatch)
> ie = Dispatch(ie)
> ie.Navigate
> if url:
> ie.Navigate(url)
> ie.Visible = 1
> return ie
>

#
> import time
> w = webbrowser()
> w.Navigate('http://www.google.com')
> time.sleep(2)
> w.Navigate('http://dir.gmane.org/gmane.comp.python.general')
> time.sleep(2)
>
webbrowser('http://groups-beta.google.com/group/comp.lang.python?hl=en&lr=')
> webbrowser('http://python.org')
>

#
> M.E.Farmer
>

Noticed your sleep statements... because the response times vary from site
to site you might want to use this code:

while w.ReadyState != 4:   # 4 signals browser has finished loading and
is ready... 0=uninitialised; 1=loading; 2=loaded; 3=interactive; 4=complete
time.sleep(1)

While we're on that subject... if you go further and expose the Document
object to work with the contents of the browser, for example...

doc = w.Document

then you also need to check for document readiness before continuing
processing as follows...

while w.ReadyState != 4 and doc.readyState != "complete":
time.sleep(1)

Useful links:
http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/IWebBrowser2/IWebBrowser2.asp

http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_document.asp

HTH,


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


Re: How to receive events (eg. user mouse clicks) from IE

2005-05-20 Thread J Correia
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thanks for the response again. The solution is pretty close but not yet
> complete
> This is what I observed.
> a) I tried to use the delay mechanism as suggested below
> ie.
> ie.Navigate('www.google.com')
> while ie.ReadyState !- 4
>time.sleep(0.5)
>
> d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events)
>
> IE *fails* to load the webpage

Thought this was quite curious so tried it myself (on Python 2.3 Win2k
machine).  Put in some timing conditions and the problem is not that it
fails to load, but that it takes really long (min time during tests = 60
secs
, maximum time 580 secs).

Tried using  just WithEvents, same problem.  The problem seems to
lie with the call to ie.ReadyState while trapping events.  2 things lead me
to believe this...
1) Interrupting the Python code after the browser window opens, results in
the window
 finishing and loading the URL immediately with no problems.
2) Running the code with just Dispatch (no events) and it works fine (< 1
sec).

All I can think is that each call to ie.ReadyState triggers some internal
event which hogs resources to process.

It seems like the problem is with IE Events only... so a possible workaround
(if all you need is the Doc events) is the following:
-
import win32com.client

class Doc_Events:
def Ononactivate(self):
print 'onactivate:', doc.location.href
def Ononclick(self):
print 'onclick fired.'
def Ononreadystatechange(self):
print 'onreadystatechange:', doc.readyState

ie = win32com.client.Dispatch("InternetExplorer.Application")
ie.Visible = 1
ie.Navigate('http://www.google.com')

while ie.ReadyState != 4:
time.sleep(1)

doc = ie.Document
doc_events = win32com.client.WithEvents(doc, Doc_Events)
# OR can use following:
# doc = win32com.client.DispatchWithEvents(ie.Document, Doc_Events)

while ie.ReadyState != 4 and doc.readyState != "complete":
# readystate is case sensitive and differs for ie (R) and doc (r)
# ie.ReadyState: 0=uninitialised; 1=loading; 2=loaded;
#3=interactive; 4=complete
time.sleep(1)
-

HTH,


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


Re: How to receive events (eg. user mouse clicks) from IE

2005-05-21 Thread J Correia
"Roger Upole" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> There does appear to be some sort of conflict between the two event
> hooks.  I wasn't seeing it before since IE was getting google from my
> browser cache and it was coming up almost instantaneously.  As soon
> as I switched the URL to a page that loads slowly, I got the same
> result.
>
>Adding win32gui.PumpWaitingMessages() to the wait loop
> seems to allow both event hooks to run without blocking each other.
>
>  Roger

I added that line to the wait loop and while it does indeed speed it
 up dramatically (in 10 tests: min = 13 sec; max = 33, ave ~ 20 secs)
it's still nowhere near the 1-2 secs it takes without hooking the
IE events.  I also can't explain the wide differences between min
and max times since they seem to occur randomly
(e.g. min occurred on 7th run, max on 4th).

I assume that that response time won't be adequate for the original
poster's needs, due to the slowdown in browsing for his users.

Jose





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


Re: Access lotus notes using Python

2005-05-23 Thread J Correia
> >>The Great 'Sateesh' uttered these words on 5/23/2005 7:14 AM:
> >>>Is it possible to access Lotus notes using Python? Can anyone provide
me
> >>>some pointers?


This might help you get started once you've installed the win32 modules.
 http://tinyurl.com/a9ocy



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


Re: Pressing A Webpage Button

2005-06-01 Thread J Correia
"Elliot Temple" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How do I make Python press a button on a webpage?  I looked at
> urllib, but I only see how to open a URL with that.  I searched
> google but no luck.
>
> For example, google has a button how would i make a script to press that button?
>
> Just for fun, is there any way to do the equivalent of typing into a
> text field like the google search field before hitting the button?
> (I don't actually need to do this.)

You don't say which OS... if you're running IE on Windows you
can use COM as follows...

from win32com.client import Dispatch
from time import sleep

ie = Dispatch("InternetExplorer.Application")
ie.Visible = 1
ie.Navigate("http://www.google.com";)
while ie.ReadyState != 4:# Wait for browser to finish loading.
sleep(1)
doc = ie.Document
doc.f.q.value = "qwerty"# form name is 'f'; search field name is 'q'
doc.f.btnG.click()# click on button 'btnG'


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


Re: Pressing A Webpage Button

2005-06-03 Thread J Correia
"Esben Pedersen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How do i know which methods the ie object has? dir(ie) doesn't show
> Navigate.

For ie object:
http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/IWebBrowser2/IWebBrowser2.asp

For document object:
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_document.asp



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


Re: separate IE instances?

2005-06-06 Thread J Correia
"Chris Curvey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I need to create a set of IE instances that have different sets of
> session cookies.  I thought that using the win32com.DispatchEx function
> would do this, but it doesn't seem to.  In other words
>
> ie1 = win32com.DispatchEx("InternetExplorer.Application")
> ie2 = win32com.DispatchEx("InternetExplorer.Application")
>
> gives me two IE windows, but only one IEXPLORE process in Task Manager.
>  And if I login to a site that uses session cookies to track sessions
> using ie1, when I move ie2 to the same site, ie2 is already logged in.
>
> Any help appreciated.
>
> -Chris

from win32com.client import Dispatch

ie1 = pythoncom.CoCreateInstance("InternetExplorer.Application", None,\
 pythoncom.CLSCTX_SERVER,
 pythoncom.IID_IDispatch)
ie1 = Dispatch(ie1)
ie2 = pythoncom.CoCreateInstance("InternetExplorer.Application", None,\
 pythoncom.CLSCTX_SERVER,
 pythoncom.IID_IDispatch)
ie2 = Dispatch(ie2)
.
.
.



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


Re: separate IE instances?

2005-06-07 Thread J Correia
"Chris Curvey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I would have given up on this a long time ago, but I can create two
> IEXPLORE processes simultaneously (and get the behavior I want) by just
> manually launching them from the Start menu.   (Of course, that doesn't
> mean that I can launch them programmatically, but I'm hoping that
> someone can give me a definitive answer.)
>

Right, I hadn't quite understood your problem when I posted my reply.  The code
posted does work and allow navigation, etc. but you do have the problem with it
sharing the same session cookies (I'm also on Win2k).  And to answer Martin, you
can definitely create as many iexplore.exe instances as you like in Windows.

How to get Python to launch several instances with COM... not sure, although I'm
99% certain it is doable.  I'll hunt around and see if I can find a solution
which I'll post back.

J


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


Re: separate IE instances?

2005-06-07 Thread J Correia
> "Chris Curvey" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I would have given up on this a long time ago, but I can create two
> > IEXPLORE processes simultaneously (and get the behavior I want) by just
> > manually launching them from the Start menu.   (Of course, that doesn't
> > mean that I can launch them programmatically, but I'm hoping that
> > someone can give me a definitive answer.)
> >

"J Correia" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Right, I hadn't quite understood your problem when I posted my reply.  The
code
> posted does work and allow navigation, etc. but you do have the problem with
it
> sharing the same session cookies (I'm also on Win2k).  And to answer Martin,
you
> can definitely create as many iexplore.exe instances as you like in Windows.
>
> How to get Python to launch several instances with COM... not sure, although
I'm
> 99% certain it is doable.  I'll hunt around and see if I can find a solution
> which I'll post back.

A very quick and very, very dirty method which might work is to start up
the instances as follows:
import win32api
a = win32api.ShellExecute(0,None,"iexplore.exe",None,None,1)
b = win32api.ShellExecute(0,None,"iexplore.exe",None,None,1)
 This creates the 2 instances of iexplore.exe in Windows you're looking for.

Then use code like this to attach to the already running instances:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/269345

Haven't tried it because I'm certain there's a much more elegant solution, but
depending on how quickly you need to get going it might be a possible short term
work around until someone posts the better way.  Perhaps you can also post some
more info on what you're actually trying to achieve... make it easier for
someone to
help or even suggest alternatives.

JC





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


Re: separate IE instances?

2005-06-07 Thread J Correia
>Chris Curvey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> thanks for all the help.  I'll give the ShellExecute() approach a try
> in the morning.
>
> The short version of what I'm trying to do is
>
> Have my website login to a 3rd party website on behalf of my customer,
> fill out a form, and submit it.  I'm just using CGI to keep things
> simple, but overlapping requests from different customers are the
> problem.  The 3rd party site uses a lot of javascript, so mechanize
> isn't going to work.  I could use some kind of locking mechanism and
> "single-thread" access to IE, but that won't scale.   I guess the next
> approach would be to queue the requests and have a pool of worker
> processes (running as different users) process the requests and report
> back.

You might have a specific reason for using COM, but if not, have you
considered using the python urllib or urllib2 modules instead?
It should overcome the session cookie / overlapping request issues i think.


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


Re: How to receive events (eg. user mouse clicks) from IE

2005-06-13 Thread J Correia
> <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Resurrecting an old thread..
> > It seems that this solution does not return events on objects within
> > frames in webpages eg . if you go to www.andersondirect.com - the page
> > is composed of three frames called as topFrame main and address. Now
> > when I click on say 'Select a Vehicle' which is within main - I do not
> > get any Onclick event. I also do not get an OnMousemove event if I move
> > the mouse. However, I do get on Mousemove event on a tag called as
> > frameset (which is part of the top page).
> > How does one get events from the frames then?
> > As always thanks a lot.
> >

"Roger Upole" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Each frame acts as a separate document.
> You should be able catch document events
> from a frame using something like
> win32com.client.DispatchWithEvents(ie.Document.frames().document, )
>
>   Roger
>

What Roger said is correct, however the frames you're wanting on that site are
running Flash apps.  I'm not aware of any method that allows one to intercept
clicks within a Flash app. And even if you could determine a click occurred,
you'd have to figure out where in the app precisely and what Flash will do with
that
information.  I suspect this is not possible by design (i.e. security reasons,
etc.)

JC



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


Re: separate IE instances?

2005-06-13 Thread J Correia
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Sorry about that I had an instance of ie running in the background that
> was version 0  didn't see the problem tell this morining when my
> computer started to not work.  it should be hwnds[1] should be
> hwnds[0].  I woud enumerate them like in the code below.
>
> If you have ie as your default browser you can use a
> shellExecute(0,None,"some url here", None, None, 1)
> To open directley to that page.
>
> Here is a more complete script:
> import win32api, time
> from win32com.client import Dispatch
> a = win32api.ShellExecute(0,None,"iexplore.exe",
> "www.ishpeck.net",None,1)
> b = win32api.ShellExecute(0,None,"iexplore.exe",
> "www.google.com",None,1)
> internetExplorerClassIdentity='{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'
> hwnds = Dispatch(internetExplorerClassIdentity)
> # way I showed you before dosn't work verry well if more then one ie is
> open
> #ieObj = hwnds[0]
> #ieObj.Navigate("http://www.google.com/search?hl=en&lr=&q=python";)
> time.sleep(30)
> for i in range(hwnds.Count):
> if hwnds[i].LocationURL.lower().find("ishpeck") > -1:
> ieObj1 = hwnds[i]
> if hwnds[i].LocationURL.lower().find("google") > -1:
> ieObj2 = hwnds[i]
>
> ieObj1.Navigate("http://www.google.com/search?hl=en&lr=&q=python";)
>
ieObj2.Navigate("http://groups-beta.google.com/group/comp.lang.python/browse_thr
ead/thread/ba1395566452dba6/343672a01d5b2cdc?hl=en#343672a01d5b2cdc")

The thing to note is that hwnds brings back a list of all Internet Explorer
 objects running on your machine.  This *includes* things that might
not be obvious at first, like a simple Windows Explorer window
(or windows) you have running (since it uses IE in the background).
Printing hwnds.LocationName and hwnds.LocationURL in a loop
will show you exactly what processes are using IE at the time you run it.
Given that the returned list will vary each time you run your program
you'll definitely have to iterate through each hwnds item and check
if it is the browser session you want as shown in the above code.

JC


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


Re: win32evtlog

2005-06-13 Thread J Correia

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Doh! I didn't think to look in the demo directory. Silly me.
>


http://www.win32com.de/index.php?option=com_content&task=view&id=163&Itemid=189


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


Re: Need design advice. What's my best approach for storing this data?

2006-03-17 Thread J Correia

"Mudcat" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> I am trying to build a tool that analyzes stock data. Therefore I am
> going to download and store quite a vast amount of it. Just for a
> general number - assuming there are about 7000 listed stocks on the two
> major markets plus some extras, 255 tradying days a year for 20 years,
> that is about 36 million entries.
>

On a different tack, to avoid thinking about any db issues, consider 
subscribing
to TC2000 (tc2000.com)... they already have all that data,
in a database which takes about 900Mb when fully installed.
They also have an API which allows you full access to the database
(including from Python via COM).  The API is pretty robust and allows
you do pre-filtering (e.g. give me last 20 years of all stocks over $50
with ave daily vol > 100k) at the db level meaning you can focus on using
Python for analysis.  The database is also updated daily.

If you don't need daily updates, then subscribe (first 30 days free) and
cancel, and you've got a snapshot db of all the data you need.

They also used to send out an evaluation CD which had all
the history data barring the last 3 months or so which is certainly
good enough for analysis and testing.  Not sure if they still do that.

HTH.


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


Re: Beginner's question: executing scripts under Win XP pro

2006-03-25 Thread J Correia

"Scott Souva" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Your script may be working properly, but XP simply removes the window
> after the script runs.  Here is a simple fix that will stop at the end
> of the script and leave the Command window open:
>
> print "Hello World"
> raw_input()

That'll work (it waits for input from the user, and, as soon as it
receives it shuts down the window).

Another way to do it is instead of doubleclicking on the script,
open a command prompt window (Start>Run>cmd OR
Start>Programs>Accessories>Command Prompt) then type
'python test.py' at the prompt.  Now the window stays open
until you specifically close it and you can rerun the script many times.

HTH,

JC 


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


Re: Python and microsoft outlook-using com, can I interact with msoutlook?

2006-04-04 Thread J Correia

><[EMAIL PROTECTED]> wrote in message 
>news:[EMAIL PROTECTED]
>Hi All,
> know that Microsoft Exchange has a com interface, CDO, but I can't seem to
>find one for Microsoft outlook.
>does anyone have code snippets for using msoutlook and python, or
>suggestions?

Check out:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/173216
also:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/266625
and:
http://www.win32com.de/index.php?option=com_content&task=view&id=97&Itemid=192

Also I've emailed you a pdf I'd downloaded a while back,
unfortunately I can't remember the source to credit here.

That should get you started.

HTH,

JC



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