Python os 模块,startfile() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用os.startfile()

项目:Freya    作者:areebbeigh    | 项目源码 | 文件源码
def play_music(p, l):
    """ Plays music """
    respond("playing music", prepend_positive_response=True)
    playlist = os.path.join(BASE_DIRECTORY, 'playlist.m3u')

    extensions = [
        ".mp3",
        ".m4a",
        ".ogg",
        ".flac",
    ]

    music_files = _get_all_files(preferences.get_music_dir(), extensions)

    with open(playlist, 'w') as f:
        for file in music_files:
            f.write(file + "\n")

    os.startfile(playlist)
项目:Spider    作者:vincenth520    | 项目源码 | 文件源码
def getQrcode(uuid):
    print('Please scan the QR code.')

    url = 'https://login.weixin.qq.com/qrcode/' + uuid

    req = request.Request(url)
    res = request.urlopen(req)

    f = open(QRImagePath, 'wb')
    f.write(res.read())
    f.close()
    time.sleep(1)

    if sys.platform.find('darwin') >= 0:
        subprocess.call(['open', QRImagePath])
    elif sys.platform.find('linux') >= 0:
        subprocess.call(['xdg-open', QRImagePath])
    else:
        os.startfile(QRImagePath)
项目:mgear    作者:miquelcampos    | 项目源码 | 文件源码
def editFile(self, widgetList):
        try:
            filepath = widgetList.selectedItems()[0].text().split("|")[-1][1:]
            if os.environ.get(MGEAR_SHIFTER_CUSTOMSTEP_KEY, ""):
                editPath = os.path.join(
                    os.environ.get(
                        MGEAR_SHIFTER_CUSTOMSTEP_KEY, ""), filepath)
            else:
                editPath = filepath
            if filepath:
                if sys.platform.startswith('darwin'):
                    subprocess.call(('open', editPath))
                elif os.name == 'nt':
                    os.startfile(editPath)
                elif os.name == 'posix':
                    subprocess.call(('xdg-open', editPath))
            else:
                pm.displayWarning("Please select one item from the list")
        except Exception:
            pm.displayError("The step can't be find or does't exists")
项目:pipeline    作者:liorbenhorin    | 项目源码 | 文件源码
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
项目:pipeline    作者:liorbenhorin    | 项目源码 | 文件源码
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
项目:Fuck_Login    作者:devzhan    | 项目源码 | 文件源码
def getCaptcha(self):
        captchaImgUrl = 'https://passport.lagou.com/vcode/create?from=register&refresh=%s' % time.time()
        # ???????
        f = open(CaptchaImagePath, 'wb')
        f.write(self.session.get(captchaImgUrl, headers=HEADERS).content)
        f.close()
        # ???????
        if sys.platform.find('darwin') >= 0:

            subprocess.call(['open', CaptchaImagePath])
        elif sys.platform.find('linux') >= 0:
            subprocess.call(['xdg-open', CaptchaImagePath])
        else:
            os.startfile(CaptchaImagePath)

        # ???????
        captcha = input("???????(% s)????: " % CaptchaImagePath)
        print('????????:% s' % captcha)
        return captcha
项目:modman    作者:haihala    | 项目源码 | 文件源码
def open_gui_editor(filename):
    """Opens default GUI text editor."""
    if sys.platform == "win32":
        os.startfile(filename)
    elif sys.platform.startswith("darwin"):
        try:
            subprocess.call(["open", filename])
        except FileNotFoundError:
            print("Your default editor \"{}\" could not be opened.")
            print("You can manually open \"{}\" if you want to edit it.".format(filename))
    elif sys.platform.startswith("linux"):
        try:
            subprocess.call(["xdg-open", filename])
        except FileNotFoundError:
            print("Your default editor \"{}\" could not be opened.")
            print("You can manually open \"{}\" if you want to edit it.".format(filename))
    else:
        print("Could not determine text editor.")
        print("You can manually open \"{}\" if you want to edit it.".format(filename))
项目:DawnlightSearch    作者:chg-hou    | 项目源码 | 文件源码
def _open_file_or_folder(self, path):
        import os, subprocess
        if not os.path.exists(path):
            logger.warning("File/path does not exist: " + path)
            msg = translate('statusbar', "File/path does not exist: ") + path
            self.show_statusbar_warning_msg_slot(msg)
            return
        try:
            QDesktopServices.openUrl(QUrl.fromLocalFile(path))
            # if sys.platform.startswith('darwin'):
            #     subprocess.call(('open', path))
            # elif os.name == 'nt':
            #     os.startfile(path)
            # elif os.name == 'posix':
            #     subprocess.call(('xdg-open', path))
        except:
            self.show_statusbar_warning_msg_slot((translate('statusbar',"Cannot open file: %s")) % path)
项目:stephanie-va    作者:SlapBot    | 项目源码 | 文件源码
def speak_from_os(self, speech_result_filename):
        self.speak_result = self.get_abs_filename(speech_result_filename)
        try:
            self.speak_result = self.get_abs_filename(speech_result_filename)
            # Check platform used
            if platform.system() == "Linux":
                os.system("xdg-open " + self.speak_result)
            elif platform.system() == "Darwin":
                os.system("afplay " + self.speak_result)
            elif platform.system() == "Windows":
                os.startfile(self.speak_result)
            else:
                os.system(self.speak_result)
        except:
            print("Default Audio Player for mp3 files is not set up, like vlc or something.")
        try:
            self.hibernate()
        except:
            print("Seems like eyed3 named package wasn't installed probably "
                  "Check back at the support tab in the main website. Or if you're "
                  "trying to close the application abruptly, keep pressing CTRL + C repeatedly.")
项目:tindieorderprintout    作者:limpkin    | 项目源码 | 文件源码
def do_print(self, evt):
        # genero el renderizador con propiedades del PDF
        t = Template(elements=[e.as_dict() for e in self.elements if not e.static])
        t.add_page()
        if not t['logo'] or not os.path.exists(t['logo']):
            # put a default logo so it doesn't trow an exception
            os.path.join(os.path.dirname(__file__), 'tutorial','logo.png')
            t.set('logo', logo)
        try:
            t.render(self.filename +".pdf")
        except:
            if DEBUG and False:
                import pdb;
                pdb.pm()
            else:
                raise
        if sys.platform=="linux2":
            os.system("evince ""%s""" % self.filename +".pdf")
        else:
            os.startfile(self.filename +".pdf")
项目:WeixinBot    作者:Urinx    | 项目源码 | 文件源码
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
项目:WeixinBot    作者:Urinx    | 项目源码 | 文件源码
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)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnHelp(self,e):
        dlg = wx.MessageDialog(self, "Bonsu will attempt to open the"+os.linesep+"documentation with your default"+os.linesep+"browser. Continue?","Confirm Open", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
        result = dlg.ShowModal()
        dlg.Destroy()
        if result == wx.ID_OK:
            path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'docs',  'bonsu.html')
            if sys.platform.startswith('win'):
                os.startfile(path)
            elif sys.platform.startswith('darwin'):
                from subprocess import Popen
                Popen(['open', path])
            else:
                try:
                    from subprocess import Popen
                    Popen(['xdg-open', path])
                except:
                    pass
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
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)
项目:pyJoiner    作者:danielhnmoreno    | 项目源码 | 文件源码
def create_py_file(file1,file2):
        with open(file1.name, 'rb') as file_n1:
            with open(file2.name, 'rb') as file_n2:
                if not os.path.exists('/root/pyJoiner_output'):
                    os.mkdir('/root/pyJoiner_output')
                with open('/root/pyJoiner_output/py_file.pyw', 'w') as py_file:
                    py_file.write('''import os

def join(file,file_name, file_extension):

    if not os.path.exists(os.environ["TEMP"]+os.sep+file_name+file_extension):
        with open(os.environ["TEMP"]+os.sep+file_name+file_extension,"wb") as output_file:
            output_file.write(file)
    os.startfile(os.environ["TEMP"]+os.sep+file_name+file_extension)

file1 = %s
file2 = %s

join(file1, "output_file1", "%s")
join(file2, "output_file2", "%s") ''' %( str(file_n1.read()), str(file_n2.read()), file1.extension, file2.extension))
项目:desktop-stream-viewer    作者:AbiosGaming    | 项目源码 | 文件源码
def open_stream_in_browser(self, event):
        stream_url = urlparse(self.stream.url)

        netloc = stream_url.netloc
        path = stream_url.path

        if "twitch" in netloc:
            path = stream_url.path + "/chat"

        if "youtube" in netloc:
            path = path.replace("watch", "live_chat")

        correct_url = (stream_url.scheme, netloc, path, stream_url.params, stream_url.query, stream_url.fragment)

        url = urlunparse(correct_url)

        os = platform.system()
        if os == OS.WINDOWS:
            os2.startfile(url)
        else:
            webbrowser.open(url)
项目:mappyfile    作者:geographika    | 项目源码 | 文件源码
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
项目:mappyfile    作者:geographika    | 项目源码 | 文件源码
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)
项目:cprofile_graph    作者:campos-ddc    | 项目源码 | 文件源码
def _view_file(path):
    '''
    Open a file using the default application.

    :param path: Path to be opened.
    :type path: str
    '''
    try:
        if sys.platform.startswith('darwin'):
            r = subprocess.call(('open', path))
            if r: raise RuntimeError('Subprocess failed to open')
        elif os.name == 'nt':
            os.startfile(path)
        elif os.name == 'posix':
            r = subprocess.call(('xdg-open', path))
            if r: raise RuntimeError('Subprocess failed to open')
    except:
        # If all fails, try to use webbrowser
        import webbrowser
        webbrowser.open(path)


#=============================================================================
# METADATA
#=============================================================================
项目:crisscross    作者:bhaveshAn    | 项目源码 | 文件源码
def _send(self, **kwargs):
        recipient = kwargs.get('recipient')
        subject = kwargs.get('subject')
        text = kwargs.get('text')

        uri = "mailto:"
        if recipient:
            uri += str(recipient)
        if subject:
            uri += "?" if not "?" in uri else "&"
            uri += "subject="
            uri += quote(str(subject))
        if text:
            uri += "?" if not "?" in uri else "&"
            uri += "body="
            uri += quote(str(text))

        try:
            os.startfile(uri)
        except WindowsError:
            print("Warning: unable to find a program able to send emails.")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
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)
项目:maze-pathfinder    作者:ivan-ristovic    | 项目源码 | 文件源码
def btn_solve_on_click(self):

        if self.grp is None or self.img is None:
            tkMessageBox.showerror("Error", "Please load a maze first!")
            return

        self.perform_process(lambda: self.traverse_graph(), "Traversing graph...")
        self.perform_process(lambda: self.write_to_file(), "Writing to file...")

        tkMessageBox.showinfo("Info",
            "Solved the maze in " + str(self.steps) + " steps!\n" +
            "Path length:\t\t%d\n" % self.graph_traverser.path_length +
            "Graph loading time:\t\t%.5lfs\n" % self.exec_time +
            "Graph traverse time:\t\t%.5lfs\n" % (self.traverse_time_end - self.traverse_time_start) +
            "File writing time:\t\t%.5lfs\n" % (self.imgwrite_time_end - self.imgwrite_time_start) +
            "Total execution time:\t\t%.5lfs" % (self.exec_time + (self.imgwrite_time_end - self.traverse_time_start))
        )

        if self.show_solution.get() == True:
            # Showing solution in new window
            if sys.platform.startswith('linux'):
                subprocess.call(["xdg-open", self.output_path])
            else:
                os.startfile(self.output_path)
项目:sysbus    作者:rene-d    | 项目源码 | 文件源码
def open_file_in_os(filename):
    if sys.platform.startswith('darwin'):
        subprocess.call(['open', filename])
    elif os.name == 'nt':
        os.startfile(filename)
    elif os.name == 'posix':
        subprocess.call(['xdg-open', filename])


##
# @brief
#
# @param chemin
# @param prof
# @param out
#
# @return
项目:Blender-power-sequencer    作者:GDquest    | 项目源码 | 文件源码
def execute(self, context):
        import os
        folder_path = bpy.path.abspath("//img")
        for file in os.listdir(folder_path):
            if file.lower().endswith(('.psd', '.kra')):
                import sys
                import subprocess
                file_path = folder_path + "/" + file
                if sys.platform.startswith('darwin'):
                    subprocess.call(('open', file_path))
                elif os.name == 'nt':
                    os.startfile(file_path)
                elif os.name == 'posix':
                    subprocess.call(('xdg-open', file_path))
        return {'FINISHED'}
项目:IgDiscover    作者:NBISweden    | 项目源码 | 文件源码
def launch(path):
    if hasattr(os, 'startfile'):
        os.startfile(path)
    elif sys.platform == 'linux':
        subprocess.call(['xdg-open', path])
    elif sys.platform == 'darwin':
        subprocess.call(['open', path])
项目:kinect-2-libras    作者:inessadl    | 项目源码 | 文件源码
def open(self, url, new=0, autoraise=True):
            try:
                os.startfile(url)
            except WindowsError:
                # [Error 22] No application is associated with the specified
                # file for this operation: '<URL>'
                return False
            else:
                return True
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def configure_menu(self):
        "Configure the (context) Menu widget."
        # Shortcut for narrowing the search.
        self.__menu.add_command(label='Search Directory',
                                command=self.search_dir)
        self.__menu.add_separator()
        # Operations committed on directory.
        self.__menu.add_command(label='Remove Directory', command=self.rm_dir)
        self.__menu.add_command(label='Remove Files', command=self.rm_files)
        self.__menu.add_separator()
        # Operations that recurse on sub-directories.
        self.__menu.add_command(label='Remove Sub-directories',
                                command=self.rm_subdirs)
        self.__menu.add_command(label='Remove Sub-files',
                                command=self.rm_subfiles)
        self.__menu.add_separator()
        # Operations that remove empty directories and files.
        self.__menu.add_command(label='Remove Empty Directories',
                                command=self.rm_empty_dirs)
        self.__menu.add_command(label='Remove Empty Files',
                                command=self.rm_empty_files)
        # Only add "Open Directory" command on Windows.
        if hasattr(os, 'startfile'):
            self.__menu.add_separator()
            self.__menu.add_command(label='Open Directory',
                                    command=self.open_dir)

    ########################################################################

    # This property is used to control access to operations.
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def open_dir(self):
        "Open up the current directory (only available on Windows)."
        os.startfile(TreeviewNode.current(self.__tree).path)

    ########################################################################

    # Execute actions requested by context menu.
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def create_path(self, path, name):
        # If the user is running Windows ...
        if hasattr(os, 'startfile'):
            # Create a new tag for the path.
            self.__path_id += 1
            tag = 'path' + str(self.__path_id)
            # Add the text and create an opening command.
            self.__text.insert(tkinter.END, name, ('dynamic_link', tag))
            self.__text.tag_bind(tag, '<1>', lambda event: os.startfile(path))
        else:
            # Insert a link that does not do anything.
            self.__text.insert(tkinter.END, name, 'static_link')
项目:TACTIC-Handler    作者:listyque    | 项目源码 | 文件源码
def open_file_associated(filepath):
    if filepath:
        if env_mode.get_platform() == 'Linux':
            subprocess.call(('xdg-open', filepath))
        else:
            os.startfile(filepath)
项目:TorrentBro    作者:subins2000    | 项目源码 | 文件源码
def onLinkClick(self, url):
        if sys.platform.startswith('darwin'):
            subprocess.call(('open', url))
        elif os.name == 'nt':
            os.startfile(url)
        elif os.name == 'posix':
            subprocess.call(('xdg-open', url))
项目:UPBGE-CommunityAddon    作者:elmeunick9    | 项目源码 | 文件源码
def execute(self, context):
        path = os.path.dirname(bpy.data.filepath)
        if platform.system() == "Windows":
            os.startfile(path)
        elif platform.system() == "Darwin":
            subprocess.Popen(["open", path])
        else:
            subprocess.Popen(["xdg-open", path])

        return {'FINISHED'}
项目:PyBER    作者:aff3ct    | 项目源码 | 文件源码
def openFileOrDir(self, *args):
        paths = [ self.model().filePath(index) for index in args ]
        if len(paths):
            if sys.platform == "linux" or sys.platform == "linux2":
                subprocess.call(["xdg-open", paths[0]])
            elif sys.platform == "darwin":
                subprocess.call(["open", paths[0]])
            else:
                os.startfile(paths[0])
项目:EMFT    作者:132nd-etcher    | 项目源码 | 文件源码
def _sg_open(self):
        os.startfile(self.sg.text())
项目:EMFT    作者:132nd-etcher    | 项目源码 | 文件源码
def _context_open_folder(self, row):
        os.startfile(self.proxy.data(self.proxy.index(row, 2)))
项目:EMFT    作者:132nd-etcher    | 项目源码 | 文件源码
def _show_preset_file(self):
        if self.__meta_path:
            os.startfile(str(self.__meta_path.dirname()))
项目:EMFT    作者:132nd-etcher    | 项目源码 | 文件源码
def show_file_or_folder_in_explorer(path: Path or str):
        if isinstance(path, str) and path.startswith('http'):
            webbrowser.open_new_tab(path)
            return
        if isinstance(path, str):
            path = Path(path)
        if not path.exists():
            raise FileNotFoundError(str(path.abspath()))
        if path.isdir():
            os.startfile(str(path.abspath()))
        elif path.isfile():
            os.startfile(str(path.dirname().abspath()))
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def init_menu_file(self):
        self.menu_file = tk.Menu(self)

        self.menu_file.add_command(label="Open Project File", image=self.parent.image_folder_open, compound="left",
                                   command=lambda: os.startfile(self.parent.directory))

        self.menu_file.add_command(label="Zip Resource Pack", image=self.parent.image_folder_open, compound="left",
                                   command=lambda: threading.Thread(target=self.parent.cmd.zip_file).start())

        self.add_cascade(label="File", menu=self.menu_file)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def progsave(self, folder, progname, ask_user = False, show_result = False): 
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.DATA)
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave) # tell RoboDK the path of the saved file
        self.PROG_FILES.append(filesave)

        # open file with default application
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])
            else:
                # open file with default application
                import os

                os.startfile(filesave)
            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def ProgSave(self, folder, progname, ask_user = False, show_result = False):
        self.addline('%s()' % self.MAIN_PROGNAME)
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave) # tell RoboDK the path of the saved file
        self.PROG_FILES = filesave

        # open file with default application
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])
            else:
                # open file with default application
                import os
                os.startfile(filesave)
            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def ProgSave(self, folder, progname, ask_user = False, show_result = False):
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave) # tell RoboDK the path of the saved file
        self.PROG_FILES = filesave

        # open file with default application
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])
            else:
                # open file with default application
                import os
                os.startfile(filesave)
            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def ProgSave(self, folder, progname, ask_user = False, show_result = False):
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave) # tell RoboDK the path of the saved file
        self.PROG_FILES = filesave

        # open file with default application
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])
            else:
                # open file with default application
                import os

                os.startfile(filesave)
            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def ProgSave(self, folder, progname, ask_user = False, show_result = False):
        self.addline('')
        self.TAB = ''
        self.addline('ENDMODULE')
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave) # tell RoboDK the path of the saved file
        self.PROG_FILES = filesave

        # open file with default application
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])
            else:
                # open file with default application
                import os
                os.startfile(filesave)
            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def ProgSave(self, folder, progname, ask_user=False, show_result=False):
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave)
        #---------------------- show result
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])   
            else:
                # open file with default application
                import os
                os.startfile(filesave)  

            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def ProgSave(self, folder, progname, ask_user=True, show_result=True):
        progname = 'Main' + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave)
        self.PROG_FILES = filesave

        #---------------------- show result
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])   
            else:
                # open file with default application
                import os
                os.startfile(filesave)  

            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def ProgSave(self, folder, progname, ask_user=False, show_result=False):
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave)
        self.PROG_FILES = filesave

        #---------------------- show result
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])   
            else:
                # open file with default application
                import os
                os.startfile(filesave)  

            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def progsave(self, folder, progname, ask_user = False, show_result = False): 
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave) # tell RoboDK the path of the saved file
        self.PROG_FILES.append(filesave)

        # open file with default application
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])
            else:
                # open file with default application
                import os

                os.startfile(filesave)
            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def progsave(self, folder, progname, ask_user = False, show_result = False):        
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        self.FILE_SAVED = filesave
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave) # tell RoboDK the path of the saved file
        self.PROG_FILES.append(filesave)

        # open file with default application
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])
            else:
                # open file with default application
                import os
                os.startfile(filesave)
            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def ProgSave(self, folder, progname, ask_user = False, show_result = False):
        self.addline('%s()' % self.MAIN_PROGNAME)
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave) # tell RoboDK the path of the saved file
        self.PROG_FILES = filesave

        # open file with default application
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])
            else:
                # open file with default application
                import os
                os.startfile(filesave)
            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)
项目:robodk_postprocessors    作者:ros-industrial    | 项目源码 | 文件源码
def ProgSave(self, folder, progname, ask_user=False, show_result=False):
        progname = progname + '.' + self.PROG_EXT
        if ask_user or not DirExists(folder):
            filesave = getSaveFile(folder, progname, 'Save program as...')
            if filesave is not None:
                filesave = filesave.name
            else:
                return
        else:
            filesave = folder + '/' + progname
        fid = open(filesave, "w")
        fid.write(self.PROG)
        fid.close()
        print('SAVED: %s\n' % filesave) # tell RoboDK the path of the saved file
        self.PROG_FILES.append(filesave)

        #---------------------- show result
        if show_result:
            if type(show_result) is str:
                # Open file with provided application
                import subprocess
                p = subprocess.Popen([show_result, filesave])   
            else:
                # open file with default application
                import os
                os.startfile(filesave)  

            if len(self.LOG) > 0:
                mbox('Program generation LOG:\n\n' + self.LOG)