mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-10 06:54:54 +08:00
Reformat files with black
This commit is contained in:
parent
88c057432f
commit
34bb5eb46b
6 changed files with 30 additions and 20 deletions
|
@ -554,7 +554,6 @@ class NPBackupRunner:
|
|||
|
||||
@exec_timer
|
||||
def raw(self, command: str) -> bool:
|
||||
|
||||
logger.info("Running raw command: {}".format(command))
|
||||
result = self.restic_runner.raw(command=command)
|
||||
return result
|
||||
|
|
|
@ -472,7 +472,7 @@ def config_gui(config_dict: dict, config_file: str):
|
|||
if event in (sg.WIN_CLOSED, "cancel"):
|
||||
break
|
||||
if event == "accept":
|
||||
if not values['repo---password']:
|
||||
if not values["repo---password"]:
|
||||
sg.PopupError(_t("config_gui.repo_password_cannot_be_empty"))
|
||||
continue
|
||||
config_dict = update_config_dict(values, config_dict)
|
||||
|
|
|
@ -241,17 +241,9 @@ class ResticRunner:
|
|||
return True, output
|
||||
# TEMP-FIX-4155-END
|
||||
self.last_command_status = False
|
||||
|
||||
|
||||
# From here, we assume that we have errors
|
||||
# Before going back to errors, let's analyze current output
|
||||
|
||||
# Cannot connect to repo (port ?)
|
||||
#if re.match("Fatal: unable to open config file: Head .*: dial tcp .*: connect .*", output):
|
||||
# logger.error("Cannot connect to repo.")
|
||||
|
||||
#if re.match("Is there a repository at the following location\?", output):
|
||||
# We did achieve to get to the repo
|
||||
|
||||
# We'll log them unless we tried to know if the repo is initialized
|
||||
if not errors_allowed and output:
|
||||
logger.error(output)
|
||||
return False, output
|
||||
|
|
|
@ -53,7 +53,6 @@ logger = logger_get_logger()
|
|||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
|
||||
server.run("upgrade_server.api:app", **server_args)
|
||||
except KeyboardInterrupt as exc:
|
||||
logger.error("Program interrupted by keyoard: {}".format(exc))
|
||||
|
|
|
@ -80,21 +80,41 @@ async def current_version(auth=Depends(get_current_username)):
|
|||
|
||||
|
||||
@app.get("/upgrades/{platform}/{arch}", response_model=FileSend, status_code=200)
|
||||
@app.get("/upgrades/{platform}/{arch}/{host_identity}", response_model=FileSend, status_code=200)
|
||||
@app.get("/upgrades/{platform}/{arch}/{host_identity}/{installed_version}", response_model=FileSend, status_code=200)
|
||||
@app.get("/upgrades/{platform}/{arch}/{host_identity}/{installed_version}/{group}", response_model=FileSend, status_code=200)
|
||||
async def upgrades(request: Request, platform: Platform, arch: Arch, host_identity: str = None, installed_version: str = None, group: str = None, auth=Depends(get_current_username)):
|
||||
@app.get(
|
||||
"/upgrades/{platform}/{arch}/{host_identity}",
|
||||
response_model=FileSend,
|
||||
status_code=200,
|
||||
)
|
||||
@app.get(
|
||||
"/upgrades/{platform}/{arch}/{host_identity}/{installed_version}",
|
||||
response_model=FileSend,
|
||||
status_code=200,
|
||||
)
|
||||
@app.get(
|
||||
"/upgrades/{platform}/{arch}/{host_identity}/{installed_version}/{group}",
|
||||
response_model=FileSend,
|
||||
status_code=200,
|
||||
)
|
||||
async def upgrades(
|
||||
request: Request,
|
||||
platform: Platform,
|
||||
arch: Arch,
|
||||
host_identity: str = None,
|
||||
installed_version: str = None,
|
||||
group: str = None,
|
||||
auth=Depends(get_current_username),
|
||||
):
|
||||
data = {
|
||||
"ip": request.client.host,
|
||||
"host_identity": host_identity,
|
||||
"installed_version": installed_version,
|
||||
"group": group,
|
||||
"platform": platform.value,
|
||||
"arch": arch.value
|
||||
"arch": arch.value,
|
||||
}
|
||||
|
||||
try:
|
||||
crud.store_host_info(config_dict['upgrades']['statistics_file'], host_id = data)
|
||||
crud.store_host_info(config_dict["upgrades"]["statistics_file"], host_id=data)
|
||||
except KeyError:
|
||||
logger.error("No statistics file set.")
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ def is_enabled() -> bool:
|
|||
def store_host_info(destination: str, host_id: dict) -> None:
|
||||
try:
|
||||
data = ",".join(host_id.values()) + "\n"
|
||||
with open(destination, 'a', encoding='utf-8') as fpw:
|
||||
with open(destination, "a", encoding="utf-8") as fpw:
|
||||
fpw.write(data)
|
||||
except OSError:
|
||||
logger.error("Cannot write statistics file")
|
||||
|
|
Loading…
Add table
Reference in a new issue