source: sasview/sansview/installer_generator.py @ 92f5521a

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 92f5521a was f5f257b, checked in by Jae Cho <jhjcho@…>, 14 years ago

new version 2nd RC(release candidate)

  • Property mode set to 100644
File size: 7.8 KB
RevLine 
[b0e8beb]1"""
2this module generate .ss file according to the local config of
3the current application. Please make sure a file named "local_config.py"
4exists in the current directory. Edit local_config.py according to your needs.
5"""
6import local_config
7import os 
8import string
9
10REG_PROGRAM = """{app}\MYPROG.EXE"" ""%1"""
11APPLICATION = str(local_config.__appname__ )+ '.exe'
12AppName  = str(local_config.__appname__ ) + '-'+ str(local_config.__version__)
13AppVerName = str(local_config.__appname__ ) + '-'+ str(local_config.__version__)
14AppPublisher = local_config._copyright
15AppPublisherURL = local_config._homepage
16AppSupportURL = local_config._homepage
17AppUpdatesURL = local_config._homepage
18DefaultDirName = os.path.join("{pf}" , AppVerName) 
19DefaultGroupName = os.path.join(local_config.DefaultGroupName, AppVerName)
20                               
21OutputBaseFilename = local_config.OutputBaseFilename
[e52010a]22SetupIconFile = local_config.SetupIconFile_win
[b0e8beb]23LicenseFile = 'license.txt'
24DisableProgramGroupPage = 'yes'
25Compression = 'lzma'
26SolidCompression = 'yes'
27PrivilegesRequired = 'none'
[f5f257b]28INSTALLER_FILE = 'installer_new'
[b0e8beb]29#find extension for windows file assocation
30#extension list need to be modified for each application
31
32def find_extension():
33    """
34    Describe the extensions that can be read by the current application
35    """
36    try:
37        list = []
38        #(ext, type, name, flags)
39        from DataLoader.loader import Loader
40        wild_cards = Loader().get_wildcards()
41        for item in wild_cards:
42            #['All (*.*)|*.*']
43            file_type, ext = string.split(item, "|*", 1)
44            if ext.strip() not in ['.*', ''] and ext.strip() not in list:
45                list.append((ext, 'string', file_type))
46    except:
47        pass
48    try:
49        file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*", 1)
50        if ext.strip() not in ['.', ''] and ext.strip() not in list:
51            list.append((ext, 'string', file_type))
52    except:
53        pass
54    try:
55        for item in local_config.PLUGINS_WLIST:
56            file_type, ext = string.split(item, "|*", 1)
57            if ext.strip() not in ['.', ''] and ext.strip() not in list:
58                list.append((ext, 'string', file_type)) 
59    except:
60        pass
61    return list
62EXTENSION = find_extension()
63   
64def write_registry(extension=None):
65    """
66    create file association for windows.
67    Allow open file on double click
68    """
69    msg = ""
70    if extension is not None and extension:
71        msg = "\n\n[Registry]\n"
72        for (ext, type, _) in extension:
73            msg +=  """Root: HKCR;\tSubkey: "%s";\t""" % str(ext)
74            msg += """ValueType: %s;\t""" % str(type)
75            #file type empty set the current application as the default
76            #reader for this file. change the value of file_type to another
77            #string modify the default reader
78            file_type = ''
79            msg += """ValueName: "%s";\t""" % str('')
80            msg += """ValueData: "{app}\%s";\t""" % str(APPLICATION)
81            msg += """ Flags: %s""" % str('uninsdeletevalue')
82            msg += "\n"
83     
84        #create default icon
85        msg += """Root: HKCR; Subkey: "{app}\%s";\t""" % str(SetupIconFile)
86        msg += """ValueType: %s; """ % str('string')
87        msg += """ValueName: "%s";\t""" % str('') 
88        msg += """ValueData: "{app}\%s,0"\n""" % str(APPLICATION)
89        #execute the file on double-click
90        msg += """Root: HKCR; Subkey: "{app}\%s\shell\open\command";\t"""  %  str(APPLICATION)
91        msg += """ValueType: %s; """ % str('string')
92        msg += """ValueName: "%s";\t""" %str('') 
93        msg += """ValueData: \"""{app}\%s""  ""%s1\"""\n"""% (str(APPLICATION),
94                                                              str('%'))
95
96    return msg
97
98def write_language(language=['english'], msfile="compiler:Default.isl"): 
99    """
100    define the language of the application
101    """ 
102    msg = ''
103    if language:
104        msg = "\n\n[Languages]\n"
105        for lang in language:
106            msg += """Name: "%s";\tMessagesFile: "%s"\n""" % (str(lang), 
107                                                           str(msfile))
108    return msg
109
110def write_tasks():
111    """
112    create desktop icon
113    """
114    msg = """\n\n[Tasks]\n"""
115    msg += """Name: "desktopicon";\tDescription: "{cm:CreateDesktopIcon}";\t"""
116    msg += """GroupDescription: "{cm:AdditionalIcons}";\tFlags: unchecked\n"""
117    return msg
118
119def write_file():
120    """
121    copy some data files
122    """
123    msg = "\n\n[Files]\n"
124    msg += """Source: "dist\%s";\t""" % str(APPLICATION)
125    msg += """DestDir: "{app}";\tFlags: ignoreversion\n"""
126    msg += """Source: "dist\*";\tDestDir: "{app}";\t"""
127    msg += """Flags: ignoreversion recursesubdirs createallsubdirs\n"""
128    msg += """Source: "images\*";\tDestDir: "{app}\%s";\t""" % str("images")
129    msg += """Flags: ignoreversion recursesubdirs createallsubdirs\n"""
130    msg += """Source: "test\*";\tDestDir: "{app}\%s";\t""" % str("test")
131    msg += """Flags: ignoreversion recursesubdirs createallsubdirs\n"""
132    msg += """;\tNOTE: Don't use "Flags: ignoreversion" on any shared system files"""
133    return msg
134
135def write_icon():
136    """
137    Create application icon
138    """
139    msg = """\n\n[Icons]\n"""
140    msg += """Name: "{group}\%s";\t""" % str(AppName)
141    msg += """Filename: "{app}\%s";\t"""  % str(APPLICATION)
142    msg += """WorkingDir: "{app}" \n"""
143    msg += """Name: "{group}\{cm:UninstallProgram, %s}";\t""" % str(AppName)
144    msg += """ Filename: "{uninstallexe}" \n"""
145    msg += """Name: "{commondesktop}\%s";\t""" % str(AppVerName)
146    msg += """Filename: "{app}\%s";\t""" % str(APPLICATION)
147    msg += """Tasks: desktopicon; WorkingDir: "{app}" \n"""
148    return msg
149
150def write_run():
151    """
152    execute some file
153    """
154    msg = """\n\n[Run]\n"""
155    msg += """Filename: "{app}\%s";\t""" % str(APPLICATION)
156    msg += """Description: "{cm:LaunchProgram, %s}";\t""" %str(AppName) 
157    msg += """Flags: nowait postinstall skipifsilent\n"""
158    return msg
159
160
161if __name__ == "__main__":
162    TEMPLATE = "\n; Script generated by the Inno Setup Script Wizard\n"
163    TEMPLATE += "\n; and local_config.py located in this directory.\n "
164    TEMPLATE += "; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!"
165    TEMPLATE += "\n[Setup]\n\n" 
[de7b4cf]166    TEMPLATE += "ChangesAssociations=%s\n" %str('yes')
167    TEMPLATE += "AppName=%s\n" % str(AppName)
168    TEMPLATE += "AppVerName=%s\n" % str(AppVerName)
169    TEMPLATE += "AppPublisher=%s\n" % str(AppPublisher)
170    TEMPLATE += "AppPublisherURL=%s\n" % str(AppPublisherURL)
171    TEMPLATE += "AppSupportURL=%s\n" % str(AppSupportURL)
172    TEMPLATE += "AppUpdatesURL=%s \n" % str(AppUpdatesURL)
173    TEMPLATE += "DefaultDirName=%s\n" % str(DefaultDirName)
174    TEMPLATE += "DefaultGroupName=%s\n" % str(DefaultGroupName)
175    TEMPLATE += "DisableProgramGroupPage=%s\n" % str(DisableProgramGroupPage)
176    TEMPLATE += "LicenseFile=%s\n" % str(LicenseFile)
177    TEMPLATE += "OutputBaseFilename=%s\n" % str(OutputBaseFilename)
178    TEMPLATE += "SetupIconFile=%s\n" % str(SetupIconFile)
179    TEMPLATE += "Compression=%s\n" % str(Compression)
180    TEMPLATE += "SolidCompression=%s\n" % str(SolidCompression)
181    TEMPLATE += "PrivilegesRequired=%s\n" % str(PrivilegesRequired)
[b0e8beb]182   
183    TEMPLATE += write_registry(extension=EXTENSION)
184    TEMPLATE += write_language()
185    TEMPLATE += write_tasks()
186    TEMPLATE += write_file()
187    TEMPLATE += write_icon()
188    TEMPLATE += write_run()
189    path = '%s.iss' % str(INSTALLER_FILE)
190    f = open(path,'w') 
191    f.write(TEMPLATE)
192    f.close()
193    print "Generate Inno setup installer script complete"
194    print "A new file %s.iss should be created.Please refresh your directory" % str(INSTALLER_FILE)
Note: See TracBrowser for help on using the repository browser.