Python Cross-system Compatibility

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
import os
import platform
import re
import subprocess

folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Image")
if not os.path.exists(folder):
os.mkdir(folder)

sys_platform = platform.system()
if (sys_platform == "Windows"):
subprocess.call(r"start "+ folder,shell=True)

elif (sys_platform == "Linux"):
sys_information = subprocess.getstatusoutput("lsb_release -a")
sys_distributor=re.search("(?<=Distributor\sID:\\t)\w+",system_info[1],re.I)

if (system_dis.group()=='LinuxMint'):
subprocess.call("caja " + folder,shell=True)
elif (system_dis.group()=='Ubuntu'):
subprocess.call("nautilus "+folder,shell=True)
else:
print("Other System tasks")
else:
print("Other System tasks")