mirror of
				https://github.com/netinvent/npbackup.git
				synced 2025-11-04 18:27:20 +08:00 
			
		
		
		
	Reformat files with black
This commit is contained in:
		
							parent
							
								
									4f06814a1e
								
							
						
					
					
						commit
						0267d5ba10
					
				
					 4 changed files with 30 additions and 15 deletions
				
			
		| 
						 | 
				
			
			@ -193,21 +193,31 @@ def evaluate_variables(config_dict: dict, value: str) -> str:
 | 
			
		|||
    """
 | 
			
		||||
 | 
			
		||||
    # We need to make a loop to catch all nested variables
 | 
			
		||||
    while "${MACHINE_ID}" in value or "${MACHINE_GROUP}" in value \
 | 
			
		||||
        or "${BACKUP_JOB}" in value or "${HOSTNAME}" in value:
 | 
			
		||||
    while (
 | 
			
		||||
        "${MACHINE_ID}" in value
 | 
			
		||||
        or "${MACHINE_GROUP}" in value
 | 
			
		||||
        or "${BACKUP_JOB}" in value
 | 
			
		||||
        or "${HOSTNAME}" in value
 | 
			
		||||
    ):
 | 
			
		||||
        value = value.replace("${HOSTNAME}", platform.node())
 | 
			
		||||
        try:
 | 
			
		||||
            value = value.replace("${MACHINE_ID}", config_dict["identity"]["machine_id"])
 | 
			
		||||
            value = value.replace(
 | 
			
		||||
                "${MACHINE_ID}", config_dict["identity"]["machine_id"]
 | 
			
		||||
            )
 | 
			
		||||
        except KeyError:
 | 
			
		||||
            pass
 | 
			
		||||
        try:
 | 
			
		||||
            value = value.replace("${MACHINE_GROUP}", config_dict["identity"]["machine_group"])
 | 
			
		||||
            value = value.replace(
 | 
			
		||||
                "${MACHINE_GROUP}", config_dict["identity"]["machine_group"]
 | 
			
		||||
            )
 | 
			
		||||
        except KeyError:
 | 
			
		||||
            pass
 | 
			
		||||
        try:
 | 
			
		||||
            value = value.replace("${BACKUP_JOB}", config_dict["prometheus"]["backup_job"])
 | 
			
		||||
            value = value.replace(
 | 
			
		||||
                "${BACKUP_JOB}", config_dict["prometheus"]["backup_job"]
 | 
			
		||||
            )
 | 
			
		||||
        except KeyError:
 | 
			
		||||
            pass   
 | 
			
		||||
            pass
 | 
			
		||||
    return value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -265,9 +265,9 @@ class ResticRunner:
 | 
			
		|||
            binary = "restic.exe"
 | 
			
		||||
            probe_paths = self.binary_search_paths + [
 | 
			
		||||
                "",
 | 
			
		||||
                os.path.join(os.environ.get("windir", ''), "SYSTEM32"),
 | 
			
		||||
                os.environ.get("windir", ''),
 | 
			
		||||
                os.path.join(os.environ.get("ProgramFiles", ''), "restic"),
 | 
			
		||||
                os.path.join(os.environ.get("windir", ""), "SYSTEM32"),
 | 
			
		||||
                os.environ.get("windir", ""),
 | 
			
		||||
                os.path.join(os.environ.get("ProgramFiles", ""), "restic"),
 | 
			
		||||
            ]
 | 
			
		||||
        else:
 | 
			
		||||
            binary = "restic"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,11 +67,11 @@ async def current_version(request: Request, auth=Depends(get_current_username)):
 | 
			
		|||
    data = {
 | 
			
		||||
        "action": "check_version",
 | 
			
		||||
        "ip": request.client.host,
 | 
			
		||||
        "auto_upgrade_host_identity": '',
 | 
			
		||||
        "installed_version": '',
 | 
			
		||||
        "group": '',
 | 
			
		||||
        "platform": '',
 | 
			
		||||
        "arch": '',
 | 
			
		||||
        "auto_upgrade_host_identity": "",
 | 
			
		||||
        "installed_version": "",
 | 
			
		||||
        "group": "",
 | 
			
		||||
        "platform": "",
 | 
			
		||||
        "arch": "",
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,12 @@ def is_enabled() -> bool:
 | 
			
		|||
 | 
			
		||||
def store_host_info(destination: str, host_id: dict) -> None:
 | 
			
		||||
    try:
 | 
			
		||||
        data = datetime.utcnow().isoformat() + ',' + ",".join([value if value else '' for value in host_id.values()]) + "\n"
 | 
			
		||||
        data = (
 | 
			
		||||
            datetime.utcnow().isoformat()
 | 
			
		||||
            + ","
 | 
			
		||||
            + ",".join([value if value else "" for value in host_id.values()])
 | 
			
		||||
            + "\n"
 | 
			
		||||
        )
 | 
			
		||||
        with open(destination, "a", encoding="utf-8") as fpw:
 | 
			
		||||
            fpw.write(data)
 | 
			
		||||
    except OSError:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue