Skip to content

Commit

Permalink
修改编译spec
Browse files Browse the repository at this point in the history
  • Loading branch information
kerlomz committed Dec 3, 2021
1 parent b12e5b3 commit c886d45
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 40 deletions.
36 changes: 2 additions & 34 deletions package.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding:utf-8 -*-
# Author: kerlomz <[email protected]>
import os
import cv2
import time
import stat
import socket
Expand Down Expand Up @@ -47,37 +48,4 @@ class Version(Enum):
opts = ['tornado_server_gpu.spec', '--distpath=dist']
else:
opts = ['tornado_server.spec', '--distpath=dist']
run(opts)

if upload:
transport = paramiko.Transport(sock=(server_ip, 22))
transport.connect(username=username, password=password)
sftp = paramiko.SFTPClient.from_transport(transport)

with open("dist/start.sh", "w", encoding="utf8") as f:
f.write("nohup ./captcha_platform_tornado &")

SystemUtils.empty(sftp, '/home/captcha_platform')
logger.info('uploading app...')

SystemUtils.empty(sftp, '/home/captcha_platform/graph')
SystemUtils.empty(sftp, '/home/captcha_platform/model')

for model in os.listdir(model_dir):
if os.path.isdir(model):
continue
sftp.put(os.path.join(model_dir, model), '/home/captcha_platform/model/{}'.format(model))

for graph in os.listdir(graph_dir):
sftp.put(os.path.join(graph_dir, graph), '/home/captcha_platform/graph/{}'.format(graph))

sftp.put("dist/captcha_platform_tornado", '/home/captcha_platform/captcha_platform_tornado')
sftp.put("dist/start.sh", '/home/captcha_platform/start.sh')
sftp.put("config.yaml", '/home/captcha_platform/config.yaml')

sftp.chmod('/home/captcha_platform/captcha_platform_tornado', stat.S_IRWXU)
sftp.chmod('/home/captcha_platform/start.sh', stat.S_IRWXU)

logger.info('uploaded.')
logger.info('update completed!')
transport.close()
run(opts)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Flask-Caching
gevent-websocket
tf-nightly
pillow
opencv-python
opencv-python-headless
numpy
grpcio
grpcio_tools
Expand Down
2 changes: 1 addition & 1 deletion resource/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20201109
20211203
2 changes: 1 addition & 1 deletion tornado_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
arithmetic = Arithmetic()
semaphore = asyncio.Semaphore(500)

scheduler = BackgroundScheduler(timezone=utc)
scheduler = BackgroundScheduler(timezone='Asia/Shanghai')


class BaseHandler(RequestHandler):
Expand Down
14 changes: 11 additions & 3 deletions tornado_server.spec
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# -*- mode: python -*-
# Used to package as a single executable
# This is a configuration file
import cv2
import os
from PyInstaller.utils.hooks import collect_all


block_cipher = None

binaries, hiddenimports = [], ['numpy.core._dtype_ctypes']
tmp_ret = collect_all('tzdata')
added_files = [('resource/icon.ico', 'resource'), ('resource/favorite.ico', '.'), ('resource/VERSION', 'astor'), ('resource/VERSION', '.')]
added_files += tmp_ret[0]; binaries += tmp_ret[1]
hiddenimports += tmp_ret[2]

a = Analysis(['tornado_server.py'],
pathex=['.'],
binaries=[],
pathex=['.', os.path.join(os.path.dirname(cv2.__file__), 'config-3.9')],
binaries=binaries,
datas=added_files,
hiddenimports=['numpy.core._dtype_ctypes'],
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=[],
Expand Down

0 comments on commit c886d45

Please sign in to comment.