Skip to content
Open
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
9 changes: 8 additions & 1 deletion .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ jobs:
run: |
./scripts/test.sh format

python-lint:
name: Lint Python code with ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3

python-tests:
name: Python ${{ matrix.python-version }} tests
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -77,7 +84,7 @@ jobs:

deploy:
name: Generate and push C headers
needs: [format, python-tests, node-tests]
needs: [format, python-lint, python-tests, node-tests]
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/master'
env:
Expand Down
10 changes: 5 additions & 5 deletions mavgenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,25 @@ def generateHeaders(self):
return

# Generate headers
opts = mavgen.Opts(self.out_value.get(), wire_protocol=self.protocol_value.get(), language=self.language_value.get(), validate=self.validate_value.get(), error_limit=error_limit, strict_units=self.strict_units_value.get());
opts = mavgen.Opts(self.out_value.get(), wire_protocol=self.protocol_value.get(), language=self.language_value.get(), validate=self.validate_value.get(), error_limit=error_limit, strict_units=self.strict_units_value.get())
args = [self.xml_value.get()]
try:
mavgen.mavgen(opts,args)
tkinter.messagebox.showinfo('Successfully Generated Headers', 'Headers generated successfully.')

except Exception as ex:
exStr = formatErrorMessage(str(ex));
exStr = formatErrorMessage(str(ex))
tkinter.messagebox.showerror('Error Generating Headers','{0!s}'.format(exStr))
return

"""\
Format the mavgen exceptions by removing 'ERROR: '.
"""
def formatErrorMessage(message):
reObj = re.compile(r'^(ERROR):\s+',re.M);
matches = re.findall(reObj, message);
reObj = re.compile(r'^(ERROR):\s+',re.M)
matches = re.findall(reObj, message)
prefix = ("An error occurred in mavgen:" if len(matches) == 1 else "Errors occurred in mavgen:\n")
message = re.sub(reObj, '\n', message);
message = re.sub(reObj, '\n', message)

return prefix + message

Expand Down
12 changes: 12 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
lint.exclude = [ "pymavlink" ]
lint.extend-ignore = [
"E711", # none-comparison
"E712", # true-false-comparison
"E713", # not-in-test
"E714", # not-is-test
"F401", # unused-import
"F403", # undefined-local-with-import-star
"F405", # undefined-local-with-import-star-usage
"F541", # f-string-missing-placeholders
"F841", # unused-variable
]