Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
Add command line functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
sco1 committed Jul 27, 2017
1 parent ea65158 commit 7c33fd5
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions AltiForce.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import matplotlib
matplotlib.use("TkAgg")
matplotlib.use("TkAgg") # Keep matplotlib and tkinter from conflicting and segfaulting
import matplotlib.pyplot as plt

from tkinter import Tk
from tkinter.filedialog import askopenfilename
import numpy as np
from numpy.lib import recfunctions as rfn
import argparse
from pathlib import Path

class AltiForce():
def __init__(self, filepath):
Expand Down Expand Up @@ -52,11 +53,25 @@ def plotdata(self):


if __name__ == "__main__":
root = Tk()
root.withdraw()
filepath = askopenfilename()
root.destroy()
parser = argparse.ArgumentParser(description=('Parsing for AltiForce GoPro Backpack CSV, '
'specify a file with the -f or --file flags '
'or leave blank for a GUI prompt'
)
)
parser.add_argument("-f", "--file",
help="Parse manually specified file (relative or absolute path)",
action="store")
args = parser.parse_args()
if args.file:
filepath = Path(args.file)
else:
root = Tk()
root.withdraw()
filepath = Path(askopenfilename())
root.destroy()

if filepath:
if filepath.exists():
mydata = AltiForce(filepath)
mydata.plotdata()
else:
raise(ValueError)

0 comments on commit 7c33fd5

Please sign in to comment.