remove paragraphs to make the code more clean
This commit is contained in:
@@ -67,7 +67,6 @@ class KlipperbackupExtension(BaseExtension):
|
|||||||
crontab_content = subprocess.check_output(["crontab", "-l"], stderr=subprocess.DEVNULL, text=True)
|
crontab_content = subprocess.check_output(["crontab", "-l"], stderr=subprocess.DEVNULL, text=True)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for line in crontab_content.splitlines():
|
for line in crontab_content.splitlines():
|
||||||
if entry in line:
|
if entry in line:
|
||||||
return True
|
return True
|
||||||
@@ -81,14 +80,11 @@ class KlipperbackupExtension(BaseExtension):
|
|||||||
def remove_moonraker_entry():
|
def remove_moonraker_entry():
|
||||||
original_file_path = os.path.join(str(MOONRAKER_DIR), 'printer_data', 'config', 'moonraker.conf')
|
original_file_path = os.path.join(str(MOONRAKER_DIR), 'printer_data', 'config', 'moonraker.conf')
|
||||||
comparison_file_path = os.path.join(str(KLIPPERBACKUP_DIR), 'install-files', 'moonraker.conf')
|
comparison_file_path = os.path.join(str(KLIPPERBACKUP_DIR), 'install-files', 'moonraker.conf')
|
||||||
|
|
||||||
if not os.path.exists(original_file_path) or not os.path.exists(comparison_file_path):
|
if not os.path.exists(original_file_path) or not os.path.exists(comparison_file_path):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
with open(original_file_path, 'r') as original_file, open(comparison_file_path, 'r') as comparison_file:
|
with open(original_file_path, 'r') as original_file, open(comparison_file_path, 'r') as comparison_file:
|
||||||
original_content = original_file.read()
|
original_content = original_file.read()
|
||||||
comparison_content = comparison_file.read().strip()
|
comparison_content = comparison_file.read().strip()
|
||||||
|
|
||||||
if comparison_content in original_content:
|
if comparison_content in original_content:
|
||||||
modified_content = original_content.replace(comparison_content, '')
|
modified_content = original_content.replace(comparison_content, '')
|
||||||
with open(original_file_path, 'w') as original_file:
|
with open(original_file_path, 'w') as original_file:
|
||||||
|
|||||||
Reference in New Issue
Block a user