Skip to content

Commit

Permalink
Merge pull request #23 from thom311/th/flake8
Browse files Browse the repository at this point in the history
[th/flake8] add flake8 support (with `.flake8` config, github action and fix warnings)
  • Loading branch information
bn222 authored Sep 12, 2024
2 parents a65579f + a893496 commit ffe67d9
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 32 deletions.
21 changes: 21 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[flake8]
extend-ignore =
E203
E501
W291
extend-exclude =
*venv*/
filename =
*.py
*/bfb
*/console
*/cx_fwup
*/dpu-tools/dpu-tools
*/fwdefaults
*/fwup
*/fwversion
*/get_mode
*/listbf
*/pxeboot
*/reset
*/set_mode
6 changes: 6 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install black
python -m pip install flake8
python -m pip install -r requirements.txt
- name: Check code formatting with Black
run: |
black --version
black --check --diff .
- name: flake8
run: |
flake8 --version
flake8
3 changes: 2 additions & 1 deletion bfb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python3

import common_bf
import argparse
import requests
import time

import common_bf


def main():
parser = argparse.ArgumentParser(
Expand Down
7 changes: 4 additions & 3 deletions common_bf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from collections import namedtuple
import subprocess
import os
import sys
import shlex
import subprocess
import sys

from collections import namedtuple


def run(cmd: str, env: dict = os.environ.copy()):
Expand Down
3 changes: 2 additions & 1 deletion console
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3

import argparse
import os

import common_bf
import argparse


def main():
Expand Down
3 changes: 2 additions & 1 deletion cx_fwup
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import os, sys
import os
import sys


def main():
Expand Down
14 changes: 6 additions & 8 deletions dpu-tools/dpu-tools
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env python3

import os
import argparse
import tempfile
import shutil
import os
import re
import shlex
from collections import namedtuple
import shutil
import subprocess
import re
import tempfile

from collections import namedtuple


def run(cmd: str, env: dict = os.environ.copy()):
Expand Down Expand Up @@ -57,9 +58,6 @@ def find_bus_pci_address(address: str) -> str:

if match:
bus = match.group(1)
device = match.group(2)
function = match.group(3)

new_address = f"{bus}:00.0"
return new_address
else:
Expand Down
5 changes: 3 additions & 2 deletions fwdefaults
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3

import os, sys
import common_bf
import argparse
import os

import common_bf


def main():
Expand Down
5 changes: 3 additions & 2 deletions fwup
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python3

import sys
import argparse
import requests
import sys

import common_bf
import argparse


class RemoteAPI:
Expand Down
3 changes: 2 additions & 1 deletion fwversion
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3

import common_bf
import argparse

import common_bf


def main():
parser = argparse.ArgumentParser(description="Shows firmware version.")
Expand Down
4 changes: 3 additions & 1 deletion get_mode
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python3
import common_bf

import argparse

import common_bf


def main():
parser = argparse.ArgumentParser(description="Reads the current mode of the BF.")
Expand Down
1 change: 1 addition & 0 deletions listbf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3

import common_bf


Expand Down
19 changes: 11 additions & 8 deletions pxeboot
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#!/usr/bin/env python3

import argparse
import http.server
import io
import os
import paramiko
import pexpect
import requests
import shutil
import signal
import sys
from multiprocessing import Process
import threading
import pexpect
import paramiko
import time
import io

from multiprocessing import Process

import common_bf
import shutil
import http.server
import requests


install_entry = "Install OS"
Expand Down Expand Up @@ -507,7 +510,7 @@ def try_pxy_boot():

ping_exception = None
try:
candidates = list(f"172.31.100.{x}" for x in range(10, 21))
candidates = [f"172.31.100.{x}" for x in range(10, 21)]
response_ip = wait_any_ping(candidates, 180)
print(f"got response from {response_ip}")
except Exception as e:
Expand Down
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bcrypt
paramiko>=2.12.0
pyasn1
pynacl
requests
setuptools-rust
5 changes: 3 additions & 2 deletions reset
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3

import common_bf
import argparse

import common_bf


def main():
parser = argparse.ArgumentParser(description="Reboots the BF.")
Expand All @@ -16,7 +17,7 @@ def main():
help="Specify the id of the BF.",
)
args = parser.parse_args()
bf_pci = common_bf.find_bf_pci_addresses_or_quit(args.id)
common_bf.find_bf_pci_addresses_or_quit(args.id)
with open(f"/dev/rshim{args.id//2}/misc", "w") as f:
f.write("SW_RESET 1")

Expand Down
6 changes: 4 additions & 2 deletions set_mode
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python3
import common_bf
import os

import argparse
import os

import common_bf


def main():
Expand Down

0 comments on commit ffe67d9

Please sign in to comment.