diff --git a/twander.py b/twander.py index e2f187d..e948e89 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 2.70 2003/01/19 02:41:22 tundra Exp $" +RCSID = "$Id: twander.py,v 2.71 2003/01/19 04:55:29 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -45,12 +45,18 @@ OSNAME = os.name +# If we're on Win32, try to load win32all stuff if possible + if OSNAME == 'nt': try: from win32api import GetLogicalDriveStrings as GetDrives + from win32api import GetUserName, GetFileAttributes + import win32con + WIN32ALL = TRUE except: - def GetDrives(): - return "" + WIN32ALL = FALSE + +# Get unix password and group features if OSNAME == 'posix': import grp @@ -219,12 +225,34 @@ # General Constants -KB = 1024 # 1 KB constant -MB = KB * KB # 1 MB constant -GB = MB * KB # 1 GB constant -HOSTNAME = getfqdn() # Full name of this host -POLLINT = 20 # Interval (ms) the poll routine should run -REFRESHINT = 3000 # Interval (ms) for automatic refresh +KB = 1024 # 1 KB constant +MB = KB * KB # 1 MB constant +GB = MB * KB # 1 GB constant +POLLINT = 20 # Interval (ms) the poll routine should run +REFRESHINT = 3000 # Interval (ms) for automatic refresh + +# Get hostname + +HOSTNAME = getfqdn() # Full name of this host + +# Get the user name + +if OSNAME == 'nt': + USERNAME = os.getenv("LOGNAME") + + +elif OSNAME == 'posix': + USERNAME = os.getenv("USER") + +else: + USERNAME = "" + +# Concatenate them if we got a user name + +if USERNAME: + FULLNAME = "%s@%s" % (USERNAME, HOSTNAME) +else: + FULLNAME = HOSTNAME # Key & Button Event Masks @@ -363,11 +391,12 @@ hABOUT = 'About' hCOMMANDS = 'Command Definitions' -hKEYS = 'Keyboard Assignments' hDIRSC = 'Directory Shortcuts' +hINTVBLS = 'Internal Program Variables' +hKEYS = 'Keyboard Assignments' hNONE = 'No %s Found.' +hOPTVBLS = 'User-Settable Options' hUSERVBLS = 'User-Defined Variables' -hVBLSOPTS = 'Internal Variables & Options' # Errors @@ -441,7 +470,7 @@ # List of internal program variables to dump during debug sessions -DebugVars = ["RCSID", "OSNAME", "HOSTNAME", "OPTIONS", "CONF", "HOME", "PSEP", "POLLINT"] +DebugVars = ["RCSID", "OSNAME", "HOSTNAME", "USERNAME", "OPTIONS", "CONF", "HOME", "PSEP", "POLLINT"] ##### @@ -492,7 +521,10 @@ # Get Win32 drive string, split on nulls, and get # rid of any resulting null entries. - return filter(lambda x : x, GetDrives().split('\x00')) + if WIN32ALL: + return filter(lambda x : x, GetDrives().split('\x00')) + else: + return "" # End of 'GetWin32Drives()' @@ -924,10 +956,11 @@ # Setup the cascading submenus self.UserVbls = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) - self.CmdDefs = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) - self.VblsOpts = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) - self.Keys = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR,font=(MFNAME, MFSZ, MFWT)) - self.DirSCs = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) + self.CmdDefs = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) + self.IntVbls = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) + self.OptVbls = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) + self.Keys = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) + self.DirSCs = Menu(self.HelpBtn.menu, foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) # Setup the Directory Listing and Scrollbars @@ -1226,7 +1259,7 @@ def UpdateTitle(self, mainwin): - mainwin.title(PROGNAME + " " + VERSION + " " + HOSTNAME + \ + mainwin.title(PROGNAME + " " + VERSION + " " + FULLNAME + \ ": "+ UI.CurrentDir + " Total Files: " + \ str(self.DirList.size()) + \ " Total Size: " + FileLength(self.TotalSize)) @@ -2504,7 +2537,8 @@ for mname, mvbl, mlist in ((hUSERVBLS, UI.UserVbls, GetUserVbls()), (hCOMMANDS, UI.CmdDefs, GetCommandTable()), - (hVBLSOPTS, UI.VblsOpts, GetIntVars() + GetOptions()), + (hINTVBLS, UI.IntVbls, GetIntVars()), + (hOPTVBLS, UI.OptVbls, GetOptions()), (hKEYS, UI.Keys, GetKeyBindings()), (hDIRSC, UI.DirSCs, GetDirShortcuts())): @@ -2711,6 +2745,7 @@ for v in DebugVars: debuginfo.append(v + " " * (12-len(v)) + (str(eval(v)) or dNULL)) + debuginfo.sort() return debuginfo # End of 'GetIntVars()'