Python

Moderators: None (Apply to moderate this forum)
Number of threads: 473
Number of posts: 1172

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Getting a files details and PyHandle Posted by Skepsis on 7 Mar 2003 at 9:54 AM
I have been working at python and have come across dificulties.
I am ok with the very basics and I am using activestates 2.2.2 Python
I want the time a file in a windows machine was last accessed and as yet have not accumplished it.
I have tried with the win32file module the getfiletime and type commands but they refer to PyHandle. What is and how does the PyHandle and associated stuff work? The help files just say what it is ot how to use it.

Can you tell where an example of creating/finding/using PyHandle is or am I stupid and should just convert the output to denary from hex?

I also want to mess with the cursor buttons and windows using the win32api win32gui stuff. I have been able to track the cursor - Hurrar
with

import win32api
x = 1
while x < 1000:
x,y = win32api.GetCursorPos()
print x,y

but have failed misrabilly to Enum any windows to a list or even return the current handle of a window or set an active window.
I tend to have to learn by example so anything on any of the above would be a great help.
Oh, one more thing.
I want a very simple python prog to run on a number of machines.
What is the minimum files to install manually to get this to happen
Python.exe
Python22.dll in the system32 dir is what I've gleaned so far...
Once again thanks for any replies.
Report
Re: Getting a files details and PyHandle Posted by infidel on 10 Mar 2003 at 2:07 PM
: I have been working at python and have come across dificulties.
: I am ok with the very basics and I am using activestates 2.2.2 Python
: I want the time a file in a windows machine was last accessed and as yet have not accumplished it.

>>> from os import stat
>>> from time import ctime
>>> st = stat("c:\\autoexec.bat")
>>> last_access = st.st_atime
>>> print ctime(last_access)
Mon Mar 10 12:41:01 2003


: I have tried with the win32file module the getfiletime and type commands but they refer to PyHandle. What is and how does the PyHandle and associated stuff work? The help files just say what it is ot how to use it.
:
: Can you tell where an example of creating/finding/using PyHandle is or am I stupid and should just convert the output to denary from hex?

Unless you know the windows API well, I'd avoid using PyHandles. They are object wrappers around Win32 handles. Win32 uses handles for everything from devices to processes to windows to brushes, practically everything is represented by a 32 bit handle (long integer).

:
: I also want to mess with the cursor buttons and windows using the win32api win32gui stuff. I have been able to track the cursor - Hurrar
: with
:
: import win32api
: x = 1
: while x < 1000:
: x,y = win32api.GetCursorPos()
: print x,y
:
: but have failed misrabilly to Enum any windows to a list or even return the current handle of a window or set an active window.
: I tend to have to learn by example so anything on any of the above would be a great help.

Here's the first link I found. Might help a bit. I didn't check it out myself.

http://aspn.activestate.com/ASPN/Python/Reference/Products/ActivePython/PythonWin32Extensions/PythonWin32Extensions.html

I know very little about the windows api but if I find anything I'll post back here.

: Oh, one more thing.
: I want a very simple python prog to run on a number of machines.
: What is the minimum files to install manually to get this to happen
: Python.exe
: Python22.dll in the system32 dir is what I've gleaned so far...
: Once again thanks for any replies.

Why not just run the Python installer on each machine?


infidel

Report
Re: Getting a files details and PyHandle Posted by Skepsis on 11 Mar 2003 at 10:28 AM
Thankyou,
Looks like I was way off the mark with the win32file commands (still aint got them working)
Did'nt think of 'stat' to search help on, all I could think of was file properties, attributes, details.... etc

About the python installer.
I had to reject that as its a clandestine prog at work to stop IE opening every time you log on but still to tell you if the company web site has had a change made to it.
Its a mixture of NT Dos and a little checking in Python, (basically if the front page file accessed date has changed then there is something new on the site) but I though I might as well try the whole thing in Python and get it - if I can - to send out the NET MESSAGE that a change has taken place. The dos is very cludgy ( it does a focused dir of the folder where the intranet files are held out to a file and then the python checks for a change between it and the old dir file. If there is then send net message - easy really except that its two languages and 3 extra files on the c drive.)

Sorry to ramble and thanks again for the info.

Any chance of a version of Python, do you think, for the palm pilot


Report
Re: Getting a files details and PyHandle Posted by infidel on 11 Mar 2003 at 11:12 AM
: Thankyou,
: Looks like I was way off the mark with the win32file commands (still aint got them working)
: Did'nt think of 'stat' to search help on, all I could think of was file properties, attributes, details.... etc

I didn't know about stat until I looked for it. Since you needed operations on files, my first inclination was to look in the "os" (operating system) module.

:
: About the python installer.
: I had to reject that as its a clandestine prog at work to stop IE opening every time you log on but still to tell you if the company web site has had a change made to it.

I guess you could try installing as few files as possible and see what happens.

: Its a mixture of NT Dos and a little checking in Python, (basically if the front page file accessed date has changed then there is something new on the site)

Are you sure you want last accessed date? Perhaps last modified date would be more appropriate when checking for updates.

: but I though I might as well try the whole thing in Python and get it - if I can - to send out the NET MESSAGE that a change has taken place. The dos is very cludgy ( it does a focused dir of the folder where the intranet files are held out to a file and then the python checks for a change between it and the old dir file. If there is then send net message - easy really except that its two languages and 3 extra files on the c drive.)

You might try VBScript or JScript.

: Any chance of a version of Python, do you think, for the palm pilot

Python on Palm OS: http://pippy.sourceforge.net/


infidel

Report
Re: Getting a files details and PyHandle Posted by Skepsis on 11 Mar 2003 at 1:07 PM
Once again mucho thankyou, I am in your debt

may python be spread far and wide



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.