Commit 3bd48911 authored by wanli's avatar wanli

更新

parent c1196462
......@@ -341,6 +341,6 @@ class AppsManager(object):
AppLogs(app_name=app.app_name, app_path=epk_path, app_version=app.app_version, app_info=app_info, create_by=user, create_at=datetime.now())
commit()
return { 'app_name': app.app_name, 'app_path': parse.urljoin(config['UPLOAD_SERVER'], epk_path) }, "application build {}.".format("success" if app_info else "fail")
return { 'app_name': app.app_name, 'app_file': "{}.epk".format(app.app_name), 'app_url': parse.urljoin(config['UPLOAD_SERVER'], epk_path) }, "application build {}.".format("success" if app_info else "fail")
appsManager = AppsManager()
import os
import requests
if __name__ == "__main__":
url = "http://localhost:5000/api/v1/evm_store/application/build"
datas = {
"access_key": "04edb4d8-855e-11eb-9faf-00155d073e1f",
"app_name": "test",
"app_version": "v1.0",
"category": "test",
}
# upload_files = [
# ("field1" , ("filename1", open("filePath1", "rb"))),
# ("field1" , ("filename2", open("filePath2", "rb"), "image/png")),
# ("field1" , open("filePath3", "rb")),
# ("field1" , open("filePath4", "rb").read())
# ]
upload_files = []
for root, dirs, files in os.walk("./watch_launcher"):
for f in files:
upload_files.append(("binfiles", (f, open(os.sep.join([root, f]), "rb"))))
# print(upload_files)
res = requests.post(url, datas, files = upload_files)
result = res.json()
print(result)
if result['code'] == 200:
down_res = requests.get(url=result['data']['app_url'])
with open(result['data']['app_file'], "wb") as fd:
fd.write(down_res.content)
\ No newline at end of file
{"appName": "Launcher", "appVersion": "1.0", "files": [{"path": "C:/Launcher.json", "name": "Launcher.json", "size": 723, "basename": "Launcher", "ext": "json"}, {"path": "C:/app.js", "name": "app.js", "size": 126, "basename": "app", "ext": "js"}, {"path": "C:/evue_launcher.evue", "name": "evue_launcher.evue", "size": 2371, "basename": "evue_launcher", "ext": "evue"}, {"path": "C:/evue_launcher.md5", "name": "evue_launcher.md5", "size": 16, "basename": "evue_launcher", "ext": "md5"}, {"path": "C:/evue_logo.bin", "name": "evue_logo.bin", "size": 67504, "basename": "evue_logo", "ext": "bin"}, {"path": "C:/watch_launcher.json", "name": "watch_launcher.json", "size": 622, "basename": "watch_launcher", "ext": "json"}]}
\ No newline at end of file
function onCreate() {
print("Application onCreate");
}
function onDestroy() {
print("Application onDestroy");
}
\ No newline at end of file
<html>
<div class="container">
<image src="evue_logo.bin" style="top: 20px;left: 40px;"></image>
<text style="top:190px;background-color: transparent; color: white;font-size: 20px;width: 240px;height: 25px;text-align: center;">{{ title }}</text>
</div>
</html>
<script>
router = require("@system.router")
http = require("@system.http")
fs = require("@system.fs")
watch = require("@system.watch")
os = require("@system.os")
export default {
data: {
title: 'Power by EVM!',
epk_remote_url: 'http://store.evmiot.com/api/v1/evm_store/download/apps',
path_prefix: '',
epk_name: 'evue_launcher.epk',
fpath: '',
url_dock: 'evue_dock',
url_404: 'evue_404',
appId: "evue_launcher"
},
onInit: function() {},
onReady: function() {
this.fpath = this.epk_name;
},
onShow: function() {
setTimeout(function() {
this.install();
}, 10)
},
install: function() {
this.installLauncherEpk(this.appId, this.epk_remote_url)
router.push({
path: this.url_dock
})
},
onHide: function() {},
onDestroy: function() {},
installLauncherEpk: function(appId, epk_remote_url) {
headers = [
"Accept: application/json",
"Content-Type: application/json",
"charsets: utf-8"
]
var res = http.request({
method: "POST",
url: epk_remote_url,
headers: headers,
data: JSON.stringify({
"id": appId,
"imei": watch.imei()
}),
timeout: 10000,
responseType: "epk",
callback: function(res, len) {},
error: function(code) {}
});
}
}
</script>
<style>
.container {
width: 240px;
height: 240px;
border-width: 0px;
border-radius: 0px;
margin: 0px;
padding: 0px;
opacity: 0;
background-color: transparent;
align-items: off;
}
</style>
\ No newline at end of file
q
TMC
\ No newline at end of file
{"appName": "watch_launcher", "appVersion": "1.0", "files": [{"path": "C:/watch_launcher.json", "name": "watch_launcher.json", "size": 622, "basename": "watch_launcher", "ext": "json"}, {"path": "C:/app.js", "name": "app.js", "size": 126, "basename": "app", "ext": "js"}, {"path": "C:/evue_launcher.evue", "name": "evue_launcher.evue", "size": 2371, "basename": "evue_launcher", "ext": "evue"}, {"path": "C:/evue_launcher.md5", "name": "evue_launcher.md5", "size": 16, "basename": "evue_launcher", "ext": "md5"}, {"path": "C:/evue_logo.bin", "name": "evue_logo.bin", "size": 67504, "basename": "evue_logo", "ext": "bin"}]}
\ No newline at end of file
......@@ -79,6 +79,7 @@ def application_build():
os.makedirs(upload_path)
for f in request.files.getlist('binfiles'):
filename = secure_filename(f.filename)
print(filename)
file_path = os.sep.join([upload_path, filename])
f.save(file_path)
files.append(file_path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment