-
基于
esky
实现
py
thon
应用的自动升级
一、
esky
介绍
Esky is an auto-update
framework for frozen Python applications. It
provides a simple API through which apps can find,
fetch and install
updates, and a
bootstrapping mechanism that keeps the app safe in
the face of failed or partial updates. Updates can
also be sent as
differential patches.
Esky is currently capable
of freezing apps with py2exe, py2app, cxfreeze and
bbfreeze. Adding support for other freezer
programs should
be easy; patches will
be gratefully accepted.
We
are tested and running on Python 2.7 Py2app will
work on python3 fine, the other freezers not so
much.
Esky
是一个
python
编译程序的自动升级框架,
提供
简单的
api
实现应用的自动更新
(包
括比较版本、
更新版本)
,
esky<
/p>
支持
py2exe
,
py2app
,
cxfreeze
以及
bbfreeze
等多种
pyth
on
打包框架。
< br>二、
esky
安装及说明
1
、
pip
安装
pip install esky
2
、
esky
说明
< br>
/cloudmatrix/esky/
3
、
esk
y
教学视频
/pycon-au-2010/
三、
esky
用法示例
esky
用起来比较简单,我们这里
以常用的基于
wx
的
windows<
/p>
应用举例。
wxpython
下有个
reupdate
< br>类,对
wxpython
应用的
esky
升级进行了二次封装。
<
/p>
网上有个现成的示范例子,具体网址:
/
2013
/
07
/12
/wxpython-updating-your-application-with-esky/
代码很简单,对其中的关键部分进行注释说明(红色字体部分
):
复制代码
#
----------------------------------------
# image_
#
#
Created 03-20-2010
#
#
Author: Mike Driscoll
#
----------------------------------------
import glob
import os
import wx
from import setuparg1
from import
pub
as Publisher
#
申明语句
from reupdate import SoftwareUpdate
import version
#######################################
#################################
class
ViewerPanel():
#--
--------------------------------------------------
------------------
def
__init__(self, parent):
.__init__(self, parent)
width, height = ySize()
hs
= []
tPicture = 0
ictures = 0
axSize = height
- 200
ibe(Images, (
imer = (None)
(_TIMER, )
()
#--
--------------------------------------------------
------------------
def
layout(self):
Layout the
widgets on the panel
zer = er(AL)
btnSizer =
er(NTAL)
img =
mage(axSize,axSize)
trl =
Bitmap(self, _ANY
,
FromImage(img))
(trl, 0, |, 5)
abel =
Text(self, label=
(abel, 0, |, 5)
btnData = [(
(
(
for
data in btnData:
label, sizer,
handler = data
lder(label, sizer, handler)
(btnSizer, 0, )
er(zer)
#--
--------------------------------------------------
------------------
def
btnBuilder(self, label, sizer, handler):
Builds a button, binds it
to an event handler and adds it to a sizer
btn = (self, label=label)
(_BUTTON, handler)
(btn, 0, |, 5)
#--
--------------------------------------------------
------------------
def
loadImage(self, image):
image_name = me(image)
img
= (image, _TYPE_ANY)
# scale the
image, preserving the aspect ratio
W =
th()
H = ght()
if
W > H:
NewW = axSize
NewH = axSize * H / W
else:
NewH = axSize
NewW = axSize * W / H
img
= (NewW,NewH)
map(FromImage(img))
el(image_name)
h()
ssage(
#--
--------------------------------------------------
------------------
def
nextPicture(self):
Loads the next picture in the directory
if tPicture == ictures-1:
tPicture = 0
else:
tPicture += 1
age(hs[tPicture])
p>
#----------------------------------------
------------------------------
def
previousPicture(self):
Displays the previous picture in the
directory
if tPicture ==
0:
tPicture = ictures - 1
else:
tPicture -= 1
age(hs[tPicture])
p>
#----------------------------------------
------------------------------
def
update(self, event):
Called when the slideTimer's timer
event fires. Loads the next
picture from the folder by calling th
nextPicture method
cture()
#--
--------------------------------------------------
------------------
def
updateImages(self, msg):
Updates the picPaths list to contain
the current folder's images
hs =
ictures = len(hs)
age(hs[0])
#--
--------------------------------------------------
------------------
def
onNext(self, event):
Calls the nextPicture method
cture()
p>
#----------------------------------------
------------------------------
def
onPrevious(self, event):
Calls the previousPicture method
usPicture()
p>
#----------------------------------------
------------------------------
def
onSlideShow(self, event):
Starts and stops the slideshow
btn = ntObject()
label = el()
if label ==
(3000)
el(
else:
()
el(
###
##################################################
###################
class
ViewerFrame():
#--
--------------------------------------------------
------------------
def
__init__(self):
title = 'Image Viewer %s' %(N)
.__init__(self,
None, title=title)
panel =
ViewerPanel(self)
Path =
ibe(Frame, (
olbar()
= er(AL)
(panel, 1, )
er()
()
(self)
()
#--
--------------------------------------------------
------------------
def
initToolbar(self):
Initialize the toolbar
r = ToolBar()
lBitmapSize((16,16))
open_ico = map(_FILE_OPEN, _TOOLBAR,
(16,16))
openTool =
pleTool(_ANY
, open_ico,
(_MENU, ectory, openTool)
e()
#--------------
--------------------------------------------------
------
def onOpenDirectory(self,
event):
Opens a
DirDialog to allow the user to open a folder with
pictures
dlg = log(self,
style=_DEFAULT_STYLE)
if dal() == _OK:
Path = h()
print Path
picPaths = (Path +
print picPaths
ssage(
#--
--------------------------------------------------
------------------
def
resizeFrame(self, msg):
(self)
###
##################################################
###################
#
注意基类是两个
-
-
-
-
-
-
-
-
-
上一篇:煤炭必备基础知识(中英文术语解释翻译)
下一篇:微软补丁服务器(SUS)实施方案