View | Details | Raw Unified | Return to bug 55948
Collapse All | Expand All

(-)a/gpupdate/gpoa/util/windows.py (-6 / +26 lines)
Lines 18-23 Link Here
18
18
19
19
20
import os
20
import os
21
import re
22
import subprocess
21
from pathlib import Path
23
from pathlib import Path
22
from samba import getopt as options
24
from samba import getopt as options
23
from samba import NTSTATUSError
25
from samba import NTSTATUSError
Lines 317-335 Link Here
317
    variables['SystemDrive'] = '/'
319
    variables['SystemDrive'] = '/'
318
    variables['DesktopDir'] = xdg_get_desktop(username, variables['HOME'])
320
    variables['DesktopDir'] = xdg_get_desktop(username, variables['HOME'])
319
321
322
    class_smbcreds = smbcreds()
323
    variables['USERDOMAIN'] = class_smbcreds.get_domain()
324
    variables['ALLUSERSPROFILE'] = '/usr/local/share'
325
    variables['COMPUTERNAME'] = subprocess.run(["hostname", "--short"], capture_output=True, text=True, check=True).stdout.strip()
326
    variables['PROGRAMDATA'] = '/usr/local/share'
327
    variables['PROGRAMFILES'] = '/usr/bin'
328
    variables['PROGRAMFILES(x86)'] = '/usr/bin'
329
    variables['WINDIR'] = '/'
330
320
    if username:
331
    if username:
321
        variables['LogonUser'] = username
332
        variables['LogonUser'] = username
322
        variables['HOME'] = get_homedir(username)
333
        variables['HOME'] = get_homedir(username)
323
        variables['HOMEPATH'] = get_homedir(username)
334
        variables['HOMEPATH'] = get_homedir(username)
324
335
336
        variables['USERNAME'] = username
337
        variables['USERPROFILE'] = get_homedir(username)
338
325
        variables['StartMenuDir'] = os.path.join(
339
        variables['StartMenuDir'] = os.path.join(
326
            variables['HOME'], '.local', 'share', 'applications')
340
            variables['HOME'], '.local', 'share', 'applications')
327
341
328
    result = text
342
    result = text
343
329
    for var in variables.keys():
344
    for var in variables.keys():
330
        result = result.replace('%{}%'.format(var),
345
331
                                 variables[var] if variables[var][-1] == '/'
346
        pattern = re.compile(re.escape(f"%{var}%"), re.IGNORECASE)
332
                                 else variables[var] +'/')
347
        result = pattern.sub(variables[var], result)
333
348
334
    return result
349
    return result
335
350
Lines 338-347 Link Here
338
    '''
353
    '''
339
    Try to make Windows path look like UNIX.
354
    Try to make Windows path look like UNIX.
340
    '''
355
    '''
341
    result = text
356
    if not text:
357
        return text
358
359
    result = str(text)
360
361
#    if text.lower().endswith('.exe'):
362
#        result = text.lower().replace('\\', '/').replace('.exe', '').rpartition('/')[2]
342
363
343
    if text.lower().endswith('.exe'):
364
    result = result.replace('\\', '/')
344
        result = text.lower().replace('\\', '/').replace('.exe', '').rpartition('/')[2]
345
365
346
    return result
366
    return result
347
367

Return to bug 55948