summarylogtreecommitdiffstats
path: root/fixes.patch
blob: 89b0ada039ada0107a1c501cb6f3d9c04178b882 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
diff --git a/multibootusb b/multibootusb
index ae831e0..5f8db76 100644
--- a/multibootusb
+++ b/multibootusb
@@ -102,7 +102,7 @@ Example for installing multiple distros without user intervention:
 
     Windows:
         python3 multibootusb -c -y -i ../../favourite.iso,../../other-distro.iso -t G:
-        
+
 Example for writing ISO image to target USB disk (will destroy data on USB disk):
 
     Linux:
@@ -184,25 +184,33 @@ if __name__ == '__main__':
             sys.exit()
             '''
 
+if platform.system() == 'Linux':
+    if os.getuid() != 0:
+        exit("You need to have root privileges to run this application."
+             "\nPlease try again using 'sudo'. Exiting.")
+elif platform.system() == 'Windows':
+    if ctypes.windll.shell32.IsUserAnAdmin() != 1:
+        exit("You need to have admin privileges to run this application."
+             "\nPlease open command window with admin rights. Exiting.")
+
 if config.debug is True:
     from scripts.debug import colors
     log(colors.HEADER + "=== DEBUG ENABLED ===")
 
 
 if gui is False:
-    check_admin()
-    if uninstall is True and config.usb_disk is not '':
+    if uninstall is True and config.usb_disk is not None:
         cli_uninstall_distro()
-    elif uninstall is True and config.usb_disk is '':
+    elif uninstall is True and config.usb_disk is None:
         log('\nYou must provide \'-t\' option to point to your USB disk for uninstalling a distro.\n'
             'See the usage example below.')
         usage()
-    elif config.image_path is '' and config.usb_disk is '':
+    elif config.image_path is None and config.usb_disk is None:
         log('\nNo option provided. See the usage below.')
         usage()
-    elif config.cli_syslinux is True and config.usb_disk is not '':
+    elif config.cli_syslinux is True and config.usb_disk is not None:
         cli_install_syslinux()
-    elif config.image_path is '' or config.usb_disk is '':
+    elif config.image_path is None or config.usb_disk is None:
         log('\nOptions \'-i\' and \'-t\' must be supplied together. See the usage below.')
         usage()
     elif config.cli_dd is True:
diff --git a/scripts/gen.py b/scripts/gen.py
index f29dc6e..2f2218d 100644
--- a/scripts/gen.py
+++ b/scripts/gen.py
@@ -137,7 +137,8 @@ def mbusb_log_file():
     if platform.system() == "Linux":
         # home_dir = os.path.expanduser('~')
         # log_file = os.path.join(home_dir, "multibootusb.log")
-        log_file = os.path.join(tempfile.gettempdir(), "multibootusb.log")
+        # log_file = os.path.join(tempfile.gettempdir(), "multibootusb.log")
+        log_file = "/var/log/multibootusb.log"
     elif platform.system() == "Windows":
         # log_file = os.path.join(tempfile.gettempdir(), "multibootusb", "multibootusb.log")
         log_file = os.path.join("multibootusb.log")
@@ -241,7 +242,7 @@ def copy_mbusb_dir_usb(usb_disk):
     if not os.path.exists(os.path.join(usb_mount_path, 'multibootusb', 'grub', 'core-msdos.img')):
         shutil.copy(resource_path(os.path.join('data', 'multibootusb', 'grub', 'core-msdos.img')),
                     os.path.join(usb_mount_path, 'multibootusb', 'grub', 'core-msdos.img'))
-    
+
     if not os.path.exists(os.path.join(usb_mount_path, 'multibootusb', 'grub', 'x86_64-efi')):
         log("New EFI modules does not exist. Copying now.")
         shutil.copytree(resource_path(os.path.join('data', 'multibootusb', 'grub', 'x86_64-efi')),
@@ -443,7 +444,7 @@ class MemoryCheck():
     Cross platform way to checks memory of a given system. Works on Linux and Windows.
     psutil is a good option to get memory info. But version 5.0 and only will work.
     Source: https://doeidoei.wordpress.com/2009/03/22/python-tip-3-checking-available-ram-with-python/
-    Call this class like this: 
+    Call this class like this:
     mem_info = memoryCheck()
     print(mem_info.value)
     """
@@ -500,7 +501,7 @@ def wmi_get_drive_info(usb_disk):
             if disk.Caption == usb_disk:
                 return (partition, disk)
     raise RuntimeError('Failed to obtain drive information ' + usb_disk)
-    
+
 def get_physical_disk_number(usb_disk):
     """
     Get the physical disk number as detected ny Windows.
diff --git a/scripts/mbusb_gui.py b/scripts/mbusb_gui.py
index ba87a30..440aa1f 100644
--- a/scripts/mbusb_gui.py
+++ b/scripts/mbusb_gui.py
@@ -753,9 +753,6 @@ class GuiInstallProgress(QtCore.QThread):
 	def __init__(self):
 		QtCore.QThread.__init__(self)
 
-	def __del__(self):
-		self.wait()
-
 	def run(self):
 		install_dir = os.path.join(config.usb_mount, "multibootusb", iso_basename(config.image_path))
 		self.thread = GenericThread(install_progress)
@@ -797,9 +794,6 @@ class GuiUninstallProgress(QtCore.QThread):
 		QtCore.QThread.__init__(self)
 		self.thread = GenericThread(uninstall_progress)
 
-	def __del__(self):
-		self.wait()
-
 	def run(self):
 		self.thread.start()
 
@@ -840,9 +834,6 @@ class DD_Progress(QtCore.QThread):
 		elif platform.system() == 'Windows':
 			self.thread = GenericThread(dd_win)
 
-	def __del__(self):
-		self.wait()
-
 	def run(self):
 		self.thread.start()
 		while self.thread.isRunning():
@@ -870,9 +861,6 @@ class GenericThread(QtCore.QThread):
 		self.args = args
 		self.kwargs = kwargs
 
-	def __del__(self):
-		self.wait()
-
 	def run(self):
 		self.function(*self.args, **self.kwargs)
 		return