當前位置: 首頁>>代碼示例>>Python>>正文


Python Tools.extractTar方法代碼示例

本文整理匯總了Python中libs.Tools.extractTar方法的典型用法代碼示例。如果您正苦於以下問題:Python Tools.extractTar方法的具體用法?Python Tools.extractTar怎麽用?Python Tools.extractTar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在libs.Tools的用法示例。


在下文中一共展示了Tools.extractTar方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: checkPio

# 需要導入模塊: from libs import Tools [as 別名]
# 或者: from libs.Tools import extractTar [as 別名]
    def checkPio(self):
        # defining default env paths
        os.environ['PATH'] = self.getEnvPaths()

        # checking python
        cmd = ['python', '--version']
        out = childProcess(cmd)

        # show error and link to download
        if(out[0] > 0):
            current_time = time.strftime('%H:%M:%S')
            go_to = sublime.ok_cancel_dialog(
                "deviot_need_python", "button_download_python")
            if(go_to):
                sublime.run_command(
                    'open_url', {'url': 'https://www.python.org/downloads/'})
            return

        # check if pio is installed
        self.message_queue.startPrint()
        self.message_queue.put("deviot_setup{0}", version)
        current_time = time.strftime('%H:%M:%S')

        cmd = ['pio', '--version']
        out = childProcess(cmd)

        if(out[0] == 0):
            current_time = time.strftime('%H:%M:%S')
            self.message_queue.put("pio_is_installed{0}", current_time)

            self.endSetup()
            return

        current_time = time.strftime('%H:%M:%S')
        self.message_queue.put("pio_isn_installed{0}", current_time)

        # check if virtualenv file is cached
        if(os.path.exists(self.env_file)):
            self.cached_file = True

        # download virtualenv
        if(not self.cached_file):
            current_time = time.strftime('%H:%M:%S')
            self.message_queue.put("downloading_files{0}", current_time)
            headers = Tools.getHeaders()
            url_file = 'https://pypi.python.org/packages/source/v/virtualenv/virtualenv-14.0.1.tar.gz'

            try:
                file_request = Request(url_file, headers=headers)
                file_open = urlopen(file_request)
                file = file_open.read()
            except:
                current_time = time.strftime('%H:%M:%S')
                self.message_queue.put(
                    "error_downloading_files{0}", current_time)
                print("There was an error downloading virtualenv")
                return
            # save file
            try:
                output = open(self.env_file, 'wb')
                output.write(bytearray(file))
                output.close()
            except:
                current_time = time.strftime('%H:%M:%S')
                self.message_queue.put("error_saving_files{0}", current_time)
                print("There was an error saving the virtualenv file")
                return

        # extract file
        current_time = time.strftime('%H:%M:%S')
        self.message_queue.put("extracting_files{0}", current_time)
        tmp = tempfile.mkdtemp()
        Tools.extractTar(self.env_file, tmp)

        # install virtualenv in a temp dir
        current_time = time.strftime('%H:%M:%S')
        self.message_queue.put("installing_pio{0}", current_time)

        temp_env = os.path.join(tmp, 'env-root')
        cwd = os.path.join(tmp, 'virtualenv-14.0.1')
        cmd = ['python', 'setup.py', 'install', '--root', temp_env]
        out = childProcess(cmd, cwd)

        # error
        if(out[0] > 0):
            current_time = time.strftime('%H:%M:%S')
            self.message_queue.put("error_installing_env_{0}", current_time)
            return

        # make vitualenv
        for root, dirs, files in os.walk(tmp):
            for file in files:
                if(file == 'virtualenv.py'):
                    cwd = root

        if(os.path.exists(cwd)):
            cmd = ['python', 'virtualenv.py', '\"' + self.env_dir + '\"']
            out = childProcess(cmd, cwd)

            # error
#.........這裏部分代碼省略.........
開發者ID:ikthap,項目名稱:Deviot,代碼行數:103,代碼來源:Install.py


注:本文中的libs.Tools.extractTar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。