Skip to content

Commit

Permalink
Merge branch 'master' into pythonw
Browse files Browse the repository at this point in the history
  • Loading branch information
timmo001 committed Jun 10, 2022
2 parents 2dddc0e + 469412d commit f229150
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 73 deletions.
2 changes: 1 addition & 1 deletion backend/systembridgebackend/_version.py
Expand Up @@ -7,5 +7,5 @@

from incremental import Version

__version__ = Version("systembridgebackend", 3, 1, 5, dev=0)
__version__ = Version("systembridgebackend", 3, 1, 6, dev=0)
__all__ = ["__version__"]
19 changes: 12 additions & 7 deletions backend/systembridgebackend/server/media.py
@@ -1,4 +1,6 @@
"""System Bridge: Server Handler - Media"""
from __future__ import annotations

import mimetypes
import os

Expand Down Expand Up @@ -39,21 +41,24 @@ def get_files(
path: str,
) -> list[dict]:
"""Get files from path"""
files = []
files_info = []
for filename in os.listdir(path):
files.append(
get_file(BASE_DIRECTORIES[base_path], os.path.join(path, filename))
)
file_info = get_file(BASE_DIRECTORIES[base_path], os.path.join(path, filename))
if file_info is not None:
files_info.append(file_info)

return files
return files_info


def get_file(
base_path: str,
filepath: str,
) -> dict:
) -> dict | None:
"""Get file from path"""
stat = os.stat(filepath)
try:
stat = os.stat(filepath)
except FileNotFoundError:
return None

mime_type = None
if os.path.isfile(filepath):
Expand Down
2 changes: 1 addition & 1 deletion cli/systembridgecli/_version.py
Expand Up @@ -7,5 +7,5 @@

from incremental import Version

__version__ = Version("systembridgecli", 3, 1, 5, dev=0)
__version__ = Version("systembridgecli", 3, 1, 6, dev=0)
__all__ = ["__version__"]
2 changes: 1 addition & 1 deletion connector/systembridgeconnector/_version.py
Expand Up @@ -7,5 +7,5 @@

from incremental import Version

__version__ = Version("systembridgeconnector", 3, 1, 5, dev=0)
__version__ = Version("systembridgeconnector", 3, 1, 6, dev=0)
__all__ = ["__version__"]
12 changes: 7 additions & 5 deletions connector/systembridgeconnector/models/battery.py
Expand Up @@ -3,6 +3,8 @@

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Extra, Field


Expand All @@ -14,8 +16,8 @@ class LastUpdated(BaseModel):
class Config:
extra = Extra.allow

is_charging: float
percentage: float
is_charging: Optional[float] = None
percentage: Optional[float] = None


class Battery(BaseModel):
Expand All @@ -26,6 +28,6 @@ class Battery(BaseModel):
class Config:
extra = Extra.allow

is_charging: bool
percentage: float
last_updated: LastUpdated = Field(..., description="Last updated")
is_charging: Optional[bool] = None
percentage: Optional[float] = None
last_updated: Optional[LastUpdated] = Field(None, description="Last updated")
22 changes: 12 additions & 10 deletions connector/systembridgeconnector/models/cpu.py
Expand Up @@ -3,6 +3,8 @@

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Extra, Field


Expand All @@ -27,15 +29,15 @@ class Config:
times_user: float
times_system: float
times_idle: float
times_interrupt: float
times_dpc: float
times_interrupt: Optional[float] = None
times_dpc: Optional[float] = None
times_percent_user: float
times_percent_system: float
times_percent_idle: float
times_percent_interrupt: float
times_percent_dpc: float
times_percent_interrupt: Optional[float] = None
times_percent_dpc: Optional[float] = None
usage: float
voltage: float
voltage: Optional[float] = None


class Cpu(BaseModel):
Expand All @@ -59,13 +61,13 @@ class Config:
times_user: float
times_system: float
times_idle: float
times_interrupt: float
times_dpc: float
times_interrupt: Optional[float] = None
times_dpc: Optional[float] = None
times_percent_user: float
times_percent_system: float
times_percent_idle: float
times_percent_interrupt: float
times_percent_dpc: float
times_percent_interrupt: Optional[float] = None
times_percent_dpc: Optional[float] = None
usage: float
voltage: float
voltage: Optional[float] = None
last_updated: LastUpdated = Field(..., description="Last updated")
10 changes: 6 additions & 4 deletions connector/systembridgeconnector/models/system.py
Expand Up @@ -3,6 +3,8 @@

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Field


Expand All @@ -21,8 +23,8 @@ class LastUpdated(BaseModel):
uptime: float
uuid: float
version: float
version_latest: float
version_newer_available: float
version_latest: Optional[float] = None
version_newer_available: Optional[float] = None


class System(BaseModel):
Expand All @@ -40,6 +42,6 @@ class System(BaseModel):
uptime: float
uuid: str
version: str
version_latest: str
version_newer_available: bool
version_latest: Optional[str] = None
version_newer_available: Optional[bool] = None
last_updated: LastUpdated = Field(..., description="Last updated")
2 changes: 1 addition & 1 deletion connector/systembridgeconnector/version.py
Expand Up @@ -70,7 +70,7 @@ async def check_version_3(self) -> str | None:
system = System(**response)
if (
system
and system.version
and system.version is not None
and parse_version(system.version) >= parse_version("3.0.0")
):
return system.version
Expand Down
2 changes: 1 addition & 1 deletion frontend/systembridgefrontend/_version.py
Expand Up @@ -7,5 +7,5 @@

from incremental import Version

__version__ = Version("systembridgefrontend", 3, 1, 5, dev=0)
__version__ = Version("systembridgefrontend", 3, 1, 6, dev=0)
__all__ = ["__version__"]
2 changes: 1 addition & 1 deletion gui/systembridgegui/_version.py
Expand Up @@ -7,5 +7,5 @@

from incremental import Version

__version__ = Version("systembridgegui", 3, 1, 5, dev=0)
__version__ = Version("systembridgegui", 3, 1, 6, dev=0)
__all__ = ["__version__"]
6 changes: 2 additions & 4 deletions schemas/data/battery.json
Expand Up @@ -22,10 +22,8 @@
},
"additionalProperties": {
"type": "number"
},
"required": ["is_charging", "percentage"]
}
}
},
"additionalProperties": {},
"required": ["is_charging", "percentage", "last_updated"]
"additionalProperties": {}
}
12 changes: 1 addition & 11 deletions schemas/data/cpu.json
Expand Up @@ -157,15 +157,10 @@
"times_user",
"times_system",
"times_idle",
"times_interrupt",
"times_dpc",
"times_percent_user",
"times_percent_system",
"times_percent_idle",
"times_percent_interrupt",
"times_percent_dpc",
"usage",
"voltage"
"usage"
]
}
},
Expand All @@ -186,15 +181,10 @@
"times_user",
"times_system",
"times_idle",
"times_interrupt",
"times_dpc",
"times_percent_user",
"times_percent_system",
"times_percent_idle",
"times_percent_interrupt",
"times_percent_dpc",
"usage",
"voltage",
"last_updated"
]
}
6 changes: 1 addition & 5 deletions schemas/data/system.json
Expand Up @@ -93,9 +93,7 @@
"platform_version",
"uptime",
"uuid",
"version",
"version_latest",
"version_newer_available"
"version"
]
}
},
Expand All @@ -111,8 +109,6 @@
"uptime",
"uuid",
"version",
"version_latest",
"version_newer_available",
"last_updated"
]
}
2 changes: 1 addition & 1 deletion shared/systembridgeshared/_version.py
Expand Up @@ -7,5 +7,5 @@

from incremental import Version

__version__ = Version("systembridgeshared", 3, 1, 5, dev=0)
__version__ = Version("systembridgeshared", 3, 1, 6, dev=0)
__all__ = ["__version__"]
12 changes: 7 additions & 5 deletions shared/systembridgeshared/models/battery.py
Expand Up @@ -3,6 +3,8 @@

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Extra, Field


Expand All @@ -14,8 +16,8 @@ class LastUpdated(BaseModel):
class Config:
extra = Extra.allow

is_charging: float
percentage: float
is_charging: Optional[float] = None
percentage: Optional[float] = None


class Battery(BaseModel):
Expand All @@ -26,6 +28,6 @@ class Battery(BaseModel):
class Config:
extra = Extra.allow

is_charging: bool
percentage: float
last_updated: LastUpdated = Field(..., description="Last updated")
is_charging: Optional[bool] = None
percentage: Optional[float] = None
last_updated: Optional[LastUpdated] = Field(None, description="Last updated")
22 changes: 12 additions & 10 deletions shared/systembridgeshared/models/cpu.py
Expand Up @@ -3,6 +3,8 @@

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Extra, Field


Expand All @@ -27,15 +29,15 @@ class Config:
times_user: float
times_system: float
times_idle: float
times_interrupt: float
times_dpc: float
times_interrupt: Optional[float] = None
times_dpc: Optional[float] = None
times_percent_user: float
times_percent_system: float
times_percent_idle: float
times_percent_interrupt: float
times_percent_dpc: float
times_percent_interrupt: Optional[float] = None
times_percent_dpc: Optional[float] = None
usage: float
voltage: float
voltage: Optional[float] = None


class Cpu(BaseModel):
Expand All @@ -59,13 +61,13 @@ class Config:
times_user: float
times_system: float
times_idle: float
times_interrupt: float
times_dpc: float
times_interrupt: Optional[float] = None
times_dpc: Optional[float] = None
times_percent_user: float
times_percent_system: float
times_percent_idle: float
times_percent_interrupt: float
times_percent_dpc: float
times_percent_interrupt: Optional[float] = None
times_percent_dpc: Optional[float] = None
usage: float
voltage: float
voltage: Optional[float] = None
last_updated: LastUpdated = Field(..., description="Last updated")
10 changes: 6 additions & 4 deletions shared/systembridgeshared/models/system.py
Expand Up @@ -3,6 +3,8 @@

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Field


Expand All @@ -21,8 +23,8 @@ class LastUpdated(BaseModel):
uptime: float
uuid: float
version: float
version_latest: float
version_newer_available: float
version_latest: Optional[float] = None
version_newer_available: Optional[float] = None


class System(BaseModel):
Expand All @@ -40,6 +42,6 @@ class System(BaseModel):
uptime: float
uuid: str
version: str
version_latest: str
version_newer_available: bool
version_latest: Optional[str] = None
version_newer_available: Optional[bool] = None
last_updated: LastUpdated = Field(..., description="Last updated")
2 changes: 1 addition & 1 deletion windowssensors/systembridgewindowssensors/_version.py
Expand Up @@ -7,5 +7,5 @@

from incremental import Version

__version__ = Version("systembridgewindowssensors", 3, 1, 5, dev=0)
__version__ = Version("systembridgewindowssensors", 3, 1, 6, dev=0)
__all__ = ["__version__"]

0 comments on commit f229150

Please sign in to comment.