Re: HELP: Python equivalent of UNIX command "touch"
pekka niiranen <[EMAIL PROTECTED]>: >Does anybody know Python recipe for changing the date >of the directory or files in W2K to current date and time? >In UNIX shell command "touch" does it. See below. The key is using the FILE_FLAG_BACKUP_SEMANTICS flag. #-- # dirtest.py from win32file import * from pywintypes import Time import time x=CreateFile(r"d:\scratch\testdir",GENERIC_READ+GENERIC_WRITE, FILE_SHARE_WRITE,None,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0) i,c,a,w= GetFileTime(x) print "create",c,"access",a,"write",w SetFileTime(x,Time(int(c)-24*3600),Time(int(c)-12*3600),Time(int(c) -3*3600)) #-- C:\e\littlepython>dirtest.py create 01/21/05 04:27:04 access 01/21/05 16:27:04 write 01/22/05 01:27:04 C:\e\littlepython>dirtest.py create 01/20/05 03:27:04 access 01/20/05 15:27:04 write 01/21/05 00:27:04 C:\e\littlepython>dir d:\scratch\testdir ... Verzeichnis von d:\scratch\testdir 20.01.2005 00:27 . 20.01.2005 00:27 .. 0 Datei(en) 0 Bytes 2 Verzeichnis(se), 806.768.640 Bytes frei -- Wir danken für die Beachtung aller Sicherheitsbestimmungen -- http://mail.python.org/mailman/listinfo/python-list
Re: [Py Windows] User Directory Path
"Zoool" : >Is there a way to know the main directory path of a user session? >I mean the "C:\Documents and Settings\username" Directory of the user logged >into a windows session. >>> from win32com.shell.shell import SHGetSpecialFolderPath >>> from win32com.shell.shellcon import CSIDL_PROFILE >>> SHGetSpecialFolderPath(0,shellcon.CSIDL_PROFILE) u'C:\\Dokumente und Einstellungen\\wolfgang' -- Wir danken für die Beachtung aller Sicherheitsbestimmungen -- http://mail.python.org/mailman/listinfo/python-list
Re: Determine if windows drive letter is hard drive or optical from python?
"mh" <[EMAIL PROTECTED]>: >2. More importantly for those drives that exist, how do I determine if >it is actually a harddrive? C:\>python Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32file,string >>> def harddisks(): ... driveletters=[] ... for drive in string.letters[len(string.letters)/2:]: ... if win32file.GetDriveType(drive+":")==win32file.DRIVE_FIXED: ... driveletters.append(drive+":") ... return driveletters ... >>> harddisks() ['C:', 'F:'] -- Thank you for observing all safety precautions -- http://mail.python.org/mailman/listinfo/python-list
Re: Determine if windows drive letter is hard drive or optical from python?
Magnus Lycka <[EMAIL PROTECTED]>: >Wolfgang Strobl wrote: >> ... for drive in string.letters[len(string.letters)/2:]: > >Or better... >..for drive in string.ascii_uppercase: > >string.letters differ with locale, but Windows drives are always >only A-Z (right?) and just iterating over upper case (or lower) >seems more clear than to iterate over half of the sum of both... Ooops. Your're right, of course. In my defense, I could argue that it was a cut&paste job, from a program written long ago ... -- Thank you for observing all safety precautions -- http://mail.python.org/mailman/listinfo/python-list