Skip to content

Commit

Permalink
添加构建脚本 修复log文件路径bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xhlove committed Feb 19, 2022
1 parent f9ff7bf commit 1843c61
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/dev_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This is a basic workflow to help you get started with Actions

name: build_dev_pkg

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
# push:
# branches: [ master ]
# pull_request:
# branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: windows-latest
steps:
- name: Get current time
uses: josStorer/get-current-time@v2
id: ct
with:
format: YYYYMMDD-HH
utcOffset: "+08:00"
- uses: actions/checkout@v2
- name: build with pyinstaller
uses: actions/setup-python@v2
with:
python-version: 3.7.5
- name: upgrade pip
run: python -m pip install --upgrade pip
- name: install requirements.txt
run: pip install -r requirements.txt
- name: install pyinstaller
run: pip install pyinstaller
- name: run pyinstaller command
env:
BUILD_TIME: "${{ steps.ct.outputs.year }}${{ steps.ct.outputs.month }}${{ steps.ct.outputs.day }}_${{ steps.ct.outputs.hour }}${{ steps.ct.outputs.minute }}${{ steps.ct.outputs.second }}"
run: pyinstaller -n pyshaka_dev_${{ env.BUILD_TIME }} -F pyshaka\main.py
- name: Upload Artifact
env:
BUILD_TIME: "${{ steps.ct.outputs.year }}${{ steps.ct.outputs.month }}${{ steps.ct.outputs.day }}_${{ steps.ct.outputs.hour }}${{ steps.ct.outputs.minute }}${{ steps.ct.outputs.second }}"
uses: actions/[email protected]
with:
name: pyshaka_dev_${{ env.BUILD_TIME }}
path: dist\pyshaka_dev_${{ env.BUILD_TIME }}.exe
File renamed without changes.
6 changes: 5 additions & 1 deletion pyshaka/log.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import logging
import datetime
from pathlib import Path
Expand All @@ -6,7 +7,10 @@
def setup_logger(name: str, write_to_file: bool = False) -> logging.Logger:
formatter = logging.Formatter('%(asctime)s %(name)s %(filename)s %(lineno)s : %(levelname)s %(message)s')
log_time = datetime.datetime.now().strftime("%Y-%m-%d_%H%M%S")
log_folder_path = Path(__name__.split('.')[0], 'logs')
if getattr(sys, 'frozen', False):
log_folder_path = Path(sys.executable).parent / 'logs'
else:
log_folder_path = Path(__file__).parent.parent / 'logs'
if log_folder_path.exists() is False:
log_folder_path.mkdir()

Expand Down

0 comments on commit 1843c61

Please sign in to comment.