Skip to content

Small Fixes - Fix Default Camera Image#28

Open
jamesstocktonj1 wants to merge 4 commits intomasterfrom
small-fixes
Open

Small Fixes - Fix Default Camera Image#28
jamesstocktonj1 wants to merge 4 commits intomasterfrom
small-fixes

Conversation

@jamesstocktonj1
Copy link
Collaborator

Change website to get image from path /file/image.jpg (moved from /static/image.jpg). The image returned will be the first one available in the following order:

  • Camera Image (Deleted on Start)
  • Corner Image (USB)
  • Team Image (Uploaded)
  • Generic Corner Image (Arena USB Exists)
  • Teddy Image

app/config.py Outdated
Path("static/image.jpg"),
arena_usb_path / "Corner.jpg",
Path('usercode/editable/team_logo.jpg'),
Path('/home/pi/game_logo.jpg'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Teddy and game logo are the same thing

teamname_file: Path = Path("/home/pi/teamname.txt")
zone: bool = False

"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to follow PEP8 (the python style guide in this). We could and should check this with CI but don't yet: https://peps.python.org/pep-0008/#block-comments

From PEP8 multiline blockcomments in python

are indented to the same level as that code. Each line of a block comment starts with a # and a single space (unless it is indented text inside the comment).

Paragraphs inside a block comment are separated by a line containing a single #.

I think the logic of this is that declaring strings in the middle of your code can sometimes do things see __doc__ in https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy

We really should do this in CI shouldn't we

return

def _get_team_specifics(self):
def _get_team_image(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a better name than _get_team_specifics maybe _get_team_image_path would be an even better name?


Only makes sense to run this if we are on a brain
Teamname is set per brain before shipping and allows unique graphics
for ID'ing teams in the arena.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this doc string is no longer 100% accurate?


teamname_jpg = self.teamname_file.read_text().strip() + '.jpg'

self.camera_image_files[1] = Path(teamname_jpg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To a person reading only this function 1 is a bit of a magic number. Maybe a comment here to explain where this came from would be useful?

"""
os.remove(cameraFile)
response = client.get("/files/image.jpg")
assert response.status_code == 200 No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to spin sheep out into seperate repo and commit changes

os.remove(stimulus_path)

def test_get_image(client):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra new line not needed by PEP8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants