Skip to content

Instantly share code, notes, and snippets.

Created December 1, 2017 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7f3f4c10a01a5694ff8bb4dd94341c0a to your computer and use it in GitHub Desktop.
Save anonymous/7f3f4c10a01a5694ff8bb4dd94341c0a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Filename : Client.py
# @Date : 17-5-5 下午8:30
# @Author : DebuggerX
import os
import xmlrpclib
import zipfile
def adddir2zip(zfile, *dirs):
for d in dirs:
for dpath, dnames, fnames in os.walk(d):
for fname in fnames:
zfile.write(os.path.join(dpath, fname))
def addfile2zip(zfile, *files):
for f in files:
zfile.write(os.path.join(f))
# 创建用于上传的upload.zip
z = zipfile.ZipFile('upload.zip', 'w', zipfile.ZIP_DEFLATED)
# 添加src目录&libs目录及所有文件,添加工程配置文件
adddir2zip(z, "src", "libs")
addfile2zip(z, ".actionScriptProperties")
z.close()
proxy = xmlrpclib.ServerProxy("http://10.0.0.1:39999/", allow_none=True)
with open("upload.zip", 'rb') as updatefile:
with open("bin/h5/LayaMain.max.js", 'wb') as savefile:
savefile.write(
proxy.python_save(xmlrpclib.Binary(updatefile.read())).data
)
# 删除临时上传zip
os.remove("upload.zip")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment