From 24a5ddd49f926fcc3a275697fea9940b510b2eea Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Tue, 26 Nov 2024 15:53:38 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20chore(up+):=20finished=20primary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/functions.py | 2 +- snigdhaos-kernel-switcher.py | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/libs/functions.py b/libs/functions.py index fdd2a86..df977c7 100644 --- a/libs/functions.py +++ b/libs/functions.py @@ -485,7 +485,7 @@ def parse_archive_html(response, linux_kernel): if len(files) > 0: if "-x86_64" in files[0]: version = files[0].split("-x86_64")[0] - file_format = files[04].split("-x86_64")[1] + file_format = files[1].split("-x86_64")[1] url = ("/packages/l/%s" % archlinux_mirror_archive_url + "/%s" % linux_kernel + "/%s" % files[0]) #URL Struct unknown to me! if ".sig" not in file_format: if len(line.rstrip().split(" ")) > 0: diff --git a/snigdhaos-kernel-switcher.py b/snigdhaos-kernel-switcher.py index 59ceb7a..13b462d 100644 --- a/snigdhaos-kernel-switcher.py +++ b/snigdhaos-kernel-switcher.py @@ -44,10 +44,31 @@ class Main(Gtk.Application): if os.path.exists(progress_lock_file): os.remove(progress_lock_file) - def snigdhal_handler(sig, frame): - Gtk.main_quit(0) +def snigdhal_handler(sig, frame): + Gtk.main_quit(0) - # if __name__ == "__main__": - # try: - # except Exception as e: - # return False \ No newline at end of file +if __name__ == "__main__": + try: + if not fn.os.path.isfile(lock_file): + with open(pid_file, "w") as f: + f.write(str(fn.os.getpid())) + app = Main() + app.run(None) + else: + md = Gtk.MessageDialog(parent=Main(), flags=0,message_type=Gtk.MessageType.INFO,buttons=Gtk.ButtonsType.YES_NO,text="%s Lock File Found!" % app_name) + md.format_secondary_markup("A %s lock file Found!\nAnother substance of %s is running!\nClick 'Yes' to remove the lockfile and restart the app." %(lock_file, app_name)) + result = md.run() + md.destroy() + if result in (Gtk.ResponseType.OK, Gtk.ResponseType.YES): + pid = "" + if fn.os.path.exists(pid_file): + with open(pid_file, "r") as f: + i = f.read() + pid = i.rstrip().lstrip() + else: + fn.os.unlink(lock_file) + fn.sys.exit(1) + else: + fn.sys.exit(1) + except Exception as e: + print("Error Occured in __main__") \ No newline at end of file