install.py

changeset 4307
6a8ec996a49c
parent 4239
4883661fc427
child 4374
627e3d0b4ba1
equal deleted inserted replaced
4305:2f3813e763a3 4307:6a8ec996a49c
1321 @param fileName name of the Python file containing the info (string) 1321 @param fileName name of the Python file containing the info (string)
1322 """ 1322 """
1323 if not fileName: 1323 if not fileName:
1324 return 1324 return
1325 1325
1326 os.rename(fileName, fileName + ".orig") 1326 try:
1327 os.rename(fileName, fileName + ".orig")
1328 except EnvironmentError:
1329 pass
1327 try: 1330 try:
1328 hgOut = subprocess.check_output(["hg", "identify", "-i"]) 1331 hgOut = subprocess.check_output(["hg", "identify", "-i"])
1329 if sys.version_info[0] == 3: 1332 if sys.version_info[0] == 3:
1330 hgOut = hgOut.decode() 1333 hgOut = hgOut.decode()
1331 except (FileNotFoundError, subprocess.CalledProcessError): 1334 except (FileNotFoundError, subprocess.CalledProcessError):
1338 f = codecs.open(fileName + ".orig", "r", "utf-8") 1341 f = codecs.open(fileName + ".orig", "r", "utf-8")
1339 else: 1342 else:
1340 f = open(fileName + ".orig", "r", encoding="utf-8") 1343 f = open(fileName + ".orig", "r", encoding="utf-8")
1341 text = f.read() 1344 text = f.read()
1342 f.close() 1345 f.close()
1343 text = text.replace("@@REVISION@@", hgOut) 1346 text = text.replace("@@REVISION@@", hgOut)\
1347 .replace("@@VERSION@@", "rev_" + hgOut)
1344 copyToFile(fileName, text) 1348 copyToFile(fileName, text)
1345 else: 1349 else:
1346 shutil.copy(fileName + ".orig", fileName) 1350 shutil.copy(fileName + ".orig", fileName)
1347 1351
1348 1352

eric ide

mercurial