Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyahui committed Jan 19, 2019
1 parent af1a886 commit 3ec3844
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 116 deletions.
233 changes: 125 additions & 108 deletions .idea/workspace.xml

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions local_transfer_file/file_select_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import traceback
import logging
import sys

from PyQt5.QtWidgets import QMainWindow, QMessageBox, QFileDialog
import qrcode
Expand Down Expand Up @@ -47,8 +48,13 @@ def init_menu_action(self):
self.ui.action_3.triggered.connect(self.aboutMe)

def set_config(self, code, file_path):
current_dir = os.path.dirname(os.path.abspath(__file__))
config_file = os.path.join(current_dir, "service/config.json")
if getattr(sys, 'frozen', False):
bundle_dir = sys._MEIPASS
config_file = os.path.join(bundle_dir, "config.json")
else:
bundle_dir = os.path.dirname(os.path.abspath(__file__))

config_file = os.path.join(bundle_dir, "service/config.json")
data = {
"file_path": file_path,
"code": code
Expand Down Expand Up @@ -124,6 +130,7 @@ def selectFileMode(self):
if self.file_mode == FileMode.DIRECTORMODE:
QMessageBox.warning(self, "警告", "出于安全考虑,请尽量不要分享文件夹,可以打包后分享或者下载!")
self.ui.showFilePath.clear()
self.ui.showUrlText.clear()

def setShowAgain(self, isNotShowAgain):
self.need_show_again = not isNotShowAgain
Expand Down
3 changes: 3 additions & 0 deletions local_transfer_file/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from local_transfer_file.run_server_thread import CustomServerThread

from local_transfer_file.utils import get_local_ip, setup_logging
# pyinstaller import
import local_transfer_file.service
import local_transfer_file.ui_files


def main():
Expand Down
2 changes: 1 addition & 1 deletion local_transfer_file/service/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"code": "aafc92e61b8a11e9ae6b1831bfbd596c",
"code": "1e05da7e1bd311e9a64a1831bfbd596c",
"file_path": "D:/programeCode/python/testCode/GUI/pyqt5/local_transfer_file/local_transfer_file/background.jpeg"
}
12 changes: 9 additions & 3 deletions local_transfer_file/service/request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@

from http.server import SimpleHTTPRequestHandler, HTTPStatus

current_dir = os.path.dirname(os.path.abspath(__file__))
config_file = os.path.join(current_dir, "config.json")
if getattr(sys, 'frozen', False):
bundle_dir = sys._MEIPASS
config_file = os.path.join(bundle_dir, "config.json")
else:
bundle_dir = os.path.dirname(os.path.abspath(__file__))

config_file = os.path.join(bundle_dir, "config.json")

logger = logging.getLogger()


Expand Down Expand Up @@ -178,7 +184,7 @@ def do_GET(self):
if os.path.isdir(path):
if not path.endswith("/"):
path += "/"
f = self.list_directory(path)
f = self.list_directory(path)
else:
f = self.get_file(path)
if f:
Expand Down
10 changes: 9 additions & 1 deletion local_transfer_file/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import logging.config
import json
import sys

import psutil

Expand Down Expand Up @@ -42,7 +43,14 @@ def setup_logging(
"""
if default_path is None:
default_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "logging.json")
if getattr(sys, 'frozen', False):
bundle_dir = sys._MEIPASS
default_path = os.path.join(bundle_dir, "logging.json")
else:
bundle_dir = os.path.dirname(os.path.abspath(__file__))

default_path = os.path.join(bundle_dir, "logging.json")
# default_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "logging.json")
path = default_path
value = os.getenv(env_key, None)
if value:
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
packages=find_packages(),
include_package_data=True,
platforms="any",
install_requires=[],
install_requires=[
"PyQt5",
"qrcode"
],

scripts=[],
entry_points={
Expand Down

0 comments on commit 3ec3844

Please sign in to comment.