当前位置: 首页>>代码示例>>Python>>正文


Python os.startfile方法代码示例

本文整理汇总了Python中os.startfile方法的典型用法代码示例。如果您正苦于以下问题:Python os.startfile方法的具体用法?Python os.startfile怎么用?Python os.startfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os的用法示例。


在下文中一共展示了os.startfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: shutdown

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def shutdown():
    if lp_events.timer != None:
        lp_events.timer.cancel()
    scripts.to_run = []
    for x in range(9):
        for y in range(9):
            if scripts.threads[x][y] != None:
                scripts.threads[x][y].kill.set()
    if window.lp_connected:
        scripts.unbind_all()
        lp_events.timer.cancel()
        launchpad_connector.disconnect(lp)
        window.lp_connected = False
    logger.stop()
    if window.restart:
        if IS_EXE:
            os.startfile(sys.argv[0])
        else:
            os.execv(sys.executable, ["\"" + sys.executable + "\""] + sys.argv)
    sys.exit("[LPHK] Shutting down...") 
开发者ID:nimaid,项目名称:LPHK,代码行数:22,代码来源:LPHK.py

示例2: open_image

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def open_image(directory, image):
    answer = input("Would you like to open the image of the computed passport file? [y] / n : ").lower()

    if answer in ("y", "yes") or answer == "":
        try:
            # TODO: Test abspath() on Windows
            image_path = os.path.join(os.pardir, os.pardir, "docs", "images", directory, image)
            print(image_path)

            if sys.platform.startswith('darwin'):
                subprocess.call(('open', image_path))
            elif os.name == 'nt':
                os.startfile(image_path)
            elif os.name == 'posix':
                subprocess.call(('xdg-open', image_path))

        except Exception:
            print("%s- An unexpected error occurred. The file could not be opened%s" % RED)
            for msg in sys.exc_info():
                print("\033[31m!", str(msg))
    elif answer in ("n", "no"):
        exit()
    else:
        print("%sInvalid response%s" % RED)
        open_image(directory, image) 
开发者ID:Arg0s1080,项目名称:mrz,代码行数:27,代码来源:functions.py

示例3: explore

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def explore(path):
    if path:
        if os.path.exists(path):
            path = os.path.dirname(path)
            platform = os_qeury()
            if platform == "darwin":
                subprocess.Popen(['open',path])
                return True
                
            elif platform == "win32":
                os.startfile(path)
                return True
        
        log.info("File dose not exist")
        return False
        
    log.info("No file name spacified")
    return False 
开发者ID:liorbenhorin,项目名称:pipeline,代码行数:20,代码来源:files.py

示例4: run

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def run(filename):
    if filename:
        if os.path.exists(filename):
            if sys.platform == "win32":
                os.startfile(filename)
                return True
            else:
                opener ="open" if sys.platform == "darwin" else "xdg-open"
                subprocess.call([opener, filename]) 
                return True 
    
        log.info("File dose not exist")
        return False
        
    log.info("No file name spacified")
    return False 
开发者ID:liorbenhorin,项目名称:pipeline,代码行数:18,代码来源:files.py

示例5: _create_image_from_map

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def _create_image_from_map(map_file, out_img, format):

    out_img += ".%s" % format
    #print out_img
    params = ["shp2img", "-m", map_file, "-i", format, "-o", out_img]

    os.environ['PATH'] = DLL_LOCATION + ';' + os.environ['PATH']

    p = Popen(params, stdout=PIPE, bufsize=1)
    with p.stdout:
        for line in iter(p.stdout.readline, b''):
            print(line)

    p.wait() # wait for the subprocess to exit

    #os.startfile(out_img)
    return out_img 
开发者ID:geographika,项目名称:mappyfile,代码行数:19,代码来源:helper.py

示例6: create_image_from_map

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def create_image_from_map(map_file, dll_location):

    of = tempfile.NamedTemporaryFile(delete=False, suffix=".png", prefix="tmp_")
    of.close()

    logging.debug("Creating file %s", of.name)
    # [SHP2IMG] -m [MAPFILE] -i png -o [RESULT]
    params = ["shp2img","-m", map_file,"-i","png","-o", of.name]

    os.environ['PATH'] = dll_location + ';' + os.environ['PATH']
    os.environ['PROJ_LIB'] = os.path.join(dll_location, "proj\SHARE")

    logging.debug(" ".join(params))

    p = Popen(params, stdout=PIPE, bufsize=1)
    with p.stdout:
        print(map_file)
        for line in iter(p.stdout.readline, b''):
            print(line)

    p.wait() # wait for the subprocess to exit

    os.startfile(of.name) 
开发者ID:geographika,项目名称:mappyfile,代码行数:25,代码来源:image_from_mapfile.py

示例7: _showQRCodeImg

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def _showQRCodeImg(self, str):
        if self.commandLineQRCode:
            qrCode = QRCode('https://login.weixin.qq.com/l/' + self.uuid)
            self._showCommandLineQRCode(qrCode.text(1))
        else:
            url = 'https://login.weixin.qq.com/qrcode/' + self.uuid
            params = {
                't': 'webwx',
                '_': int(time.time())
            }

            data = self._post(url, params, False)
            if data == '':
                return
            QRCODE_PATH = self._saveFile('qrcode.jpg', data, '_showQRCodeImg')
            if str == 'win':
                os.startfile(QRCODE_PATH)
            elif str == 'macos':
                subprocess.call(["open", QRCODE_PATH])
            else:
                return 
开发者ID:Urinx,项目名称:WeixinBot,代码行数:23,代码来源:weixin.py

示例8: genqrcode

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def genqrcode(self):
        """
        @brief      outprint the qrcode to stdout on macos/linux
                    or open image on windows
        """
        if sys.platform.startswith('win'):
            url = self.wx_conf['API_qrcode_img'] + self.uuid
            params = {
                't': 'webwx',
                '_': int(time.time())
            }
            data = post(url, params, False)
            if data == '':
                return
            qrcode_path = save_file('qrcode.jpg', data, './')
            os.startfile(qrcode_path)
        else:
            str2qr_terminal(self.wx_conf['API_qrcode'] + self.uuid) 
开发者ID:Urinx,项目名称:WeixinBot,代码行数:20,代码来源:wechat_apis.py

示例9: open_config

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def open_config(self, event):
        """Opens Superpaper config folder, CONFIG_PATH."""
        if platform.system() == "Windows":
            try:
                os.startfile(sp_paths.CONFIG_PATH)
            except BaseException:
                show_message_dialog("There was an error trying to open the config folder.")
        elif platform.system() == "Darwin":
            try:
                subprocess.check_call(["open", sp_paths.CONFIG_PATH])
            except subprocess.CalledProcessError:
                show_message_dialog("There was an error trying to open the config folder.")
        else:
            try:
                subprocess.check_call(['xdg-open', sp_paths.CONFIG_PATH])
            except subprocess.CalledProcessError:
                show_message_dialog("There was an error trying to open the config folder.") 
开发者ID:hhannine,项目名称:superpaper,代码行数:19,代码来源:tray.py

示例10: psdump

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def psdump(self, filename=None, **kargs):
        """
        psdump(filename=None, layer_shift=0, rebuild=1)

        Creates an EPS file describing a packet. If filename is not provided a
        temporary file is created and gs is called.

        :param filename: the file's filename
        """
        from scapy.config import conf
        from scapy.utils import get_temp_file, ContextManagerSubprocess
        canvas = self.canvas_dump(**kargs)
        if filename is None:
            fname = get_temp_file(autoext=kargs.get("suffix", ".eps"))
            canvas.writeEPSfile(fname)
            if WINDOWS and conf.prog.psreader is None:
                os.startfile(fname)
            else:
                with ContextManagerSubprocess(conf.prog.psreader):
                    subprocess.Popen([conf.prog.psreader, fname])
        else:
            canvas.writeEPSfile(filename)
        print() 
开发者ID:secdev,项目名称:scapy,代码行数:25,代码来源:base_classes.py

示例11: pdfdump

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def pdfdump(self, filename=None, **kargs):
        """
        pdfdump(filename=None, layer_shift=0, rebuild=1)

        Creates a PDF file describing a packet. If filename is not provided a
        temporary file is created and xpdf is called.

        :param filename: the file's filename
        """
        from scapy.config import conf
        from scapy.utils import get_temp_file, ContextManagerSubprocess
        canvas = self.canvas_dump(**kargs)
        if filename is None:
            fname = get_temp_file(autoext=kargs.get("suffix", ".pdf"))
            canvas.writePDFfile(fname)
            if WINDOWS and conf.prog.pdfreader is None:
                os.startfile(fname)
            else:
                with ContextManagerSubprocess(conf.prog.pdfreader):
                    subprocess.Popen([conf.prog.pdfreader, fname])
        else:
            canvas.writePDFfile(filename)
        print() 
开发者ID:secdev,项目名称:scapy,代码行数:25,代码来源:base_classes.py

示例12: svgdump

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def svgdump(self, filename=None, **kargs):
        """
        svgdump(filename=None, layer_shift=0, rebuild=1)

        Creates an SVG file describing a packet. If filename is not provided a
        temporary file is created and gs is called.

        :param filename: the file's filename
        """
        from scapy.config import conf
        from scapy.utils import get_temp_file, ContextManagerSubprocess
        canvas = self.canvas_dump(**kargs)
        if filename is None:
            fname = get_temp_file(autoext=kargs.get("suffix", ".svg"))
            canvas.writeSVGfile(fname)
            if WINDOWS and conf.prog.svgreader is None:
                os.startfile(fname)
            else:
                with ContextManagerSubprocess(conf.prog.svgreader):
                    subprocess.Popen([conf.prog.svgreader, fname])
        else:
            canvas.writeSVGfile(filename)
        print() 
开发者ID:secdev,项目名称:scapy,代码行数:25,代码来源:base_classes.py

示例13: test_deprecated

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def test_deprecated(self):
        import nt
        filename = os.fsencode(support.TESTFN)
        with warnings.catch_warnings():
            warnings.simplefilter("error", DeprecationWarning)
            for func, *args in (
                (nt._getfullpathname, filename),
                (nt._isdir, filename),
                (os.access, filename, os.R_OK),
                (os.chdir, filename),
                (os.chmod, filename, 0o777),
                (os.getcwdb,),
                (os.link, filename, filename),
                (os.listdir, filename),
                (os.lstat, filename),
                (os.mkdir, filename),
                (os.open, filename, os.O_RDONLY),
                (os.rename, filename, filename),
                (os.rmdir, filename),
                (os.startfile, filename),
                (os.stat, filename),
                (os.unlink, filename),
                (os.utime, filename),
            ):
                self.assertRaises(DeprecationWarning, func, *args) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:test_os.py

示例14: launchFile

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def launchFile(filepath):
    if sys.platform.startswith('darwin'):
        subprocess.call(('open', filepath))
    elif os.name == 'nt':
        os.startfile(filepath)
    elif os.name == 'posix':
        subprocess.call(('xdg-open', filepath))


############################ String utilities ############################ 
开发者ID:svviz,项目名称:svviz,代码行数:12,代码来源:utilities.py

示例15: open_file_folder

# 需要导入模块: import os [as 别名]
# 或者: from os import startfile [as 别名]
def open_file_folder(path):
    try:
        if platform.system() == "Windows":
            os.startfile(path)
        elif platform.system() == "Darwin":
            subprocess.Popen(["open", path])
        else:
            subprocess.Popen(["xdg-open", path])
    except:
        print("[files] Could not open file or folder " + path) 
开发者ID:nimaid,项目名称:LPHK,代码行数:12,代码来源:files.py


注:本文中的os.startfile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。