-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.Fix not responding problem.
- Loading branch information
Showing
14 changed files
with
201 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from .shell import Shell | ||
from .py2app import Py2App | ||
from .pyinstaller import PyInstaller | ||
|
||
app_shell: Shell | ||
|
||
|
||
def init_app_shell(): | ||
global app_shell | ||
if PyInstaller.check(): | ||
app_shell = PyInstaller() | ||
elif Py2App.check(): | ||
app_shell = Py2App() | ||
else: | ||
app_shell = Shell() | ||
|
||
return app_shell | ||
|
||
|
||
def get_app_shell(): | ||
return app_shell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import os | ||
|
||
from .shell import Shell | ||
|
||
|
||
class Py2App(Shell): | ||
def __init__(self): | ||
super().__init__() | ||
if self.check(): | ||
self.fix_encoding() | ||
self.runtime_dir = os.path.abspath(os.getcwd()) | ||
self.app_path = os.path.abspath('%s/../..' % self.runtime_dir) | ||
|
||
@staticmethod | ||
def check(): | ||
return os.getenv('_PY2APP_LAUNCHED_') is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
import sys | ||
|
||
from .shell import Shell | ||
|
||
|
||
class PyInstaller(Shell): | ||
def __init__(self): | ||
super().__init__() | ||
if self.check(): | ||
self.fix_encoding() | ||
self.runtime_dir = os.path.abspath(getattr(sys, '_MEIPASS', '.')) | ||
if getattr(sys, 'frozen', False): | ||
self.app_path = os.path.abspath('%s/../../..' % sys.executable) | ||
|
||
@staticmethod | ||
def check(): | ||
return getattr(sys, '_MEIPASS', None) is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import sys | ||
from subprocess import Popen | ||
|
||
|
||
class Shell: | ||
def __init__(self): | ||
self.runtime_dir = '.' | ||
self.app_path = None | ||
|
||
@staticmethod | ||
def check(): | ||
return False | ||
|
||
def get_app_path(self): | ||
return self.app_path | ||
|
||
def get_runtime_dir(self): | ||
return self.runtime_dir | ||
|
||
@staticmethod | ||
def fix_encoding(): | ||
encoding = sys.getdefaultencoding() | ||
_init = Popen.__init__ | ||
|
||
def init(*args, **kwargs): | ||
kwargs['encoding'] = kwargs.get('encoding', encoding) | ||
return _init(*args, **kwargs) | ||
|
||
Popen.__init__ = init | ||
|
||
__open = open | ||
|
||
def _open(*args, **kwargs): | ||
if len(args) >= 2: | ||
mode = args[1] | ||
else: | ||
mode = kwargs.get('mode') | ||
|
||
if isinstance(mode, str) and 'b' not in mode: | ||
kwargs['encoding'] = kwargs.get('encoding', encoding) | ||
return __open(*args, **kwargs) | ||
|
||
__builtins__['open'] = _open |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
requests==2.22.0 | ||
rumps==0.3.0 | ||
opencv_python==4.1.0.25 | ||
PyExecJS==1.5.1 | ||
PyInstaller==3.5 | ||
PyInstaller==3.5 | ||
py2app==0.19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
This is a setup.py script generated by py2applet | ||
Usage: | ||
python setup.py py2app | ||
""" | ||
|
||
import time | ||
|
||
from setuptools import setup | ||
|
||
from app.res.const import Const | ||
|
||
APP = ['__main__.py'] | ||
DATA_FILES = [] | ||
OPTIONS = { | ||
'argv_emulation': True, | ||
'iconfile': 'app/res/icon.icns', | ||
'plist': { | ||
'CFBundleName': Const.app_name, | ||
'CFBundleDisplayName': Const.app_name, | ||
'CFBundleGetInfoString': Const.github_page, | ||
'CFBundleIdentifier': Const.app_name, | ||
'CFBundleVersion': Const.version, | ||
'CFBundleShortVersionString': Const.version, | ||
'NSHumanReadableCopyright': "Copyright © %d, %s, All Rights Reserved" % ( | ||
time.localtime().tm_year, Const.author), | ||
'LSUIElement': True, | ||
} | ||
} | ||
|
||
setup( | ||
app=APP, | ||
data_files=DATA_FILES, | ||
options={'py2app': OPTIONS}, | ||
setup_requires=['py2app', 'rumps', 'requests'], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters