Getting a files details and PyHandle - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Getting a files details and PyHandle

SkepsisSkepsis Posts: 9Member
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.

Comments

  • infidelinfidel Posts: 2,900Member
    : 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.

    [code]
    >>> 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
    [/code]

    : 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?


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • SkepsisSkepsis Posts: 9Member
    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
    :-)

  • infidelinfidel Posts: 2,900Member
    : 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/


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • SkepsisSkepsis Posts: 9Member
    Once again mucho thankyou, I am in your debt

    may python be spread far and wide
Sign In or Register to comment.