Skip to content

Commit

Permalink
Add missing serial numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jul 15, 2023
1 parent 3a9bd65 commit 0156d39
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 3.1.1 (2023-07-15)

- Updated logic to save missing serial numbers.

## 3.1 (2023-07-14)

- Use serial numbers as another way to identify computers.
Expand Down
8 changes: 8 additions & 0 deletions mine/models/computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,31 @@ def match(self, partial: str):
def get_current(self):
"""Get the current computer's information."""
this = Computer(None)
log.debug(f"Matching: {this.hostname=} {this.address=} {this.serial=}")

# Search for a matching hostname
for other in self:
if this.hostname == other.hostname:
log.debug(f"Matched via hostname: {other}")
other.address = this.address
if this.serial:
other.serial = this.serial
return other

# Else, search for a matching serial
for other in self:
if this.serial and this.serial == other.serial:
log.debug(f"Matched via serial: {other}")
other.hostname = this.hostname
return other

# Else, search for a matching address
for other in self:
if this.address == other.address:
log.debug(f"Matched via address: {other}")
other.hostname = this.hostname
if this.serial:
other.serial = this.serial
return other

# Else, this is a new computer
Expand Down

0 comments on commit 0156d39

Please sign in to comment.