# -*- coding: ISO-8859-1 -*- """ capellaScript -- 09.06.2005 Peter Becker >>> Create Script Erzeugt ein Script, das mehrere selektierbare Scripts hintereinander ausführt<<< History: 09.06.05 - Erste Ausgabe 13.06.05 - Dank Paul werden jetzt auch die Optionen gefunden 05.08.07 - Anpassung an Stepup 12 01.09.08 - Anpassung an VISTA """ import os, os.path, string, shutil programDir = getProgramDir() dataDir = getPersonalDataDir() #messageBox('DATA',str(dataDir)) pluginFileName = os.path.join(programDir,"data\\plugins.dat") #pluginDataName = os.path.join(dataDir,"script\\") header1 = ['# -*- coding: ISO-8859-1 -*-\n', '""" capellaScript -- erzeugt durch create_script.py\n', ' \n', 'Ausführen der definierten Scripte hintereinander\n', '"""\n', 'import os\n', '\n' ] list1a = 'progList = [\n' list1b = ' ' list1c = ']\n' exec1 = ['for prog in progList:\n', ' _x_y_z_progName = prog\n', ' messageBox("nächstes Programm",str(prog))\n', ' execfile(prog)\n' ] def selectScript(): dlg = FileDialog() dlg.__init__(bOpen=True) dlg.setTitle('Python Skript auswählen') dlg.addFilter('Python Scripts', '*.py') dlg.setStartFile(str(sys.argv[0])) if dlg.run(): newSkript = dlg.filePath() if dataDir in newSkript: # newSkript = newSkript[len(programDir + 'script\\')+1:] pass else: newSkript = '' messageBox('-- Hinweis --', 'Skript nicht im Capella Skriptverzeichnis',2) return newSkript else: return '' task = 0 sn = ' ' start = 0 scriptPath = os.path.join(dataDir,'scripts')+ '\\' while task <> 1: #options = ScriptOptions('CS.opt') options = ScriptOptions() opt = options.get() lablPath1 = Label('Script Pfad : ',width=8) lablPath2 = Label(scriptPath,width=3) editPath = Edit(opt.get('pn'), width=20) hboxPath = HBox([lablPath2,editPath]) lablName1 = Label('Scriptname',width=8) editName = Edit(opt.get('sn'), width=15) lablName2 = Label('.py',width=3) radNeu = Radio(['Neues Skript auswählen','Skript beenden'], value = 0, text = 'Aktion') hboxName = HBox([lablName1,editName,lablName2]) vboxName = VBox([lablPath1,hboxPath,hboxName,radNeu]) dlg = Dialog(' -- neues Script --', vboxName) if dlg.run(): task = radNeu.value() name = editName.value() path = editPath.value() opt = dict(sn=name,pn=path) options.set(opt) if task == 0: script = selectScript().replace('\\','\\\\') # pluginFileName = list1b + '"' + os.path.join(programDir,'scripts',script) + '",\n' pluginFileName = '%s"%s",\n' % (list1b, script) if start == 0: fl = file(scriptPath + path + '\\' + name + '.py','w') for hd in header1: fl.write(hd) start = 1 fl.write(list1a) fl.write(pluginFileName) if task == 1 : fl.write(list1b) fl.write(list1c) for ex in exec1: fl.write(ex) fl.close() break else: break