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


Python Install_Log.set_file方法代码示例

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


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

示例1: __safe_call__

# 需要导入模块: import Install_Log [as 别名]
# 或者: from Install_Log import set_file [as 别名]
    def __safe_call__ (self):
        url_download = CTK.cfg.get_val('tmp!market!install!download')

        box = CTK.Box()
        box += CTK.RawHTML ("<h2>%s</h2><br/>" %(_('Setting up application…')))

        # has it been downloaded?
        pkg_filename = url_download.split('/')[-1]

        package_path = CTK.cfg.get_val ('tmp!market!install!local_package')
        if not package_path or not os.path.exists (package_path):
            down_entry = CTK.DownloadEntry_Factory (url_download)
            package_path = down_entry.target_path

        # Create the local directory
        target_path = os.path.join (CHEROKEE_OWS_ROOT, str(int(time.time()*100)))
        os.mkdir (target_path, 0700)
        CTK.cfg['tmp!market!install!root'] = target_path

        # Create the log file
        Install_Log.log ("Unpacking %s" %(package_path))
        Install_Log.set_file (os.path.join (target_path, "install.log"))

        # Uncompress
        tar = tarfile.open (package_path, 'r:gz')
        for tarinfo in tar:
            Install_Log.log ("  %s" %(tarinfo.name))
            tar.extract (tarinfo, target_path)

        # Set default permission
        Install_Log.log ("Setting default permission 755 for directory %s" %(target_path))
        os.chmod (target_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH )

        # Remove the package
        if package_path.startswith (CHEROKEE_OWS_DIR):
            Install_Log.log ("Skipping removal of: %s" %(package_path))
        else:
            Install_Log.log ("Removing %s" %(package_path))
            os.unlink (package_path)

        # Import the Installation handler
        if os.path.exists (os.path.join (target_path, "installer.py")):
            Install_Log.log ("Passing control to installer.py")
            installer_path = os.path.join (target_path, "installer.py")
            pkg_installer = imp.load_source ('installer', installer_path)
        else:
            Install_Log.log ("Passing control to installer.pyo")
            installer_path = os.path.join (target_path, "installer.pyo")
            pkg_installer = imp.load_compiled ('installer', installer_path)

        # Set owner and permissions
        Install_Log.log ("Post unpack commands")

        # Execute commands
        commands = pkg_installer.__dict__.get ('POST_UNPACK_COMMANDS',[])
        box += CommandProgress.CommandProgress (commands, URL_INSTALL_SETUP_EXTERNAL)

        return box.Render().toStr()
开发者ID:chetan,项目名称:cherokee,代码行数:60,代码来源:Install.py

示例2: _Setup_unpack

# 需要导入模块: import Install_Log [as 别名]
# 或者: from Install_Log import set_file [as 别名]
def _Setup_unpack():
    url_download = CTK.cfg.get_val("tmp!market!install!download")

    # has it been downloaded?
    pkg_filename = url_download.split("/")[-1]

    package_path = CTK.cfg.get_val("tmp!market!install!local_package")
    if not package_path or not os.path.exists(package_path):
        down_entry = CTK.DownloadEntry_Factory(url_download)
        package_path = down_entry.target_path

    # Create the local directory
    target_path = os.path.join(CHEROKEE_OWS_ROOT, str(int(time.time() * 100)))
    os.mkdir(target_path, 0700)
    CTK.cfg["tmp!market!install!root"] = target_path

    # Create the log file
    Install_Log.set_file(os.path.join(target_path, "install.log"))

    # Uncompress
    try:
        if sys.version_info < (
            2,
            5,
        ):  # tarfile module prior to 2.5 is useless to us: http://bugs.python.org/issue1509889
            raise tarfile.CompressionError

        Install_Log.log("Unpacking %s with Python" % (package_path))
        tar = tarfile.open(package_path, "r:gz")
        for tarinfo in tar:
            Install_Log.log("  %s" % (tarinfo.name))
            tar.extract(tarinfo, target_path)
        ret = {"retcode": 0}
    except tarfile.CompressionError:
        command = "gzip -dc '%s' | tar xfv -" % (package_path)
        Install_Log.log(
            "Unpacking %(package_path)s with the GZip binary (cd: %(target_path)s): %(command)s" % (locals())
        )
        ret = popen.popen_sync(command, cd=target_path)
        Install_Log.log(ret["stdout"])
        Install_Log.log(ret["stderr"])

    # Set default permission
    Install_Log.log("Setting default permission 755 for directory %s" % (target_path))
    os.chmod(
        target_path,
        stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH,
    )

    # Remove the package
    if package_path.startswith(CHEROKEE_OWS_DIR):
        Install_Log.log("Skipping removal of: %s" % (package_path))
    else:
        Install_Log.log("Removing %s" % (package_path))
        os.unlink(package_path)

    return ret
开发者ID:hikikomorime,项目名称:webserver,代码行数:59,代码来源:Install.py


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