scripts/install.py

changeset 8240
93b8a353c4bf
parent 8214
51f0d3e047ec
child 8243
cc717c2ae956
equal deleted inserted replaced
8239:59a9a658618c 8240:93b8a353c4bf
22 import io 22 import io
23 import json 23 import json
24 import shlex 24 import shlex
25 import datetime 25 import datetime
26 import getpass 26 import getpass
27 import contextlib
27 28
28 # Define the globals. 29 # Define the globals.
29 progName = None 30 progName = None
30 currDir = os.getcwd() 31 currDir = os.getcwd()
31 modDir = None 32 modDir = None
1742 @param fileName name of the Python file containing the info (string) 1743 @param fileName name of the Python file containing the info (string)
1743 """ 1744 """
1744 if not fileName: 1745 if not fileName:
1745 return 1746 return
1746 1747
1747 try: 1748 with contextlib.suppress(OSError):
1748 os.rename(fileName, fileName + ".orig") 1749 os.rename(fileName, fileName + ".orig")
1749 except OSError:
1750 pass
1751 try: 1750 try:
1752 hgOut = subprocess.check_output(["hg", "identify", "-i"]) # secok 1751 hgOut = subprocess.check_output(["hg", "identify", "-i"]) # secok
1753 hgOut = hgOut.decode() 1752 hgOut = hgOut.decode()
1754 except (OSError, subprocess.CalledProcessError): 1753 except (OSError, subprocess.CalledProcessError):
1755 hgOut = "" 1754 hgOut = ""
2057 with open(os.path.join(cfg["ericDir"], 2056 with open(os.path.join(cfg["ericDir"],
2058 installInfoName), "w") as installInfoFile: 2057 installInfoName), "w") as installInfoFile:
2059 json.dump(installInfo, installInfoFile, indent=2) 2058 json.dump(installInfo, installInfoFile, indent=2)
2060 2059
2061 # do some cleanup 2060 # do some cleanup
2062 try: 2061 with contextlib.suppress(OSError):
2063 if installFromSource: 2062 if installFromSource:
2064 os.remove(configName) 2063 os.remove(configName)
2065 configNameC = configName + 'c' 2064 configNameC = configName + 'c'
2066 if os.path.exists(configNameC): 2065 if os.path.exists(configNameC):
2067 os.remove(configNameC) 2066 os.remove(configNameC)
2068 os.rename(configName + ".orig", configName) 2067 os.rename(configName + ".orig", configName)
2069 except OSError: 2068 with contextlib.suppress(OSError):
2070 pass
2071 try:
2072 if installFromSource and infoName: 2069 if installFromSource and infoName:
2073 os.remove(infoName) 2070 os.remove(infoName)
2074 infoNameC = infoName + 'c' 2071 infoNameC = infoName + 'c'
2075 if os.path.exists(infoNameC): 2072 if os.path.exists(infoNameC):
2076 os.remove(infoNameC) 2073 os.remove(infoNameC)
2077 os.rename(infoName + ".orig", infoName) 2074 os.rename(infoName + ".orig", infoName)
2078 except OSError:
2079 pass
2080 2075
2081 print("\nInstallation complete.") 2076 print("\nInstallation complete.")
2082 print() 2077 print()
2083 2078
2084 exit(res) 2079 exit(res)

eric ide

mercurial