240
240
return _ensure_unicode(get_host_name())
243
def _ensure_with_dir(path):
244
if not os.path.split(path)[0] or path.startswith(u'*') or path.startswith(u'?'):
245
return u'./' + path, True
249
def _undo_ensure_with_dir(path, corrected):
243
257
def glob_expand(file_list):
244
258
"""Replacement for glob expansion by the shell.
257
271
expanded_file_list = []
258
272
for possible_glob in file_list:
274
# work around bugs in glob.glob()
275
# - Python bug #1001604 ("glob doesn't return unicode with ...")
276
# - failing expansion for */* with non-iso-8859-* chars
277
possible_glob, corrected = _ensure_with_dir(possible_glob)
259
278
glob_files = glob.glob(possible_glob)
261
280
if glob_files == []:
262
281
# special case to let the normal code path handle
263
282
# files that do not exists
264
expanded_file_list.append(possible_glob)
283
expanded_file_list.append(
284
_undo_ensure_with_dir(possible_glob, corrected))
286
glob_files = [_undo_ensure_with_dir(elem, corrected) for elem in glob_files]
266
287
expanded_file_list += glob_files
267
return expanded_file_list
289
return [elem.replace(u'\\', u'/') for elem in expanded_file_list]
292
def get_app_path(appname):
293
"""Look up in Windows registry for full path to application executable.
294
Typicaly, applications create subkey with their basename
295
in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
297
:param appname: name of application (if no filename extension
298
is specified, .exe used)
299
:return: full path to aplication executable from registry,
300
or appname itself if nothing found.
304
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
305
r'SOFTWARE\Microsoft\Windows'
306
r'\CurrentVersion\App Paths')
307
except EnvironmentError:
311
if not os.path.splitext(basename)[1]:
312
basename = appname + '.exe'
315
fullpath = _winreg.QueryValue(hkey, basename)
319
_winreg.CloseKey(hkey)