scripts/install-i18n.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9328
49a0a9cb2505
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
21 sys.exit(1) 21 sys.exit(1)
22 except SyntaxError: 22 except SyntaxError:
23 # an incomplete or old config file was found 23 # an incomplete or old config file was found
24 print("The eric IDE seems to be installed incompletely. Aborting.") 24 print("The eric IDE seems to be installed incompletely. Aborting.")
25 sys.exit(1) 25 sys.exit(1)
26 26
27 27
28 def getConfigDir(): 28 def getConfigDir():
29 """ 29 """
30 Global function to get the name of the directory storing the config data. 30 Global function to get the name of the directory storing the config data.
31 31
32 @return directory name of the config dir (string) 32 @return directory name of the config dir (string)
33 """ 33 """
34 cdn = ".eric7" 34 cdn = ".eric7"
35 35
36 hp = os.path.join(os.path.expanduser("~"), cdn) 36 hp = os.path.join(os.path.expanduser("~"), cdn)
37 if not os.path.exists(hp): 37 if not os.path.exists(hp):
38 os.mkdir(hp) 38 os.mkdir(hp)
39 return hp 39 return hp
40 40
41
41 # Define the globals. 42 # Define the globals.
42 progName = None 43 progName = None
43 configDir = getConfigDir() 44 configDir = getConfigDir()
44 privateInstall = False 45 privateInstall = False
45 46
55 print() 56 print()
56 print("Usage:") 57 print("Usage:")
57 print(" {0} [-hp]".format(progName)) 58 print(" {0} [-hp]".format(progName))
58 print("where:") 59 print("where:")
59 print(" -h display this help message") 60 print(" -h display this help message")
60 print(" -p install into the private area ({0})".format( 61 print(" -p install into the private area ({0})".format(configDir))
61 configDir))
62 62
63 sys.exit(rcode) 63 sys.exit(rcode)
64 64
65 65
66 def installTranslations(): 66 def installTranslations():
67 """ 67 """
68 Install the translation files into the right place. 68 Install the translation files into the right place.
69 """ 69 """
70 global privateInstall, configDir 70 global privateInstall, configDir
71 71
72 targetDir = (configDir if privateInstall 72 targetDir = configDir if privateInstall else getConfig("ericTranslationsDir")
73 else getConfig('ericTranslationsDir')) 73
74
75 try: 74 try:
76 for fn in glob.glob(os.path.join('eric', 'src', 'eric7', 'i18n', '*.qm')): 75 for fn in glob.glob(os.path.join("eric", "src", "eric7", "i18n", "*.qm")):
77 shutil.copy2(fn, targetDir) 76 shutil.copy2(fn, targetDir)
78 os.chmod(os.path.join(targetDir, os.path.basename(fn)), 0o644) 77 os.chmod(os.path.join(targetDir, os.path.basename(fn)), 0o644)
79 except OSError as msg: 78 except OSError as msg:
80 sys.stderr.write( 79 sys.stderr.write("OSError: {0}\nTry install-i18n as root.\n".format(msg))
81 'OSError: {0}\nTry install-i18n as root.\n'.format(msg))
82 except OSError as msg: 80 except OSError as msg:
83 sys.stderr.write( 81 sys.stderr.write(
84 'OSError: {0}\nTry install-i18n with admin rights.\n'.format(msg)) 82 "OSError: {0}\nTry install-i18n with admin rights.\n".format(msg)
85 83 )
84
86 85
87 def main(argv): 86 def main(argv):
88 """ 87 """
89 The main function of the script. 88 The main function of the script.
90 89
100 optlist, args = getopt.getopt(argv[1:], "hp") 99 optlist, args = getopt.getopt(argv[1:], "hp")
101 except getopt.GetoptError: 100 except getopt.GetoptError:
102 usage() 101 usage()
103 102
104 global platBinDir 103 global platBinDir
105 104
106 for opt, _arg in optlist: 105 for opt, _arg in optlist:
107 if opt == "-h": 106 if opt == "-h":
108 usage(0) 107 usage(0)
109 elif opt == "-p": 108 elif opt == "-p":
110 privateInstall = 1 109 privateInstall = 1
111 110
112 installTranslations() 111 installTranslations()
112
113 113
114 if __name__ == "__main__": 114 if __name__ == "__main__":
115 try: 115 try:
116 main(sys.argv) 116 main(sys.argv)
117 except SystemExit: 117 except SystemExit:
118 raise 118 raise
119 except Exception: 119 except Exception:
120 print("""An internal error occured. Please report all the output of""" 120 print(
121 """ the program,\nincluding the following traceback, to""" 121 """An internal error occured. Please report all the output of"""
122 """ eric-bugs@eric-ide.python-projects.org.\n""") 122 """ the program,\nincluding the following traceback, to"""
123 """ eric-bugs@eric-ide.python-projects.org.\n"""
124 )
123 raise 125 raise
124 126
125 # 127 #
126 # eflag: noqa = M801 128 # eflag: noqa = M801

eric ide

mercurial