Replace os.path.exists calls by os.path.isfile

merge-requests/64/head
Huluti 2016-12-04 20:40:34 +01:00
parent 2031dc5be9
commit 96072653de
1 changed files with 5 additions and 5 deletions

View File

@ -23,7 +23,7 @@ class ManjaroHello(Gtk.Window):
self.preferences = self.get_preferences() self.preferences = self.get_preferences()
if not self.preferences: if not self.preferences:
self.preferences = {"autostart": os.path.exists(self.autostart_path)} self.preferences = {"autostart": os.path.isfile(self.autostart_path)}
self.save_preferences() self.save_preferences()
self.infos = get_infos() self.infos = get_infos()
@ -60,13 +60,13 @@ class ManjaroHello(Gtk.Window):
self.window.show() self.window.show()
def change_autostart(self, state): def change_autostart(self, state):
if state and not os.path.exists(self.autostart_path): if state and not os.path.isfile(self.autostart_path):
try: try:
shutil.copyfile("manjaro-hello.desktop", self.autostart_path) shutil.copyfile("manjaro-hello.desktop", self.autostart_path)
self.preferences["autostart"] = True self.preferences["autostart"] = True
except OSError as e: except OSError as e:
print(e) print(e)
elif not state and os.path.exists(self.autostart_path): elif not state and os.path.isfile(self.autostart_path):
try: try:
os.remove(self.autostart_path) os.remove(self.autostart_path)
self.preferences["autostart"] = False self.preferences["autostart"] = False
@ -90,7 +90,7 @@ class ManjaroHello(Gtk.Window):
def read_data(self, name): def read_data(self, name):
filename = "data/{}/{}".format(self.language, name) filename = "data/{}/{}".format(self.language, name)
if not os.path.exists(filename): if not os.path.isfile(filename):
filename = "data/{}/{}".format(self.default_language, name) filename = "data/{}/{}".format(self.default_language, name)
try: try:
@ -131,7 +131,7 @@ def get_infos():
infos["codename"] = lsb.get("CODENAME", 0) infos["codename"] = lsb.get("CODENAME", 0)
infos["release"] = lsb.get("RELEASE", 0) infos["release"] = lsb.get("RELEASE", 0)
infos["arch"] = "64-bit" if os.uname()[4] else "32-bit" infos["arch"] = "64-bit" if os.uname()[4] else "32-bit"
infos["live"] = os.path.exists("/bootmnt/manjaro") or os.path.exists("/run/miso/bootmnt/manjaro") infos["live"] = os.path.isfile("/bootmnt/manjaro") or os.path.isfile("/run/miso/bootmnt/manjaro")
return infos return infos