示例#1
0
def create_shortcut(r, what, where=''):
    # TODO Move to windows helpers
    print('\n\n+---- Creating Shortcut ----')
    print('What = %s\n Where=%s' % (what, where))
    run_in    = ''
    what_args = ''
    if isinstance(what, tuple):
        tup       = what
        what      = tup[0]
        what_args = tup[1]
        run_in    = tup[2]
        if run_in == ' ':
            run_in = ''
        if what_args == ' ':
            what_args = ''
    if where == '':
        target = what + '.lnk'
    else:
        import ubelt as ub
        ub.ensuredir(where)
        base_what = os.path.basename(what)
        if len(base_what) > 0:
            if base_what[-1] in ['"', "'"]:
                base_what = base_what[0:-1]

        target = where + '/' + base_what + '.lnk'
    helpers_vbs = r.f.create_shortcut_vbs
    cmd = 'cscript "%s" "%s" "%s" "%s" "%s"' % (helpers_vbs, target, what,
                                                what_args, run_in)
    print(cmd)
    call(cmd)
示例#2
0
def create_shortcut(r, what, where=''):
    # TODO Move to windows helpers
    print('\n\n+---- Creating Shortcut ----')
    print('What = %s\n Where=%s' % (what, where))
    run_in = ''
    what_args = ''
    if isinstance(what, tuple):
        tup = what
        what = tup[0]
        what_args = tup[1]
        run_in = tup[2]
        if run_in == ' ':
            run_in = ''
        if what_args == ' ':
            what_args = ''
    if where == '':
        target = what + '.lnk'
    else:
        import utool as ut
        ut.ensuredir(where)
        base_what = os.path.basename(what)
        if len(base_what) > 0:
            if base_what[-1] in ['"', "'"]:
                base_what = base_what[0:-1]

        target = where + '/' + base_what + '.lnk'
    helpers_vbs = r.f.create_shortcut_vbs
    cmd = 'cscript "%s" "%s" "%s" "%s" "%s"' % (helpers_vbs, target, what,
                                                what_args, run_in)
    print(cmd)
    call(cmd)
示例#3
0
def save_power_settings_pref(r):
    (out, err) = rob_helpers.call('POWERCFG -LIST')
    outlines = out.split('\n')
    for line in outlines:
        if '(Balanced)' in line:
            guid_begin_pos = 19
            guid_str = line[19:55]
    rob_helpers.dircheck(r.d.PORT_SETTINGS + '\WinPowerDir')
    rob_helpers.call(r'POWERCFG -EXPORT "%PORT_SETTINGS%\WinPowerDir"\ '+guid_str)
示例#4
0
def save_power_settings_pref(r):
    (out, err) = rob_helpers.call('POWERCFG -LIST')
    outlines = out.split('\n')
    for line in outlines:
        if '(Balanced)' in line:
            guid_begin_pos = 19
            guid_str = line[19:55]
    rob_helpers.dircheck(r.d.PORT_SETTINGS + '\WinPowerDir')
    rob_helpers.call(r'POWERCFG -EXPORT "%PORT_SETTINGS%\WinPowerDir"\ '+guid_str)
示例#5
0
def symlink(r, source=None, target=None):
    'Creates a hard link to the source in the current directory or linked_dest if specified'
    if source is None:
        raise Exception('must at least specify a source')
    #if target == None:
    #target = slash_fix('C:/tmp/'+os.path.basename(source))
    if sys.platform == 'win32':
        if os.path.isdir(source):
            call('MKLINK /D "%s" "%s"' % (target, source))
        else:
            call('MKLINK "%s" "%s"' % (target, source))
    else:
        print(os.path.islink(target))
        call(['ln', '-s', os.path.normpath(source), os.path.normpath(target)])
示例#6
0
def symlink(r, source=None, target=None):
    'Creates a hard link to the source in the current directory or linked_dest if specified'
    if source is None:
        raise Exception('must at least specify a source')
    #if target == None:
        #target = slash_fix('C:/tmp/'+os.path.basename(source))
    if sys.platform == 'win32':
        if os.path.isdir(source):
            call('MKLINK /D "%s" "%s"' % (target, source))
        else:
            call('MKLINK "%s" "%s"' % (target, source))
    else:
        print(os.path.islink(target))
        call(['ln', '-s', os.path.normpath(source),  os.path.normpath(target)])
示例#7
0
def send_command(r, remote, remote_cmd):
    args = ['ssh', '-X', remote, '"' + remote_cmd + '"']
    cmdstr = ' '.join(args)
    print(cmdstr)
    rob_helpers.call(cmdstr)
示例#8
0
def send_command(r, remote, remote_cmd):
    args = ['ssh', '-X', remote, '"' + remote_cmd + '"']
    cmdstr = ' '.join(args)
    print(cmdstr)
    rob_helpers.call(cmdstr)
示例#9
0
def nircmd(r, command):
    # r.f.nircmd_exe + '
    rob_helpers.call('nircmd ' + command)
示例#10
0
def nircmd(r, command):
    # r.f.nircmd_exe + '
    rob_helpers.call('nircmd ' + command)