コード例 #1
0
 def run_program(entry, path, parent):  # noqa
     import re
     cmdline = entry_to_cmdline(entry, path)
     flags = win32con.CREATE_DEFAULT_ERROR_MODE | win32con.CREATE_NEW_PROCESS_GROUP
     if re.match(r'"[^"]+?(.bat|.cmd|.com)"', cmdline, flags=re.I):
         flags |= win32con.CREATE_NO_WINDOW
         console = ' (console)'
     else:
         flags |= win32con.DETACHED_PROCESS
         console = ''
     print('Running Open With commandline%s:' % console,
           repr(entry['cmdline']), ' |==> ', repr(cmdline))
     try:
         with sanitize_env_vars():
             process_handle, thread_handle, process_id, thread_id = CreateProcess(
                 None, cmdline, None, None, False, flags, None, None,
                 STARTUPINFO())
         WaitForInputIdle(process_handle, 2000)
     except Exception as err:
         return error_dialog(
             parent,
             _('Failed to run'),
             _('Failed to run program, click "Show Details" for more information'
               ),
             det_msg='Command line: %r\n%s' % (cmdline, as_unicode(err)))
コード例 #2
0
ファイル: open_with.py プロジェクト: JapaChin/calibre
 def run_program(entry, path, parent):  # noqa
     cmdline = entry_to_cmdline(entry, path)
     print('Running Open With commandline:', repr(entry['cmdline']), ' |==> ', repr(cmdline))
     try:
         with sanitize_env_vars():
             process_handle, thread_handle, process_id, thread_id = CreateProcess(
                 None, cmdline, None, None, False, win32con.CREATE_DEFAULT_ERROR_MODE | win32con.CREATE_NEW_PROCESS_GROUP | win32con.DETACHED_PROCESS,
                 None, None, STARTUPINFO())
         WaitForInputIdle(process_handle, 2000)
     except Exception as err:
         return error_dialog(
             parent, _('Failed to run'), _(
             'Failed to run program, click "Show Details" for more information'),
             det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
コード例 #3
0
ファイル: open_with.py プロジェクト: WilliamRJohns/glacier.io
 def run_program(entry, path, parent):  # noqa
     cmdline = entry_to_cmdline(entry, path)
     print('Running Open With commandline:', repr(entry['cmdline']), ' |==> ', repr(cmdline))
     try:
         with sanitize_env_vars():
             process_handle, thread_handle, process_id, thread_id = CreateProcess(
                 None, cmdline, None, None, False, win32con.CREATE_DEFAULT_ERROR_MODE | win32con.CREATE_NEW_PROCESS_GROUP | win32con.DETACHED_PROCESS,
                 None, None, STARTUPINFO())
         WaitForInputIdle(process_handle, 2000)
     except Exception as err:
         return error_dialog(
             parent, _('Failed to run'), _(
             'Failed to run program, click "Show Details" for more information'),
             det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
コード例 #4
0
ファイル: open_with.py プロジェクト: JapaChin/calibre
def run_program(entry, path, parent):
    import subprocess
    cmdline = entry_to_cmdline(entry, path)
    print('Running Open With commandline:', repr(cmdline))
    try:
        with sanitize_env_vars():
            process = subprocess.Popen(cmdline)
    except Exception as err:
        return error_dialog(
            parent, _('Failed to run'), _(
            'Failed to run program, click "Show Details" for more information'),
            det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
    t = Thread(name='WaitProgram', target=process.wait)
    t.daemon = True
    t.start()
コード例 #5
0
def run_program(entry, path, parent):
    import subprocess
    cmdline = entry_to_cmdline(entry, path)
    print('Running Open With commandline:', repr(cmdline))
    try:
        with sanitize_env_vars():
            process = subprocess.Popen(cmdline)
    except Exception as err:
        return error_dialog(
            parent, _('Failed to run'), _(
            'Failed to run program, click "Show details" for more information'),
            det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
    t = Thread(name='WaitProgram', target=process.wait)
    t.daemon = True
    t.start()
コード例 #6
0
 def run_program(entry, path, parent):  # noqa
     import re
     cmdline = entry_to_cmdline(entry, path)
     flags = subprocess.CREATE_DEFAULT_ERROR_MODE | subprocess.CREATE_NEW_PROCESS_GROUP
     if re.match(r'"[^"]+?(.bat|.cmd|.com)"', cmdline, flags=re.I):
         flags |= subprocess.CREATE_NO_WINDOW
         console = ' (console)'
     else:
         flags |= subprocess.DETACHED_PROCESS
         console = ''
     print('Running Open With commandline%s:' % console, repr(entry['cmdline']), ' |==> ', repr(cmdline))
     try:
         with sanitize_env_vars():
             winutil.run_cmdline(cmdline, flags, 2000)
     except Exception as err:
         return error_dialog(
             parent, _('Failed to run'), _(
             'Failed to run program, click "Show details" for more information'),
             det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
コード例 #7
0
ファイル: open_with.py プロジェクト: JimmXinu/calibre
 def run_program(entry, path, parent):  # noqa
     import re
     cmdline = entry_to_cmdline(entry, path)
     flags = win32con.CREATE_DEFAULT_ERROR_MODE | win32con.CREATE_NEW_PROCESS_GROUP
     if re.match(r'"[^"]+?(.bat|.cmd|.com)"', cmdline, flags=re.I):
         flags |= win32con.CREATE_NO_WINDOW
         console = ' (console)'
     else:
         flags |= win32con.DETACHED_PROCESS
         console = ''
     print('Running Open With commandline%s:' % console, repr(entry['cmdline']), ' |==> ', repr(cmdline))
     try:
         with sanitize_env_vars():
             process_handle, thread_handle, process_id, thread_id = CreateProcess(
                 None, cmdline, None, None, False,  flags,
                 None, None, STARTUPINFO())
         WaitForInputIdle(process_handle, 2000)
     except Exception as err:
         return error_dialog(
             parent, _('Failed to run'), _(
             'Failed to run program, click "Show Details" for more information'),
             det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))