scripts/install.py

changeset 7836
2f0d208b8137
parent 7835
0835ed67714b
child 7850
e64b178499da
child 7894
4370a8b30648
equal deleted inserted replaced
7835:0835ed67714b 7836:2f0d208b8137
572 pass 572 pass
573 573
574 if sys.platform == "darwin": 574 if sys.platform == "darwin":
575 # delete the Mac app bundle 575 # delete the Mac app bundle
576 cleanUpMacAppBundle() 576 cleanUpMacAppBundle()
577 except (IOError, OSError) as msg: 577 except OSError as msg:
578 sys.stderr.write( 578 sys.stderr.write(
579 'Error: {0}\nTry install with admin rights.\n'.format(msg)) 579 'Error: {0}\nTry install with admin rights.\n'.format(msg))
580 exit(7) 580 exit(7)
581 581
582 582
669 for linkName in windowsDesktopNames(): 669 for linkName in windowsDesktopNames():
670 linkPath = os.path.join(desktopFolder, linkName) 670 linkPath = os.path.join(desktopFolder, linkName)
671 if os.path.exists(linkPath): 671 if os.path.exists(linkPath):
672 try: 672 try:
673 os.remove(linkPath) 673 os.remove(linkPath)
674 except EnvironmentError: 674 except OSError:
675 # maybe restrictions prohibited link removal 675 # maybe restrictions prohibited link removal
676 print("Could not remove '{0}'.".format(linkPath)) 676 print("Could not remove '{0}'.".format(linkPath))
677 677
678 # 2. cleanup start menu entry 678 # 2. cleanup start menu entry
679 regName = "Programs" 679 regName = "Programs"
682 programsFolder = os.path.normpath(os.path.expandvars(programsEntry)) 682 programsFolder = os.path.normpath(os.path.expandvars(programsEntry))
683 eric6EntryPath = os.path.join(programsFolder, windowsProgramsEntry()) 683 eric6EntryPath = os.path.join(programsFolder, windowsProgramsEntry())
684 if os.path.exists(eric6EntryPath): 684 if os.path.exists(eric6EntryPath):
685 try: 685 try:
686 shutil.rmtree(eric6EntryPath) 686 shutil.rmtree(eric6EntryPath)
687 except EnvironmentError: 687 except OSError:
688 # maybe restrictions prohibited link removal 688 # maybe restrictions prohibited link removal
689 print("Could not remove '{0}'.".format(eric6EntryPath)) 689 print("Could not remove '{0}'.".format(eric6EntryPath))
690 690
691 691
692 def shutilCopy(src, dst, perm=0o644): 692 def shutilCopy(src, dst, perm=0o644):
824 cfg['ericDir']) 824 cfg['ericDir'])
825 825
826 # create the global plugins directory 826 # create the global plugins directory
827 createGlobalPluginsDir() 827 createGlobalPluginsDir()
828 828
829 except (IOError, OSError) as msg: 829 except OSError as msg:
830 sys.stderr.write( 830 sys.stderr.write(
831 'Error: {0}\nTry install with admin rights.\n'.format(msg)) 831 'Error: {0}\nTry install with admin rights.\n'.format(msg))
832 return(7) 832 return(7)
833 833
834 # copy some text files to the doc area 834 # copy some text files to the doc area
835 for name in ["LICENSE.GPL3", "THANKS", "changelog"]: 835 for name in ["LICENSE.GPL3", "THANKS", "changelog"]:
836 try: 836 try:
837 shutilCopy(os.path.join(sourceDir, "docs", name), 837 shutilCopy(os.path.join(sourceDir, "docs", name),
838 cfg['ericDocDir']) 838 cfg['ericDocDir'])
839 except EnvironmentError: 839 except OSError:
840 print("Could not install '{0}'.".format( 840 print("Could not install '{0}'.".format(
841 os.path.join(sourceDir, "docs", name))) 841 os.path.join(sourceDir, "docs", name)))
842 for name in glob.glob(os.path.join(sourceDir, 'docs', 'README*.*')): 842 for name in glob.glob(os.path.join(sourceDir, 'docs', 'README*.*')):
843 try: 843 try:
844 shutilCopy(name, cfg['ericDocDir']) 844 shutilCopy(name, cfg['ericDocDir'])
845 except EnvironmentError: 845 except OSError:
846 print("Could not install '{0}'.".format(name)) 846 print("Could not install '{0}'.".format(name))
847 847
848 # copy some more stuff 848 # copy some more stuff
849 for name in ['default.e4k', 'default_Mac.e4k']: 849 for name in ['default.e4k', 'default_Mac.e4k']:
850 try: 850 try:
851 shutilCopy(os.path.join(sourceDir, "others", name), 851 shutilCopy(os.path.join(sourceDir, "others", name),
852 cfg['ericOthersDir']) 852 cfg['ericOthersDir'])
853 except EnvironmentError: 853 except OSError:
854 print("Could not install '{0}'.".format( 854 print("Could not install '{0}'.".format(
855 os.path.join(sourceDir, "others", name))) 855 os.path.join(sourceDir, "others", name)))
856 856
857 # install the API file 857 # install the API file
858 if installApis: 858 if installApis:
864 os.makedirs(apidir) 864 os.makedirs(apidir)
865 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs", 865 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs",
866 progLanguage, "*.api")): 866 progLanguage, "*.api")):
867 try: 867 try:
868 shutilCopy(apiName, apidir) 868 shutilCopy(apiName, apidir)
869 except EnvironmentError: 869 except OSError:
870 print("Could not install '{0}' (no permission)." 870 print("Could not install '{0}' (no permission)."
871 .format(apiName)) 871 .format(apiName))
872 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs", 872 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs",
873 progLanguage, "*.bas")): 873 progLanguage, "*.bas")):
874 try: 874 try:
875 shutilCopy(apiName, apidir) 875 shutilCopy(apiName, apidir)
876 except EnvironmentError: 876 except OSError:
877 print("Could not install '{0}' (no permission)." 877 print("Could not install '{0}' (no permission)."
878 .format(apiName)) 878 .format(apiName))
879 if progLanguage == "Python": 879 if progLanguage == "Python":
880 # copy Python3 API files to the same destination 880 # copy Python3 API files to the same destination
881 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs", 881 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs",
882 "Python3", "*.api")): 882 "Python3", "*.api")):
883 try: 883 try:
884 shutilCopy(apiName, apidir) 884 shutilCopy(apiName, apidir)
885 except EnvironmentError: 885 except OSError:
886 print("Could not install '{0}' (no permission)." 886 print("Could not install '{0}' (no permission)."
887 .format(apiName)) 887 .format(apiName))
888 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs", 888 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs",
889 "Python3", "*.bas")): 889 "Python3", "*.bas")):
890 if os.path.exists(os.path.join( 890 if os.path.exists(os.path.join(
891 apidir, os.path.basename( 891 apidir, os.path.basename(
892 apiName.replace(".bas", ".api")))): 892 apiName.replace(".bas", ".api")))):
893 try: 893 try:
894 shutilCopy(apiName, apidir) 894 shutilCopy(apiName, apidir)
895 except EnvironmentError: 895 except OSError:
896 print("Could not install '{0}' (no permission)." 896 print("Could not install '{0}' (no permission)."
897 .format(apiName)) 897 .format(apiName))
898 898
899 # copy MicroPython API files to the same destination 899 # copy MicroPython API files to the same destination
900 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs", 900 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs",
901 "MicroPython", "*.api")): 901 "MicroPython", "*.api")):
902 try: 902 try:
903 shutilCopy(apiName, apidir) 903 shutilCopy(apiName, apidir)
904 except EnvironmentError: 904 except OSError:
905 print("Could not install '{0}' (no permission)." 905 print("Could not install '{0}' (no permission)."
906 .format(apiName)) 906 .format(apiName))
907 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs", 907 for apiName in glob.glob(os.path.join(eric6SourceDir, "APIs",
908 "MicroPython", "*.bas")): 908 "MicroPython", "*.bas")):
909 if os.path.exists(os.path.join( 909 if os.path.exists(os.path.join(
910 apidir, os.path.basename( 910 apidir, os.path.basename(
911 apiName.replace(".bas", ".api")))): 911 apiName.replace(".bas", ".api")))):
912 try: 912 try:
913 shutilCopy(apiName, apidir) 913 shutilCopy(apiName, apidir)
914 except EnvironmentError: 914 except OSError:
915 print("Could not install '{0}' (no permission)." 915 print("Could not install '{0}' (no permission)."
916 .format(apiName)) 916 .format(apiName))
917 917
918 # Create menu entry for Linux systems 918 # Create menu entry for Linux systems
919 if sys.platform.startswith("linux"): 919 if sys.platform.startswith("linux"):
1063 programsFolder = os.path.normpath(os.path.expandvars(programsEntry)) 1063 programsFolder = os.path.normpath(os.path.expandvars(programsEntry))
1064 eric6EntryPath = os.path.join(programsFolder, windowsProgramsEntry()) 1064 eric6EntryPath = os.path.join(programsFolder, windowsProgramsEntry())
1065 if not os.path.exists(eric6EntryPath): 1065 if not os.path.exists(eric6EntryPath):
1066 try: 1066 try:
1067 os.makedirs(eric6EntryPath) 1067 os.makedirs(eric6EntryPath)
1068 except EnvironmentError: 1068 except OSError:
1069 # maybe restrictions prohibited link creation 1069 # maybe restrictions prohibited link creation
1070 return 1070 return
1071 1071
1072 for linkName, targetPath, iconPath in windowsDesktopEntries(): 1072 for linkName, targetPath, iconPath in windowsDesktopEntries():
1073 linkPath = os.path.join(eric6EntryPath, linkName) 1073 linkPath = os.path.join(eric6EntryPath, linkName)
1735 if not fileName: 1735 if not fileName:
1736 return 1736 return
1737 1737
1738 try: 1738 try:
1739 os.rename(fileName, fileName + ".orig") 1739 os.rename(fileName, fileName + ".orig")
1740 except EnvironmentError: 1740 except OSError:
1741 pass 1741 pass
1742 try: 1742 try:
1743 hgOut = subprocess.check_output(["hg", "identify", "-i"]) # secok 1743 hgOut = subprocess.check_output(["hg", "identify", "-i"]) # secok
1744 hgOut = hgOut.decode() 1744 hgOut = hgOut.decode()
1745 except (OSError, subprocess.CalledProcessError): 1745 except (OSError, subprocess.CalledProcessError):
1983 os.rename(configName, configName + ".orig") 1983 os.rename(configName, configName + ".orig")
1984 configNameC = configName + 'c' 1984 configNameC = configName + 'c'
1985 if os.path.exists(configNameC): 1985 if os.path.exists(configNameC):
1986 os.remove(configNameC) 1986 os.remove(configNameC)
1987 os.remove(configName) 1987 os.remove(configName)
1988 except EnvironmentError: 1988 except OSError:
1989 pass 1989 pass
1990 1990
1991 # cleanup old installation 1991 # cleanup old installation
1992 print("Cleaning up old installation ...") 1992 print("Cleaning up old installation ...")
1993 try: 1993 try:
1994 if doCleanup: 1994 if doCleanup:
1995 if distDir: 1995 if distDir:
1996 shutil.rmtree(distDir, True) 1996 shutil.rmtree(distDir, True)
1997 else: 1997 else:
1998 cleanUp() 1998 cleanUp()
1999 except (IOError, OSError) as msg: 1999 except OSError as msg:
2000 sys.stderr.write('Error: {0}\nTry install as root.\n'.format(msg)) 2000 sys.stderr.write('Error: {0}\nTry install as root.\n'.format(msg))
2001 exit(7) 2001 exit(7)
2002 2002
2003 # Create a config file and delete the default one 2003 # Create a config file and delete the default one
2004 print("\nCreating configuration file ...") 2004 print("\nCreating configuration file ...")
2050 os.remove(configName) 2050 os.remove(configName)
2051 configNameC = configName + 'c' 2051 configNameC = configName + 'c'
2052 if os.path.exists(configNameC): 2052 if os.path.exists(configNameC):
2053 os.remove(configNameC) 2053 os.remove(configNameC)
2054 os.rename(configName + ".orig", configName) 2054 os.rename(configName + ".orig", configName)
2055 except EnvironmentError: 2055 except OSError:
2056 pass 2056 pass
2057 try: 2057 try:
2058 if installFromSource and infoName: 2058 if installFromSource and infoName:
2059 os.remove(infoName) 2059 os.remove(infoName)
2060 infoNameC = infoName + 'c' 2060 infoNameC = infoName + 'c'
2061 if os.path.exists(infoNameC): 2061 if os.path.exists(infoNameC):
2062 os.remove(infoNameC) 2062 os.remove(infoNameC)
2063 os.rename(infoName + ".orig", infoName) 2063 os.rename(infoName + ".orig", infoName)
2064 except EnvironmentError: 2064 except OSError:
2065 pass 2065 pass
2066 2066
2067 print("\nInstallation complete.") 2067 print("\nInstallation complete.")
2068 print() 2068 print()
2069 2069

eric ide

mercurial