83 |
84 |
84 def getRealName(): |
85 def getRealName(): |
85 """ |
86 """ |
86 Function to get the real name of the user. |
87 Function to get the real name of the user. |
87 |
88 |
88 @return real name of the user (string) |
89 @return real name of the user |
|
90 @rtype str |
89 """ |
91 """ |
90 if isWindowsPlatform(): |
92 if isWindowsPlatform(): |
91 return win32_getRealName() |
93 return win32_getRealName() |
92 else: |
94 else: |
93 user = getpass.getuser() |
95 user = getpass.getuser() |
110 |
113 |
111 def getEnvironmentEntry(key, default=None): |
114 def getEnvironmentEntry(key, default=None): |
112 """ |
115 """ |
113 Module function to get an environment entry. |
116 Module function to get an environment entry. |
114 |
117 |
115 @param key key of the requested environment entry (string) |
118 @param key key of the requested environment entry |
116 @param default value to be returned, if the environment doesn't contain |
119 @type str |
117 the requested entry (string) |
120 @param default value to be returned, if the environment doesn't contain the |
118 @return the requested entry or the default value, if the entry wasn't |
121 requested entry |
119 found (string or None) |
122 @type str |
|
123 @return the requested entry or the default value, if the entry wasn't found |
|
124 @rtype str |
120 """ |
125 """ |
121 if key in os.environ: |
126 if key in os.environ: |
122 entryKey = key |
127 entryKey = key |
123 elif isWindowsPlatform() and key.lower() in os.environ: |
128 elif isWindowsPlatform() and key.lower() in os.environ: |
124 entryKey = key.lower() |
129 entryKey = key.lower() |
153 |
158 |
154 def win32_Kill(pid): |
159 def win32_Kill(pid): |
155 """ |
160 """ |
156 Function to provide an os.kill equivalent for Win32. |
161 Function to provide an os.kill equivalent for Win32. |
157 |
162 |
158 @param pid process id (integer) |
163 @param pid process id |
159 @return result of the kill (boolean) |
164 @type int |
|
165 @return result of the kill |
|
166 @rtype bool |
160 """ |
167 """ |
161 import win32api # __IGNORE_WARNING_I102__ |
168 import win32api # __IGNORE_WARNING_I102__ |
162 |
169 |
163 handle = win32api.OpenProcess(1, 0, pid) |
170 handle = win32api.OpenProcess(1, 0, pid) |
164 return 0 != win32api.TerminateProcess(handle, 0) |
171 return 0 != win32api.TerminateProcess(handle, 0) |
184 |
192 |
185 def win32_getRealName(): |
193 def win32_getRealName(): |
186 """ |
194 """ |
187 Function to get the user's real name (aka. display name) under Win32. |
195 Function to get the user's real name (aka. display name) under Win32. |
188 |
196 |
189 @return real name of the current user (string) |
197 @return real name of the current user |
|
198 @rtype str |
190 """ |
199 """ |
191 GetUserNameEx = ctypes.windll.secur32.GetUserNameExW |
200 GetUserNameEx = ctypes.windll.secur32.GetUserNameExW |
192 NameDisplay = 3 |
201 NameDisplay = 3 |
193 |
202 |
194 size = ctypes.pointer(ctypes.c_ulong(0)) |
203 size = ctypes.pointer(ctypes.c_ulong(0)) |