diff --git a/twander.py b/twander.py index 265522a..e41a4d4 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 2.72 2003/01/19 06:12:56 tundra Exp $" +RCSID = "$Id: twander.py,v 2.73 2003/01/19 08:03:49 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -51,8 +51,10 @@ if OSNAME == 'nt': try: from win32api import GetLogicalDriveStrings as GetDrives - from win32api import GetUserName, GetFileAttributes + from win32api import GetUserName, GetFileAttributes, GetComputerName import win32con + from win32security import * + WIN32HOST = GetComputerName() WIN32ALL = TRUE except: WIN32ALL = FALSE @@ -79,50 +81,51 @@ # General Program Commands -CLRHIST = '' # Clear Command History -MOUSECTX = '' # Pop-up Context Menu -MOUSEDIR = '' # Pop-up Directory Menu -KEYPRESS = '' # Any keypress (for commands) -QUITPROG = '' # Quit the program -READCONF = '' # Re-read the configuration file -REFRESH = '' # Refresh screen -TOGDETAIL = '' # Toggle detail view +CLRHIST = '' # Clear Command History +MOUSECTX = '' # Pop-up Context Menu +MOUSEDIR = '' # Pop-up Directory Menu +KEYPRESS = '' # Any keypress (for commands) +QUITPROG = '' # Quit the program +READCONF = '' # Re-read the configuration file +REFRESH = '' # Refresh screen +TOGDETAIL = '' # Toggle detail view +TOGWIN32ALL = '' # Toggle win32all features, if available # Directory Navigation -CHANGEDIR = '' # Enter a new path -DIRHOME = '' # Goto $HOME -DIRBACK = '' # Goto previous directory -DIRROOT = '' # Goto root directory -DIRSTART = '' # Goto starting directory -DIRUP = '' # Go up one directory level -DRIVELIST = '' # On Win32, display Drive List View if possible -MOUSEBACK = '' # Go back one directory with mouse -MOUSEUP = '' # Go up one directory with mouse +CHANGEDIR = '' # Enter a new path +DIRHOME = '' # Goto $HOME +DIRBACK = '' # Goto previous directory +DIRROOT = '' # Goto root directory +DIRSTART = '' # Goto starting directory +DIRUP = '' # Go up one directory level +DRIVELIST = '' # On Win32, display Drive List View if possible +MOUSEBACK = '' # Go back one directory with mouse +MOUSEUP = '' # Go up one directory with mouse # Selection Keys -SELALL = '' # Select all items -SELINV = '' # Invert the current selection -SELNONE = '' # Unselect all items -SELNEXT = '' # Select next item -SELPREV = '' # Select previous item -SELEND = '' # Select bottom item -SELTOP = '' # Select top item +SELALL = '' # Select all items +SELINV = '' # Invert the current selection +SELNONE = '' # Unselect all items +SELNEXT = '' # Select next item +SELPREV = '' # Select previous item +SELEND = '' # Select bottom item +SELTOP = '' # Select top item # Scrolling Commands -PGDN = '' # Move page down -PGUP = '' # Move page up -PGRT = '' # Move page right -PGLFT = '' # Move page left +PGDN = '' # Move page down +PGUP = '' # Move page up +PGRT = '' # Move page right +PGLFT = '' # Move page left # Execute Commands -RUNCMD = '' # Run arbitrary user command -SELKEY = '' # Select item w/keyboard -MOUSESEL = '' # Select item w/mouse +RUNCMD = '' # Run arbitrary user command +SELKEY = '' # Select item w/keyboard +MOUSESEL = '' # Select item w/mouse # Name The Key/Mouse Assignments Which We Do Not Allow To Be Rebound In The Config File @@ -219,6 +222,7 @@ NODETAILS = FALSE # TRUE means details can never be displayed NONAVIGATE = FALSE # TRUE means that all directory navigation is prevented USETHREADS = TRUE # Use threads on Unix +USEWIN32ALL = TRUE # Use win32all features if available WARN = TRUE # Warnings on ##### @@ -240,7 +244,7 @@ # Get the user name if OSNAME == 'nt': - if WIN32ALL: + if WIN32ALL and USEWIN32ALL: USERNAME = GetUserName() else: USERNAME = os.getenv("LOGNAME") @@ -292,7 +296,7 @@ # Stat-Related Constants -if WIN32ALL: +if WIN32ALL and USEWIN32ALL: # Used with win32all-based permissions logic. # Format for each entry is: (mask to test, symbol if true). @@ -317,11 +321,12 @@ "10":"-", "12":"l", "14":"s"} # Size of each status display field including trailing space +# These are sized for the worst-case: Win32 with win32all features -ST_SZMODE = 12 # Need more space with win32all (11) than Unix (10) +ST_SZMODE = 12 ST_SZNLINK = 5 -ST_SZUNAME = 12 -ST_SZGNAME = 12 +ST_SZUNAME = 18 +ST_SZGNAME = 18 ST_SZLEN = 12 ST_SZMTIME = 18 @@ -540,7 +545,7 @@ # Get Win32 drive string, split on nulls, and get # rid of any resulting null entries. - if WIN32ALL: + if WIN32ALL and USEWIN32ALL: return filter(lambda x : x, GetDrives().split('\x00')) else: return "" @@ -602,6 +607,7 @@ "READCONF":READCONF, "REFRESH":REFRESH, "TOGDETAIL":TOGDETAIL, + "TOGWIN32ALL":TOGWIN32ALL, "CHANGEDIR":CHANGEDIR, "DIRHOME":DIRHOME, "DIRBACK":DIRBACK, @@ -1033,6 +1039,9 @@ # Bind handler for "Toggle Detail" self.DirList.bind(self.KeyBindings["TOGDETAIL"], KeyToggleDetail) + # Bind handler for "Toggle win32all Features" + self.DirList.bind(self.KeyBindings["TOGWIN32ALL"], KeyToggleWin32All) + ### # Directory Navigation ### @@ -1465,6 +1474,17 @@ # End of 'KeyToggleDetail()' +##### +# Event Handler: Toggle win32all Features, If Available +##### + +def KeyToggleWin32All(event): + global USEWIN32ALL + + USEWIN32ALL = not USEWIN32ALL + +# End of 'KeyToggleWin32All()' + #------------------- Directory Navigation -----------------# @@ -2173,7 +2193,7 @@ continue # Do Win32-specific mode if win32all is loaded - if WIN32ALL: + if WIN32ALL and USEWIN32ALL: modlen = len(win32all_mode) @@ -2270,9 +2290,25 @@ # Handle Win32 systems elif OSNAME == 'nt': + + # Defaults owner = 'win32user' group = 'win32group' + if WIN32ALL and USEWIN32ALL: + try: + ho = GetFileSecurity(fn, OWNER_SECURITY_INFORMATION) + hg = GetFileSecurity(fn, GROUP_SECURITY_INFORMATION) + sido = ho.GetSecurityDescriptorOwner() + sidg = hg.GetSecurityDescriptorGroup() + owner = LookupAccountSid(WIN32HOST, sido)[0] + group = LookupAccountSid(WIN32HOST, sidg)[0] + owner = owner[:ST_SZUNAME-1] + group = group[:ST_SZGNAME-1] + except: + owner = 'Unavailable' + group = 'Unavailable' + # Default names for all other OSs else: owner = OSNAME + 'user' @@ -2619,7 +2655,6 @@ UI.HelpBtn['menu'] = UI.HelpBtn.menu UI.HelpBtn.config(state=NORMAL) - ##### # Dump requested debug information ##### @@ -2881,7 +2916,7 @@ # Options (and their default values) which can be set in the configuration file UI.OptionsBoolean = {"AUTOREFRESH":AUTOREFRESH, "NODETAILS":NODETAILS, "NONAVIGATE":NONAVIGATE, - "USETHREADS":USETHREADS, "WARN":WARN} + "USETHREADS":USETHREADS, "USEWIN32ALL":USEWIN32ALL, "WARN":WARN} UI.OptionsNumeric = {"DEBUGLEVEL":DEBUGLEVEL, "FSZ":FSZ, "HEIGHT":HEIGHT, "MAXDIR":MAXDIR, "MAXDIRBUF":MAXDIRBUF, "MAXHIST":MAXHIST, "MAXHISTBUF":MAXHISTBUF,