def ConsolidateSnapshotData(dataExportFolderPath, output): try: snapshotDataFilePath = GetSnapshotDataFilePath(dataExportFolderPath) temporarySnapshotDataFilePath = GetTemporarySnapshotDataFilePath( dataExportFolderPath) if File.Exists(snapshotDataFilePath): if File.Exists(temporarySnapshotDataFilePath): File.Delete(temporarySnapshotDataFilePath) elif File.Exists(temporarySnapshotDataFilePath): File.Move(temporarySnapshotDataFilePath, snapshotDataFilePath) else: output() output( "WARNING: could not find snapshot data file in snapshot data folder:" ) output() output("\t" + dataExportFolderPath) except Exception, e: output() output( "WARNING: failed to properly consolidate the snapshot data in folder:" ) output() output("\t" + dataExportFolderPath) exception_util.LogOutputErrorDetails(e, output)
def Load(self, path="settings.dat"): #Get settings for the settings.xml file #Change the xml to dat. This will be removed in later versions. if File.Exists(common.SCRIPTDIRECTORY + "settings.xml"): File.Move(common.SCRIPTDIRECTORY + "settings.xml", common.SCRIPTDIRECTORY + path) if File.Exists(common.SCRIPTDIRECTORY + path): xreader = XmlReader.Create(common.SCRIPTDIRECTORY + path) while xreader.Read(): if xreader.Name == "DisplayCovers": self.DisplayCovers = xreader.ReadElementContentAsBoolean() #print self.DisplayCovers if xreader.Name == "DownloadCovers": self.DownloadCovers = xreader.ReadElementContentAsBoolean() #print self.DownloadCovers if xreader.Name == "BlackList": blacklist = xreader.ReadElementContentAsString() self.BlackList = blacklist.split(",") #print self.BlackList if xreader.Name == "DisplayPrice": self.DisplayPrice = xreader.ReadElementContentAsBoolean() if xreader.Name == "DisplayPublisher": self.DisplayPublisher = xreader.ReadElementContentAsBoolean() if xreader.Name == "Export": self.Export = xreader.ReadElementContentAsBoolean() xreader.Close() xreader.Dispose() else: print "settings.xml does not exist yet....\nUsing default values" return
def main(): if len(sys.argv) != 2: print "Usage: ipy run_compiled.py <testfile.py>" sys.exit(-1) testName = sys.argv[1] print "Compiling ", testName ,"..." clr.CompileModules("compiledTest.dll", testName) File.Move(testName, testName+".bak") try: print "Running test from compiled binary..." clr.AddReference("compiledTest") __import__(Path.GetFileNameWithoutExtension(testName)) finally: File.Move(testName+".bak" , testName)
def move(self, fromPath, toPath): """ movies a file or directory """ fromAbsPath = self.absolutePath(fromPath) toAbsPath = self.absolutePath(toPath) try: os.renames(fromAbsPath, toAbsPath) except: if system.isCli: import System.IO.File as file file.Move(fromAbsPath, toAbsPath)
def run(self, Mml2vgmInfo, index): #設定値の読み込み Mml2vgmInfo.loadSetting() #初回のみ(設定値が無いときのみ)mucom88.exeの場所をユーザーに問い合わせ、設定値として保存する mc = Mml2vgmInfo.getSettingValue("mucom88path") if mc is None: mc = Mml2vgmInfo.fileSelect( "mucom88.exeを選択してください(この選択内容は設定値として保存され次回からの問い合わせはありません)") if not Mml2vgmInfo.confirm("mucom88.exeの場所は以下でよろしいですか\r\n" + mc): return None Mml2vgmInfo.setSettingValue("mucom88path", mc) Mml2vgmInfo.saveSetting() #念のため if mc is None or mc == "": Mml2vgmInfo.msg("mucom88.exeを指定してください") return None #ファイル選択 muc = Mml2vgmInfo.fileSelect("mucファイルの選択") if muc is None: return None #ファイル情報の整理 #Mml2vgmInfo.msgLogWindow(muc) wp = Path.GetDirectoryName(muc) #Mml2vgmInfo.msgLogWindow(wp) Directory.SetCurrentDirectory(wp) #mucom88.exeでコンパイルを行いmubファイルを生成する args = "-c " + muc Mml2vgmInfo.runCommand(mc, args, True) #mubファイルが出来たかチェック(mucom88.exeはコンパイルが成功するとmucom88.mubというファイルができる) mm = Path.Combine(wp, "mucom88.mub") #Mml2vgmInfo.msgLogWindow(mm) if not File.Exists(mm): return None #mucom88.mubを本来のファイル名にリネーム mub = Path.Combine(wp, Path.GetFileNameWithoutExtension(muc) + ".mub") #Mml2vgmInfo.msgLogWindow(mub) File.Delete(mub) File.Move(mm, mub) #mucom88.exeで演奏を開始 Mml2vgmInfo.runCommand(mc, mub, False) #戻り値を生成(何もしないけど念のため) si = ScriptInfo() si.responseMessage = "" return si
def textFiles(): ''' Creates *.txt files. One is actually a text file and the other is a DLL in disguise ''' #create a fake DLL file_name = Directory.GetCurrentDirectory() + "\\fooGARBAGE.dll" file = open(file_name, "w") print >> file, garbage file.close() #create a real DLL and give it the *.txt extension createAssembly("TXTDLL", "TXTDLL", 7) File.Move("fooTXTDLL.dll", "fooTXTDLL.txt")
# save the image data to the selected folder and close the image output_detailscan.Save(Path.Combine(OutputFolder, output_detailscan.Name)) output_detailscan.Close() # rename the CZI regarding to the object ID - Attention - IDs start with 2 !!! if not wellid_exist: # no wellID found inside table newname_dtscan = 'DTScan_ID_' + str(POI_ID) + '.czi' if wellid_exist: # wellID was found inside table well_id = SingleObj.GetValue(i, column_wellid) newname_dtscan = 'DTScan_Well_' + str(well_id) + '_ID_' + str( POI_ID) + '.czi' print('Renaming File: ' + dtscan_name + ' to: ' + newname_dtscan + '\n') File.Move(Path.Combine(OutputFolder, dtscan_name), Path.Combine(OutputFolder, newname_dtscan)) ############ OPTIONAL POSTPROCESSING ############### if do_postprocess: # do the postprocessing image2process = Zen.Application.LoadImage(newname_dtscan, False) # define the parameters for processing: Topography Export parameters = {} parameters['noise_low'] = 1 parameters['noise_high'] = 254 parameters['outputfolder'] = OutputFolder parameters['extension'] = '.sur'
# coding=utf-8 # This file is covered by the LICENSE in this dynamo package 'extra' folder ''' Rename file ''' # .Net module from System.IO import File # argument assigned the IN port file_path = IN[0] extension = IN[1] exist_name = IN[2] new_name = IN[3] # core data processing renamed = [] for e_name, n_name in zip(exist_name, new_name): exist_file = file_path + '\\' + e_name + '.' + extension new_file = file_path + '\\' + n_name + '.' + extension File.Move(exist_file, new_file) renamed.append(n_name + '.' + extension) # return assigned the OUT port OUT = renamed
#Check if the file currently exists at all if comic[FILENAME] != 'Fileless' and File.Exists(comic[FILEPATH]): #If the book is already in the location we don't have to do anything if fullpath == comic[FILEPATH]: #print "books path is the same" logfile.write( "\n\nSkipped moving book " + comic[FILEPATH] + " because it is already located at the calculated path" ) dmCleanDirectories(DirectoryInfo(path)) if comic[FILENAME] != 'Fileless' and not File.Exists(fullpath): try: File.Move(comic[FILEPATH], fullpath) comic[BOOK].FilePath = fullpath #update new file path except Exception, ex: MessageBox.Show( 'ERROR: ' + str(ex) + "while trying to move " + comic[FILENAME], 'MOVE ERROR', MessageBoxButtons.OK, MessageBoxIcon.Exclamation) logfile.write('ERROR: ' + str(ex) + '\n') else: logfile.write('WARNING: ' + comic[FILENAME] + ' could not be moved\n') logfile.write('---MOVED... ' + comic[FILENAME] + '\n') if options["removefromlib"]: try:
# get the version attribute version_number = item.GetAttribute('Version') print('Old version : ', version_number) try: # set the new version number item.SetAttribute('Version', newversion) print('Set the Modelversion to: ', newversion) except: # stop the script execution completely sys.exit('Could not update the Version number.') # get the raw XML and write it to disk rawXML = xmldoc.OuterXml File.WriteAllText(modelxml, rawXML) # zip the folder with the updated XML file print('Started zipping ...') zipfile = zipfolder(tempdir, tempdir) change_dir_sep(zipfile) print('Finished zipping: ', tempdir) # rename the new zipfile to *.czmodel print('Rename *.zip back to *.czmodel') File.Move(zipfile, Path.ChangeExtension(zipfile, '.czmodel')) # remover the temp folder from unzipping afterwards if remove_tmpfolder: print('Deleting tempory folder : ', tempdir) Directory.Delete(tempdir, True) print('Done.')
Tiles.TileTools.ModifyTileRegionsXYZ(DetailScan, xpos, ypos, zpos) # Modify ConturSize for the tile according to the size of the bounding rectangle Tiles.TileTools.ModifyTileRegionsSize(DetailScan, bcwidth, bcheight) print 'New Tile Properties: ', round(xpos, 2), round(ypos, 2), round( zpos, 2), round(bcwidth, 2), round(bcheight, 2) # execute the experiment print 'Running Detail Scan Experiment at new XYZ position.' # run the Detail Scan output_detailscan = Zen.Acquisition.Execute(DetailScan) DetailScan.Close() # get the image data name dtscan_name = output_detailscan.Name # save the image data to the selected folder and close the image output_detailscan.Save(OutputFolder + '\\' + output_detailscan.Name) output_detailscan.Close() # rename the CZI regarding to the object ID - Attention - IDs start with 2 !!! newname_dtscan = 'DTScan_ID' + str(POI_ID) + '.czi' if verbose: print 'Renaming File: ' + dtscan_name + ' to: ' + newname_dtscan + '\n' File.Move(OutputFolder + '\\' + dtscan_name, OutputFolder + '\\' + newname_dtscan) ############# END DETAILED SCAN EXPERIMENT ############# # show the overview scan document again at the end Zen.Application.Documents.ActiveDocument = ovdoc print 'All Positions done. RareEvent Detection finished.'