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


Python Utilities.create_zipfile方法代码示例

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


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

示例1:

# 需要导入模块: from utilities import Utilities [as 别名]
# 或者: from utilities.Utilities import create_zipfile [as 别名]
                                        # Archive any existing file, appending the date/time
                                        if os.path.exists(archivedFile):
                                            utils.log_output(logger, "There is already a file named {0} in the {1} directory".format(fileName, archivedDir), 'error')
                                            utils.log_output(logger, "Attempting to archive {0}...".format(archivedFile), 'info')
                                            arr = utils.archive_file(archivedFile)
                                            blnContinue = arr[0]
                                            if blnContinue:
                                                utils.log_output(logger, "{0} has been archived as {1}".format(archivedFile, arr[1]), 'debug')

                                        if blnContinue:
                                            os.rename(backupFile, archivedFile)
                                            utils.log_output(logger, "{0} has been moved to {1}".format(backupFile, archivedFile), 'info')
                                            if compress.lower() == 'true':
                                                try:
                                                    return_value = utils.create_zipfile(archivedFile)
                                                    if return_value:
                                                        try:
                                                            os.remove(archivedFile)
                                                            utils.log_output(logger, "{0} has been removed.".format(archivedFile), 'info')
                                                        except:
                                                            utils.capture_exception(logger, "Error removing {0}.".format(archivedFile), sys.exc_info())
                                                    else:
                                                        utils.log_output(logger, "Unable to compress {0}".format(archivedFile), 'error')
                                                except:
                                                    utils.capture_exception(logger, "Error trying to compress {0}".format(archivedFile), 'error')
                                        else:
                                            utils.log_output(logger, "Unable to rename existing {0} file. Manual intervention needed.".format(fileName), 'info')
                                    except:
                                        utils.capture_exception(logger, "Error trying to rename {0} to {1}".format(backupFile, archivedFile), sys.exc_info())
                                    # utls.log_output(logger, "Unable rename {0} to {1}".format(backupFile, archivedFile), 'error')
开发者ID:victorpendleton,项目名称:archiveFiles,代码行数:32,代码来源:archiveBackups.py


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