Skip to content

Commit

Permalink
Merge 9914c44 into 6327038
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbrook authored Feb 16, 2024
2 parents 6327038 + 9914c44 commit 82aaece
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 55 deletions.
66 changes: 44 additions & 22 deletions .github/workflows/build-exe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,7 @@ jobs:
# - name: Get current date and time
# id: date
# run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H_%M_%S')"
# - name: Release
# uses: softprops/action-gh-release@v1
# with:
# tag_name: ${{ github.ref_name }}-${{ steps.date.outputs.date }}
# files: ./*

# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: '3.8' # Replace '3.x' with your Python version

# - name: install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt

# - name: run pyinstaller
# run: |
# pyinstaller --onefile ./parser_exe.py
# - name: check what files we cooked up
# run: |
# ls -R

- name: install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -55,6 +34,7 @@ jobs:
ls -r
mkdir .\dist\test
xcopy ".\test" ".\dist\test" /E
copy ".\dataPlots.m" ".\dist"
- name: release-downloader
uses: robinraju/[email protected]
Expand All @@ -73,7 +53,15 @@ jobs:
path: |
./dist/*
./build/*
./*.m
# - name: release all files
# uses: softprops/action-gh-release@v1
# with:
# tag_name: ${{ github.ref_name }}-${{ steps.date.outputs.date }}
# files: |
# ./*

test-exe:
needs: build
runs-on: windows-latest
Expand All @@ -98,3 +86,37 @@ jobs:
# path: |
# ./build/*
# ./dist/parser_exe
release-bin:
needs: [build,test-exe]
runs-on: windows-latest
steps:
- name: download artifact
uses: actions/download-artifact@v2
with:
name: parser-exe-windows
path: parser-exe-download
- name: compress artifact
run: |
tar -czvf parser-exe-windows.zip ./parser-exe-download
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.run_number }}
release_name: ${{ github.ref_name }}_release_windows_${{ github.run_number }}
draft: false
prerelease: false

- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./parser-exe-windows.zip
asset_name: parser_exe_windows.zip
asset_content_type: application/zip

48 changes: 44 additions & 4 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
- name: checkout code
uses: actions/checkout@v2

# - name: Get current date and time
# id: date
# run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H_%M_%S')"
- name: Get current date and time
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H_%M_%S')"
# - name: Release
# uses: softprops/action-gh-release@v1
# with:
Expand Down Expand Up @@ -45,6 +45,7 @@ jobs:
run: |
ls -R
cp -r ./test ./dist
cp ./dataPlots.m ./dist
Expand All @@ -65,6 +66,12 @@ jobs:
path: |
./build/*
./dist/*
- name: release all files
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}-${{ steps.date.outputs.date }}
files: |
./*
test-bin:
needs: build
Expand All @@ -82,5 +89,38 @@ jobs:
chmod u+x ./parser_exe
./parser_exe -h
./parser_exe --getdbc --test -v
release-bin:
needs: [build,test-bin]
runs-on: ubuntu-latest
steps:
- name: download artifact
uses: actions/download-artifact@v2
with:
name: parser-exe-linux
path: parser-exe-download
- name: compress artifact
run: |
tar -czvf parser-exe-linux.tar.gz ./parser-exe-download
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.run_number }}
release_name: ${{ github.ref_name }}_release_linux_${{ github.run_number }}
draft: false
prerelease: false

- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./parser-exe-linux.tar.gz
asset_name: parser_exe_linux.tar.gz
asset_content_type: application/zip

34 changes: 22 additions & 12 deletions parser_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
import tempfile
import shutil
import time
import parser_logger
import parser_utils.parser_logger as parser_logger
import logging

DEBUG = False # Set True for optional error print statements
PARSER_EXIT_TIMEOUT = 10


def get_dbc_files(path_name='dbc-files') -> cantools.db.Database:
Expand Down Expand Up @@ -66,6 +67,7 @@ def get_dbc_files(path_name='dbc-files') -> cantools.db.Database:
if (len(mega_dbc.messages) > 0):
logging.info(
f"dbc successfully created with {len(mega_dbc.messages)} messages")
logging.info(f"DBC VERSION: {mega_dbc.version}")
return mega_dbc
else:
logging.warning(f"error: dbc was empty! it has no messages :(")
Expand Down Expand Up @@ -355,6 +357,16 @@ def parse_folder(input_path, dbc_file: cantools.db.Database):
# Generate the main DBC file object for parsing
dbc_file = dbc_file
dbc_ids = parse_ids_in_database(dbc_file)
num_of_csvs_in_folder = 0
for file in os.listdir(newpath):
filename = os.fsdecode(file)
if filename.endswith(".CSV") or filename.endswith(".csv"):
logging.debug(f"found csv: {filename}")
num_of_csvs_in_folder+=1
logging.info(f"found {num_of_csvs_in_folder} CSVs in {newpath}")
if num_of_csvs_in_folder == 0:
logging.warning("there are ZERO CSV files in this folder. did you select the right one?")

# Loops through files and call parse_file on each raw CSV.
for file in os.listdir(newpath):
filename = os.fsdecode(file)
Expand All @@ -367,7 +379,7 @@ def parse_folder(input_path, dbc_file: cantools.db.Database):
logging.info(
f"Successfully parsed: {filename} with {length} lines in {end_time-start_time} seconds")
except (ValueError,PermissionError) as e:
logging.error(f"attemp to parse {filename} raised error {e}")
logging.error(f"attempt to parse {filename} raised error {e}")
else:
logging.debug("Skipped " + filename +
" because it does not end in .csv")
Expand Down Expand Up @@ -413,9 +425,7 @@ def read_files(folder):
file_count += 1
except:
logging.error('error: Process failed at step 1.')
logging.warning('exiting in 3 seconds...')
time.sleep(3)
sys.exit(0)
return None

logging.info('Step 1: found ' + str(file_count) +
' files in the ' + path_name + ' folder')
Expand All @@ -432,7 +442,11 @@ def create_dataframe(files=[]):
try:
df_list = []
for f in files:
df = pd.read_csv(f)
try:
df = pd.read_csv(f)
except pd.errors.EmptyDataError as e:
logging.error(f"failed to read csv ({f}) into dataframe: {e}")
continue
df_list.append(df)
except:
logging.error('error: Process failed at step 2.')
Expand Down Expand Up @@ -481,9 +495,7 @@ def get_time_elapsed(frames=[]):
continue
except:
logging.error('error: Process failed at step 3.')
logging.error('exiting in 3 seconds...')
time.sleep(3)
sys.exit(0)
return None

logging.info('Step 3: calculated elapsed time')
return df_list
Expand Down Expand Up @@ -542,9 +554,7 @@ def create_struct(frames=[]):

except:
logging.error('error: Process failed at step 4.')
logging.warning('exiting in 3 seconds...')
time.sleep(3)
sys.exit(0)
return None

logging.info('Step 4: created struct')
return struct
Expand Down
44 changes: 32 additions & 12 deletions parser_exe.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
from folder_selection_utils import select_folder_and_get_path,select_folder_and_get_path_dbc
from download_latest_dbc_from_releases import download_latest_release
from parser_utils.folder_selection_utils import select_folder_and_get_path,select_folder_and_get_path_dbc,open_path
from parser_utils.download_latest_dbc_from_releases import download_latest_release
from parser_api import *
from parser_utils.big_text_prints import *
import sys
import argparse
import subprocess
import parser_logger, logging
import importlib
import parser_utils.parser_logger as parser_logger, logging
sys.path.insert(1, "../telemetry_parsers")
########################################################################
# Entry Point to Framework
########################################################################


def main(args):
logging.info("Welcome to KSU motorsports parser")
logging.info("Welcome to KSU motorsports CAN parser")
logging.info(PARSER_INIT_TEXT)
logging.info("The process will be of two parts: CSV to CSV parsing, and then CSV to MAT parsing.")
dbc_found = False
dbc_files_folder_good = True
if args.getdbc:
logging.info("Downloading latest dbc")
download_latest_release()

logging.info("Looking for dbc-files folder: ")
logging.info("Looking for 'dbc-files' folder: ")
while not dbc_found:
if not os.path.exists("dbc-files") or dbc_files_folder_good == False:
logging.warning("'dbc-files' folder was not found or failed to load dbcs.")
Expand All @@ -40,8 +42,8 @@ def main(args):
dbc_file = get_dbc_files(dbc_files_path)
elif dbc_files_path is None:
logging.warning(f"selected path was {dbc_files_path}, which means you exited or cancelled the prompt")
logging.warning("exiting the program in 3 secs ! byebye")
time.sleep(3)
logging.warning(f"exiting the program in {PARSER_EXIT_TIMEOUT} secs ! byebye")
time.sleep(PARSER_EXIT_TIMEOUT)
sys.exit()
if dbc_found and dbc_file is not None:
break
Expand All @@ -59,7 +61,8 @@ def main(args):
elif dbc_file is None:
dbc_files_folder_good = False

logging.info("Beginning CSV to CSV parsing...")
logging.info("beginning CSV to CSV parsing")
logging.info(PARSER_STARTING_TEXT)
parsing_folder_path=None
if not args.test:
logging.info("Select a folder which contains the raw logs to be parsed")
Expand All @@ -78,19 +81,30 @@ def main(args):
except (TypeError,FileNotFoundError) as e:
logging.error(f"Error ({type(e)}-{e}) when trying to parse folder {parsing_folder_path} :(")
logging.warning("Parsing folder step failed")
logging.info(PARSER_CSV_FINISHED_TEXT)
logging.info("Beginning CSV to MAT parsing...")
logging.info(PARSER_MAT_START_TEXT)
create_mat_success = create_mat()
if create_mat_success:
logging.info("Finished CSV to MAT parsing.")
elif not create_mat_success:
logging.warning("CSV to MAT parsing step failed")
logging.info(PARSER_MAT_FINISHED_TEXT)
logging.info("Parsing Complete.")
logging.info('Program exiting in 3 seconds...')
time.sleep(3)
logging.info(PARSER_FINISHED_TEXT)
if parsing_folder_path is not None:
logging.info(f"the parsed data is in {parsing_folder_path}")
logging.info(f"opening the folder with your parsed files: '{parsing_folder_path}'")
try:
open_path(parsing_folder_path)
except:
logging.error(f"opening {parsing_folder_path} failed.")
logging.info(f'Program exiting in {PARSER_EXIT_TIMEOUT} seconds...')
time.sleep(PARSER_EXIT_TIMEOUT)


if __name__ == "__main__":

parser = argparse.ArgumentParser(
description='KSU Motorsports parser! \nThese args configure how the parser is run')
parser.add_argument('--getdbc',action="store_true" , help='include this flag if you want to download the latest dbc.')
Expand All @@ -99,4 +113,10 @@ def main(args):
parser.add_argument('-v','--verbose',action="store_true",help="will show debug prints (this will spam your console but show more info)")
args = parser.parse_args()
parser_logger.setup_logger(args.verbose)
if '_PYIBoot_SPLASH' in os.environ and importlib.util.find_spec("pyi_splash"):
import pyi_splash
pyi_splash.update_text("UPDATED TEXT")
time.sleep(5)
pyi_splash.close()
logging.debug('App loaded and splash screen closed.')
main(args)
11 changes: 11 additions & 0 deletions parser_exe.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@ a = Analysis(
noarchive=False,
)
pyz = PYZ(a.pure)
splash = Splash(
'.\\readmepics\\kennesawmotorsports.jpg',
binaries=a.binaries,
datas=a.datas,
text_pos=None,
text_size=12,
minify_script=True,
always_on_top=True,
)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
splash,
splash.binaries,
[],
name='parser_exe',
debug=False,
Expand Down
Loading

0 comments on commit 82aaece

Please sign in to comment.