- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章EarthLiveSharp中cloudinary的CDN图片缓存自动清理python脚本由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
恰巧发现有个叫“EarthLiveSharp”,可用将日本向日葵8号卫星的地球实时图片设为屏保。向日葵8号卫星的地球实时图片官网为:http://himawari8.nict.go.jp/,EarthLiveSharp的项目地址是:https://github.com/bitdust/EarthLiveSharp。 为了减轻向日葵8号的服务器负担,同时也是提高地球实时图片的获取成功率,需要使用cloudinary来做CDN。注册配置都在软件里有说明.
目前EarthLiveSharp暂时没有清理cloudinary的CDN图片缓存的功能,于是我用python写了一个,并尝试用gist管理,地址为:https://gist.github.com/creke/c5a8a18fa41b8f5c1a0719a7e0cf4de6 。
同时,为了大家方便,顺便编译成了Windows可执行文件,下载: https://pan.baidu.com/s/1c27fXEo 提取码:k33n 为了自己检索方便,顺便在这里附上python脚本源码,可以作为python如何使用RESTful接口的例子,相关工具类函数也便于参考.
EarthLiveCleanCloudinary.py 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# -*- coding: utf-8 -*-
# Author: Creke
# HomePage: http://blog.creke.net
import
sys
import
urllib, urllib2
import
base64
import
json
URLLIB_DEBUG_LEVEL
=
1
URLLIB_TIMEOUT
=
5
def
Dict2Uri(dic):
return
urllib.urlencode(dic)
def
GenUrllibReq(url, method, api_key, api_secret, post_data
=
None
):
urlreq
=
None
if
post_data
is
None
:
urlreq
=
urllib2.Request(url)
else
:
urlreq
=
urllib2.Request(url, post_data)
urlreq.get_method
=
lambda
: method
auth_str
=
base64.b64encode(
'%s:%s'
%
(api_key, api_secret))
urlreq.add_header(
"Authorization"
,
"Basic %s"
%
auth_str)
urlreq.add_header(
'Cache-Control'
,
'no-cache'
)
return
urlreq
def
GetApiDelUrl(cloud_name, img_type):
url
=
"https://api.cloudinary.com/v1_1/%s/resources/image/%s"
%
(cloud_name, img_type)
params
=
{
"prefix"
:
"http://himawari8-dl"
}
url
=
url
+
"?"
+
Dict2Uri(params)
return
url
def
main(argv):
arg_idx
=
1
api_key
=
argv[arg_idx]
arg_idx
+
=
1
api_secret
=
argv[arg_idx]
arg_idx
+
=
1
cloud_name
=
argv[arg_idx]
while
True
:
del_url
=
GetApiDelUrl(cloud_name,
'fetch'
)
urlreq
=
GenUrllibReq(del_url,
'DELETE'
, api_key, api_secret)
print
"==========================="
print
"Requesting %s"
%
(del_url)
opener
=
urllib2.build_opener(urllib2.HTTPSHandler(debuglevel
=
URLLIB_DEBUG_LEVEL))
urllib_open
=
opener.
open
(urlreq, timeout
=
URLLIB_TIMEOUT)
response
=
urllib_open.read()
print
"==========================="
print
"Response:"
print
"%s"
%
(response)
print
"==========================="
urllib_open.close()
print
"Done Requesting"
res_json
=
json.loads(response)
deleted_cnt
=
len
(res_json[
'deleted'
])
print
"Deleted %u himawari8 pics"
%
(deleted_cnt)
print
"==========================="
if
'next_cursor'
in
res_json
and
deleted_cnt>
0
:
print
"Due to Cloudinary limits, we're starting a new round"
else
:
break
return
0
def
PrintHelp(argv):
print
"\t USAGE: %s [api_key] [api_secret] [cloud_name]"
%
(argv[
0
])
if
__name__
=
=
'__main__'
:
if
len
(sys.argv) <
4
:
PrintHelp(sys.argv)
exit(
1
)
print
"RUNNING main"
main(sys.argv)
print
"DONE main"
|
EarthLiveCleanCloudinary2exe.py 。
1
2
3
4
5
6
7
8
|
# -*- coding: utf-8 -*-
# Author: Creke
# HomePage: http://blog.creke.net
from
distutils.core
import
setup
import
py2exe
setup(console
=
[
'EarthLiveCleanCloudinary.py'
])
|
Windows编译版本下载:
链接: https://pan.baidu.com/s/1skADZeH 密码: rdgb 。
最后此篇关于EarthLiveSharp中cloudinary的CDN图片缓存自动清理python脚本的文章就讲到这里了,如果你想了解更多关于EarthLiveSharp中cloudinary的CDN图片缓存自动清理python脚本的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
如何使用 CDN 将语义 UI 包含到 HTML 页面? CDN链接为https://cdnjs.com/libraries/semantic-ui ,但是怎么使用呢? 最佳答案 您只需复制要用于语义
我有一个我似乎无法解决的特定用例。 典型的 gcloud 设置: K8S集群 一个 gcloud 存储桶 gcloud 负载均衡器 我设法获得了我的域 https://cdn.foobar.com/u
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我有 blob 存储和 CDN 端点,用于存储我的静态内容。 现在我想更新 app.js 文件,因为它被修改了,但是当我将此文件写入 blob 时,CDN 仍然给我旧的 app.js 文件。如何更新我
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
出于性能原因,我希望通过 Azure CDN 提供很少更改的内容。但是,当内容确实发生变化时,更新的数据立即可用很重要。理想情况下,我可以设置一个长 TTL,然后在我更新内容时主动告诉 CDN 使内容
以下main.js代码不遵守优先级顺序(有时underscore.js在backbone.js需要时不会加载它): require({ baseUrl:'/scripts', prio
为什么我不能重用以前删除的端点的名称?例如,如果我创建一个名为“acme-cdn1”的端点,将其删除,然后尝试创建一个具有相同名称的新端点,我会收到以下消息:“错误,该端点名称已经存在。”是否有必要删
我不确定我是否使用 CDN 还是本地。本地是否意味着jquery资源需要安装在智能手机上,以便离线应用程序成为可能? 最佳答案 在这种情况下,本地意味着您自己托管文件(作为网站的一部分),而不是依赖
一种不言自明的问题:为什么建议从 CDN 加载 jQuery 或任何其他库? 最佳答案 CDN 将比您的服务器更快。 服务器具有最大连接数。浏览器将同时请求的数量限制在单个域中。将您的库卸载到 CDN
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我知道 Google AMP 缓存会缓存网站的有效 AMP 页面和资源文件,并通过 .cdn.ampproject.org/提供它们。我做了一些测试,它对我的网站运行良好。 我在一家受欢迎的网站工
我有一个用静态 html/js/css 编写的 HTML5 应用程序(它实际上是用 Dart 编写的,但会编译成 javascript)。我通过 CDN 提供应用程序文件,REST api 托管在一个
我不太确定如何防止谷歌将我的 CDN 域与我的主域名混合编入索引。我想在直接访问 CDN 域时通过 .htaccess 重定向到主域。 事实: 两个域都指向文件系统中的同一个位置。 两者共享相同的 r
引自此处:https://www.ampproject.org/docs/get_started/about-amp.html AMP is a way to build web pages for
我刚刚尝试设置 Azure CDN 帐户,到目前为止(现在已经持续了四个小时)我还无法让它返回除 400 和 404 错误之外的任何内容。 如果这是一个真正的 CDN,我需要做的就是将 CDN 指向我
我们希望提供来自少数可用 AWS 区域的大量视频文件。目标受众来自全局多个地点。不保证连接速度。因此,绝对需要 CDN(最好是 CloudFront)。 视频需要受到保护,因此只有在用户经过身份验证和
有没有content delivery network (CDN)正在托管google-code-prettify ? 我正在 TypePad 上建立一个博客如果可能的话,希望利用 CDN。 最佳答案
在我的应用程序中,使用 ember-cli 开发,我还需要一些外部资源,例如 bootstrap;现在我通过 Brocfile 导入它: app.import('bower_components/bo
我想知道是否有像 960GS 这样的 CSS 框架的 CDN。因为我认为很多人都在使用它。 最佳答案 我还没有尝试过 cachedcommons.org,但他们有一个 960 的链接,听起来像你所要求
我是一名优秀的程序员,十分优秀!