qpdfview: fix: check file existence before operation
This commit is contained in:
parent
a7be3b1f49
commit
ceef4b03b0
1 changed files with 12 additions and 2 deletions
|
@ -10,9 +10,18 @@ import shutil
|
||||||
# =======================================================================================
|
# =======================================================================================
|
||||||
|
|
||||||
QPDFVIEW_CONFIGDIR = os.path.expanduser("~/.config/qpdfview/")
|
QPDFVIEW_CONFIGDIR = os.path.expanduser("~/.config/qpdfview/")
|
||||||
|
if not os.path.exists(QPDFVIEW_CONFIGDIR):
|
||||||
|
print("qpdfview config directory not found.")
|
||||||
|
print("Install qpdfview first and rerun this script.")
|
||||||
|
print("Exiting...")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
# =======================================================================================
|
||||||
|
|
||||||
QPDFVIEW_CONFIG_CONFIG = QPDFVIEW_CONFIGDIR + "qpdfview.conf"
|
QPDFVIEW_CONFIG_CONFIG = QPDFVIEW_CONFIGDIR + "qpdfview.conf"
|
||||||
print(f"{QPDFVIEW_CONFIG_CONFIG=}")
|
print(f"{QPDFVIEW_CONFIG_CONFIG=}")
|
||||||
|
|
||||||
|
if os.path.exists(QPDFVIEW_CONFIG_CONFIG):
|
||||||
shutil.copyfile(QPDFVIEW_CONFIG_CONFIG, QPDFVIEW_CONFIG_CONFIG + ".orig")
|
shutil.copyfile(QPDFVIEW_CONFIG_CONFIG, QPDFVIEW_CONFIG_CONFIG + ".orig")
|
||||||
|
|
||||||
config = configparser.RawConfigParser()
|
config = configparser.RawConfigParser()
|
||||||
|
@ -42,6 +51,7 @@ with open(QPDFVIEW_CONFIG_CONFIG, "w") as file:
|
||||||
|
|
||||||
QPDFVIEW_CONFIG_SHORTCUTS = QPDFVIEW_CONFIGDIR + "shortcuts.conf"
|
QPDFVIEW_CONFIG_SHORTCUTS = QPDFVIEW_CONFIGDIR + "shortcuts.conf"
|
||||||
|
|
||||||
|
if os.path.exists(QPDFVIEW_CONFIG_SHORTCUTS):
|
||||||
shutil.copyfile(QPDFVIEW_CONFIG_SHORTCUTS, QPDFVIEW_CONFIG_SHORTCUTS + ".orig")
|
shutil.copyfile(QPDFVIEW_CONFIG_SHORTCUTS, QPDFVIEW_CONFIG_SHORTCUTS + ".orig")
|
||||||
|
|
||||||
config = configparser.RawConfigParser()
|
config = configparser.RawConfigParser()
|
||||||
|
|
Loading…
Reference in a new issue