mirror of
https://github.com/Derisis13/barusu.git
synced 2025-12-07 03:52:48 +01:00
Added checking for dconf and apt-get to avoid confusion and frustration
Also restoring now provides information about the age of your backup
This commit is contained in:
27
main.py
27
main.py
@@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import distutils.spawn
|
||||||
import getopt
|
import getopt
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -47,6 +48,13 @@ def restore():
|
|||||||
packagelist.close()
|
packagelist.close()
|
||||||
exit(2)
|
exit(2)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
|
f = open(".backupdone", "r")
|
||||||
|
date = f.read(10)
|
||||||
|
f.close()
|
||||||
|
except FileNotFoundError:
|
||||||
|
date = "Unknown"
|
||||||
|
print("Restoring programs and settings from ", date)
|
||||||
subprocess.run(["dpkg", "--set-selections"], stdin=packagelist)
|
subprocess.run(["dpkg", "--set-selections"], stdin=packagelist)
|
||||||
subprocess.run(["apt-get", "dselect-upgrade"])
|
subprocess.run(["apt-get", "dselect-upgrade"])
|
||||||
packagelist.close()
|
packagelist.close()
|
||||||
@@ -67,6 +75,18 @@ def restore():
|
|||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
|
def check_progs():
|
||||||
|
apt = distutils.spawn.find_executable("apt-get")
|
||||||
|
dconf = distutils.spawn.find_executable("dconf")
|
||||||
|
if apt == False:
|
||||||
|
print("Your system is not using apt as a package manager! Barusu uses apt to back up your packages. Barusu IS "
|
||||||
|
"NOT designed to work with other packaging tools.")
|
||||||
|
if dconf = False:
|
||||||
|
print("Your system is not using dconf! Barusu uses dconf to back up your settings. Barusu IS "
|
||||||
|
"NOT designed to work with other settings manager.")
|
||||||
|
return apt, dconf
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
backupdir = os.path.expanduser("~/.backup")
|
backupdir = os.path.expanduser("~/.backup")
|
||||||
try:
|
try:
|
||||||
@@ -76,7 +96,7 @@ if __name__ == '__main__':
|
|||||||
exit(1)
|
exit(1)
|
||||||
for option, value in options:
|
for option, value in options:
|
||||||
if option in ("-h", "help"):
|
if option in ("-h", "help"):
|
||||||
print("usage: barusu [opts]\n\
|
print("usage: backup_assistant [opts]\n\
|
||||||
Options:\n\
|
Options:\n\
|
||||||
\t-h --help: show this\n\
|
\t-h --help: show this\n\
|
||||||
\t-d --backup-dir [directory]: set the directory for the backup/restoration (default is ~/.backups)\n\
|
\t-d --backup-dir [directory]: set the directory for the backup/restoration (default is ~/.backups)\n\
|
||||||
@@ -88,6 +108,11 @@ if __name__ == '__main__':
|
|||||||
restore()
|
restore()
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
apt, dconf = check_progs()
|
||||||
|
if apt and dconf:
|
||||||
|
print("System incompatibilities, exitting...")
|
||||||
|
exit(3)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.chdir(backupdir)
|
os.chdir(backupdir)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
|||||||
Reference in New Issue
Block a user