Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/fancy tab #13

Merged
merged 13 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ignore$
^Autocoders/Python/test/.*\.xml$
/doc/xml/
/third-party/
/third/
/vendor/
/modified-vendor/
\.min\.
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ada
addon
addslash
ADEBAD
adrianheine
allbox
ALLEXTERNALS
ALOG
Expand Down Expand Up @@ -79,6 +80,7 @@ CMake
cmdhist
cmds
CODEFILE
Codemirror
colorized
COLORSTYLE
colorwheel
Expand Down Expand Up @@ -155,6 +157,7 @@ doxypypy
doxyrules
doxysearch
Doxywizard
doy
dropdown
dropleft
dropright
Expand Down Expand Up @@ -230,6 +233,7 @@ getroot
getsize
github
globals
gmail
gnumeric
Golang
graphviz
Expand All @@ -241,6 +245,7 @@ gz
hardcoded
hardcoding
hasattr
Haverbeke
hdl
hgroup
hh
Expand Down Expand Up @@ -317,11 +322,13 @@ kinda
kwargs
len
lestarch
Lezer
lgtm
libc
libclang
libcrc
libiconv
Linting
Linux
listbox
listdir
Expand All @@ -341,6 +348,7 @@ MAINPAGE
makedirs
makeindex
MAKEVAR
marijnh
matchobj
mathjax
maxcountryman
Expand Down Expand Up @@ -383,6 +391,7 @@ Noto
novalidate
nowait
nowrap
npm
NSPACES
objs
odf
Expand Down Expand Up @@ -485,6 +494,7 @@ rgb
rgba
riverbankcomputing
Roboto
rollup
rpaetz
rst
rtd
Expand Down Expand Up @@ -528,6 +538,7 @@ startswith
startuml
staticmethod
stderr
Stdio
stdout
strftime
stringified
Expand Down Expand Up @@ -558,12 +569,14 @@ tcp
tcpserver
td
telem
tempdir
testcase
TESTLIST
textarea
textbox
tgz
thead
Theif
thtcp
thudp
timebase
Expand Down Expand Up @@ -650,6 +663,7 @@ webbrowser
webified
webkit
webp
webpack
webserver
website
werkzeug
Expand Down
70 changes: 40 additions & 30 deletions src/fprime_gds/common/parsers/seq_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@


class SeqFileParser:
def parse(self, filename):
def parse(self, filename, cont=False):
"""
Generator that parses an input sequence file and returns a tuple
for each valid line of the sequence file.
@param seqfile: A sequence file name (usually a .seq extension)
@param cont: attempt to continue after a line fails to parse, hopefully revealing more errors
@return A list of tuples:
(lineNumber, descriptor, seconds, useconds, mnemonic, arguments)
"""
Expand Down Expand Up @@ -189,41 +190,50 @@ def parseAbsolute(timeStr):

# Open the sequence file and parse each line:
with open(filename) as inputFile:
messages = []
for i, line in enumerate(inputFile):
line = line.strip()
# ignore blank lines and comments
if line and line[0] != ";":
line = removeTrailingComments(line)
line = splitString(line)
length = len(line)
if length < 2:
raise gseExceptions.GseControllerParsingException(
"Line %d: %s"
% (
i + 1,
"Each line must contain a minimum of two fields, time and command mnemonic\n",
)
)
else:
try:
descriptor, seconds, useconds = parseTime(i, line[0])
except:
try:
line = line.strip()
# ignore blank lines and comments
if line and line[0] != ";":
line = removeTrailingComments(line)
line = splitString(line)
length = len(line)
if length < 2:
raise gseExceptions.GseControllerParsingException(
"Line %d: %s"
% (i + 1, "Encountered syntax error parsing timestamp")
% (
i + 1,
"Each line must contain a minimum of two fields, time and command mnemonic\n",
)
)
mnemonic = line[1]
args = []
if length > 2:
args = line[2:]
else:
try:
args = parseArgs(args)
descriptor, seconds, useconds = parseTime(i, line[0])
except:
raise gseExceptions.GseControllerParsingException(
"Line %d: %s"
% (
i + 1,
"Encountered syntax error parsing arguments",
)
% (i + 1, "Encountered syntax error parsing timestamp")
)
yield i, descriptor, seconds, useconds, mnemonic, args
mnemonic = line[1]
args = []
if length > 2:
args = line[2:]
try:
args = parseArgs(args)
except:
raise gseExceptions.GseControllerParsingException(
"Line %d: %s"
% (
i + 1,
"Encountered syntax error parsing arguments",
)
)
yield i, descriptor, seconds, useconds, mnemonic, args
except gseExceptions.GseControllerParsingException as exc:
if not cont:
raise
messages.append(exc.getMsg())
if cont and messages:
raise gseExceptions.GseControllerParsingException("\n".join(messages))

80 changes: 44 additions & 36 deletions src/fprime_gds/common/tools/seqgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, val):
# __error("The Gse source code was not found in your $PYTHONPATH variable. Please set PYTHONPATH to something like: $BUILD_ROOT/Gse/src:$BUILD_ROOT/Gse/generated/$DEPLOYMENT_NAME")


def generateSequence(inputFile, outputFile, dictionary, timebase):
def generateSequence(inputFile, outputFile, dictionary, timebase, cont=False):
"""
Write a binary sequence file from a text sequence file
@param inputFile: A text input sequence file name (usually a .seq extension)
Expand All @@ -71,53 +71,61 @@ def generateSequence(inputFile, outputFile, dictionary, timebase):
command_list = []
file_parser = SeqFileParser()

parsed_seq = file_parser.parse(inputFile)
parsed_seq = file_parser.parse(inputFile, cont=cont)

messages = []
try:
for i, descriptor, seconds, useconds, mnemonic, args in parsed_seq:
# Make sure that command is in the command dictionary:
if mnemonic in cmd_name_dict:
command_temp = copy.deepcopy(cmd_name_dict[mnemonic])
# Set the command arguments:
try:
command_temp.setArgs(args)
except ArgLengthMismatchException as e:
try:
# Make sure that command is in the command dictionary:
if mnemonic in cmd_name_dict:
command_temp = copy.deepcopy(cmd_name_dict[mnemonic])
# Set the command arguments:
try:
command_temp.setArgs(args)
except ArgLengthMismatchException as e:
raise SeqGenException(
"Line %d: %s"
% (
i + 1,
"'"
+ mnemonic
+ "' argument length mismatch. "
+ e.getMsg(),
)
)
except TypeException as e:
raise SeqGenException(
"Line %d: %s"
% (
i + 1,
"'" + mnemonic + "' argument type mismatch. " + e.getMsg(),
)
)
# Set the command time and descriptor:
command_temp.setDescriptor(descriptor)
command_temp.setSeconds(seconds)
command_temp.setUseconds(useconds)
# Append this command to the command list:
command_list.append(command_temp)
else:
raise SeqGenException(
"Line %d: %s"
% (
i + 1,
"'"
+ mnemonic
+ "' argument length mismatch. "
+ e.getMsg(),
+ "' does not match any command in the command dictionary.",
)
)
except TypeException as e:
raise SeqGenException(
"Line %d: %s"
% (
i + 1,
"'" + mnemonic + "' argument type mismatch. " + e.getMsg(),
)
)
# Set the command time and descriptor:
command_temp.setDescriptor(descriptor)
command_temp.setSeconds(seconds)
command_temp.setUseconds(useconds)
# Append this command to the command list:
command_list.append(command_temp)
else:
raise SeqGenException(
"Line %d: %s"
% (
i + 1,
"'"
+ mnemonic
+ "' does not match any command in the command dictionary.",
)
)
except SeqGenException as exc:
if not cont:
raise
messages.append(exc.getMsg())
except gseExceptions.GseControllerParsingException as e:
raise SeqGenException(e.getMsg())
raise SeqGenException("\n".join([e.getMsg()] + messages))
if cont and messages:
raise SeqGenException("\n".join(messages))

# Write to the output file:
writer = SeqBinaryWriter(timebase=timebase)
Expand Down
8 changes: 8 additions & 0 deletions src/fprime_gds/flask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import fprime_gds.flask.json
import fprime_gds.flask.logs
import fprime_gds.flask.updown
import fprime_gds.flask.sequence

from . import components

Expand Down Expand Up @@ -122,6 +123,13 @@ def construct_app():
"/download/files/<string:source>",
resource_class_args=[pipeline.files.downlinker],
)
api.add_resource(
fprime_gds.flask.sequence.SequenceCompiler,
"/sequence",
resource_class_args=[app.config["DICTIONARY"], app.config["UPLOADED_UPLINK_DEST"], pipeline.files.uplinker,
app.config["REMOTE_SEQ_DIRECTORY"]],
)

# Optionally serve log files
if app.config["SERVE_LOGS"]:
api.add_resource(
Expand Down
1 change: 1 addition & 0 deletions src/fprime_gds/flask/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
SERVE_LOGS = os.environ.get("SERVE_LOGS", "YES") == "YES"
UPLOADED_UPLINK_DEST = uplink_dir
UPLOADS_DEFAULT_DEST = uplink_dir
REMOTE_SEQ_DIRECTORY = "/seq"
MAX_CONTENT_LENGTH = 32 * 1024 * 1024 # Max length of request is 32MiB

# Gds config setup
Expand Down
Loading