• 大小: 45M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-10
  • 语言: 其他
  • 标签: 其他  

资源简介

duoqy.part3.rar

资源截图

代码片段和文件信息

#!/usr/bin/env python2.7
from __future__ import absolute_import unicode_literals print_function division

from sys import argv
from os import environ stat remove as _delete_file
from os.path import isfile dirname basename abspath
from hashlib import sha256
from subprocess import check_call as run

from boto.s3.connection import S3Connection
from boto.s3.key import Key
from boto.exception import S3ResponseError


NEED_TO_UPLOAD_MARKER = ‘.need-to-upload‘
BYTES_PER_MB = 1024 * 1024
try:
    BUCKET_NAME = environ[‘TWBS_S3_BUCKET‘]
except KeyError:
    raise SystemExit(“TWBS_S3_BUCKET environment variable not set!“)


def _sha256_of_file(filename):
    hasher = sha256()
    with open(filename ‘rb‘) as input_file:
        hasher.update(input_file.read())
    file_hash = hasher.hexdigest()
    print(‘sha256({}) = {}‘.format(filename file_hash))
    return file_hash


def _delete_file_quietly(filename):
    try:
        _delete_file(filename)
    except (OSError IOError):
        pass


def _tarball_size(directory):
    kib = stat(_tarball_filename_for(directory)).st_size // BYTES_PER_MB
    return “{} MiB“.format(kib)


def _tarball_filename_for(directory):
    return abspath(‘./{}.tar.gz‘.format(basename(directory)))


def _create_tarball(directory):
    print(“Creating tarball of {}...“.format(directory))
    run([‘tar‘ ‘-czf‘ _tarball_filename_for(directory) ‘-C‘ dirname(directory) basename(directory)])


def _extract_tarball(directory):
    print(“Extracting tarball of {}...“.format(directory))
    run([‘tar‘ ‘-xzf‘ _tarball_filename_for(directory) ‘-C‘ dirname(directory)])


def download(directory):
    _delete_file_quietly(NEED_TO_UPLOAD_MARKER)
    try:
        print(“Downloading {} tarball from S3...“.format(friendly_name))
        key.get_contents_to_filename(_tarball_filename_for(directory))
    except S3ResponseError as err:
        open(NEED_TO_UPLOAD_MARKER ‘a‘).close()
        print(err)
        raise SystemExit(“Cached {} download failed!“.format(friendly_name))
    print(“Downloaded {}.“.format(_tarball_size(directory)))
    _extract_tarball(directory)
    print(“{} successfully installed from cache.“.format(friendly_name))


def upload(directory):
    _create_tarball(directory)
    print(“Uploading {} tarball to S3... ({})“.format(friendly_name _tarball_size(directory)))
    key.set_contents_from_filename(_tarball_filename_for(directory))
    print(“{} cache successfully updated.“.format(friendly_name))
    _delete_file_quietly(NEED_TO_UPLOAD_MARKER)


if __name__ == ‘__main__‘:
    # Uses environment variables:
    #   AWS_ACCESS_KEY_ID -- AWS Access Key ID
    #   AWS_SECRET_ACCESS_KEY -- AWS Secret Access Key
    argv.pop(0)
    if len(argv) != 4:
        raise SystemExit(“USAGE: s3_cache.py    “)
    mode friendly_name dependencies_file directory = argv

    conn = S3Connection()
    bucket = conn.lookup(BUCKET_NAME validate=False)
    if buck

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1377  2015-09-26 16:18  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Face\92.gif

     文件       1119  2015-09-26 16:18  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Face\93.gif

     文件       3426  2015-09-26 16:18  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Face\94.gif

     文件       3011  2015-09-26 16:18  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Face\95.gif

     文件       1796  2015-09-26 16:18  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Face\96.gif

     文件       5300  2015-09-26 16:18  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Face\97.gif

     文件       1629  2015-09-26 16:18  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Face\98.gif

     文件       2261  2015-09-26 16:18  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Face\99.gif

     文件       8704  2015-09-26 16:18  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Face\Thumbs.db

     文件       8426  2015-09-26 16:17  duoqy\dqy\Tpl\Qyapp\Kefu\Images\logo.png

     文件      10166  2015-09-26 16:17  duoqy\dqy\Tpl\Qyapp\Kefu\Images\menu.png

     文件         43  2015-09-26 16:17  duoqy\dqy\Tpl\Qyapp\Kefu\Images\spacer17ced3.gif

     文件         43  2015-09-26 16:17  duoqy\dqy\Tpl\Qyapp\Kefu\Images\spacer17ced4.gif

     文件      15360  2015-09-26 16:17  duoqy\dqy\Tpl\Qyapp\Kefu\Images\Thumbs.db

     文件      14293  2015-09-28 14:59  duoqy\dqy\Tpl\Qyapp\Kefu\index.html

     文件       1850  2015-09-26 16:17  duoqy\dqy\Tpl\Qyapp\Kefu\Js\audio.js

     文件     113092  2015-09-26 16:17  duoqy\dqy\Tpl\Qyapp\Kefu\Js\jQuery.js

     文件       5454  2015-09-26 17:29  duoqy\dqy\Tpl\Qyapp\Kefu\Login.html

     文件      24030  2015-09-27 19:03  duoqy\dqy\Tpl\Qyapp\Kefu\main.html

     文件      28188  2015-09-26 16:17  duoqy\dqy\Tpl\Qyapp\Kefu\Swf\uploader.swf

     文件      17744  2015-10-19 16:00  duoqy\dqy\Tpl\Qyapp\Knowledge\addFiles.html

     文件      15763  2015-10-17 15:13  duoqy\dqy\Tpl\Qyapp\Knowledge\addFolder.html

     文件       5766  2015-09-28 09:58  duoqy\dqy\Tpl\Qyapp\Knowledge\addFolder.html1

     文件       9616  2015-09-28 09:58  duoqy\dqy\Tpl\Qyapp\Knowledge\back.html

     文件       2996  2015-09-28 09:58  duoqy\dqy\Tpl\Qyapp\Knowledge\backInfo.html

     文件      11235  2015-09-28 09:58  duoqy\dqy\Tpl\Qyapp\Knowledge\css\banji.css

     文件       3786  2015-09-28 09:58  duoqy\dqy\Tpl\Qyapp\Knowledge\css\basic.css

     文件       2224  2015-09-28 09:58  duoqy\dqy\Tpl\Qyapp\Knowledge\css\com_know.css

     文件       3962  2015-09-28 09:58  duoqy\dqy\Tpl\Qyapp\Knowledge\css\massge.css

     文件       1106  2015-09-28 09:58  duoqy\dqy\Tpl\Qyapp\Knowledge\css\news.css

............此处省略3252个文件信息

评论

共有 条评论