Ejemplo n.º 1
0
def rip(driveLetter, movieName):
    out = Path.Combine(Path.GetTempPath(), movieName)
    # for debugging
    if True:
        return Directory.GetFiles(out)[0]

    print("Saving to: '%s'" % out)

    if not os.path.exists(out):
        os.makedirs(out)

    p = Process()
    p.StartInfo.UseShellExecute = False
    #p.StartInfo.RedirectStandardOutput = True
    p.StartInfo.FileName = "makemkvcon"
    p.StartInfo.Arguments = '--minlength=2700 mkv disc:0 all "%s"' % out
    print("Saving to: '%s'" % out)
    print(p.StartInfo.Arguments)
    if p.Start():
        print("Ripping")
        p.WaitForExit()
        if p.ExitCode == 0:
            print("Successfully ripped %s" % movieName)

            return Directory.GetFiles(out)[0]
        else:
            print("Error: %d" % p.ExitCode)
    else:
        print("Error ripping, quitting")
Ejemplo n.º 2
0
def ImportMultipleDocuments(directory, documentFolder):
    """
    <Script>
    <Author>ANK</Author>
    <Description>load all files in a directory into a documentfolder. If a document already exists with the same name as a new file it wil be replaced</Description>
    <Parameters>
    <Parameter name="directory" type="string">directory path</Parameter>
    <Parameter name="documentFolder" type="string">document folder</Parameter>
    </Parameters>
    </Script>
    """
    dm = app.Modules.Get("Document Manager")
    dg = dm.DocumentFolderList.Fetch(documentFolder)
    if (dg == None):
        dg = dm.DocumentFolderList.CreateNew(documentFolder)
        dm.DocumentFolderList.Add(dg)

    for f in Directory.GetFiles(directory):
        print f
        fname = os.path.split(f)[1]
        d = dm.DocumentList.Fetch(documentFolder + "/" + fname)
        if d is not None:
            print "  - deleting old document"
            dm.DocumentList.Delete(d)
        dm.DocumentList.Import(f, dg.Id, fname)
        print "  - importing"

    print "done"
Ejemplo n.º 3
0
def recycleBin():
    summary = printHeader("RECYCLE BIN")
    if WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator):
        for drive in DriveInfo.GetDrives():
            try:
                recycleDir = DirectoryInfo(drive.Name + "$Recycle.Bin\\")
                for dir in DirectoryInfo.EnumerateDirectories(recycleDir):
                    fileList = DirectoryInfo.GetFiles(dir)
                    summary += printSubheader("Directory: {0}".format(dir.FullName))
                    for file in fileList:
                        name = file.FullName.split("\\")[-1]
                        if name.startswith("$I"):
                            info = open(file.FullName, "r").read()
                            summary += "{0}\t{1}\n".format(name.replace("$I", "$R"), info[26::2])
            except IOError:
                pass
    else:
        for drive in DriveInfo.GetDrives():
            try:
                recycleDir = drive.Name + "$Recycle.Bin\\"
                user = WindowsIdentity.GetCurrent()
                fileList = Directory.GetFiles(recycleDir + user.Owner.ToString())
                summary += printSubheader("Directory: {0}".format(recycleDir + user.Owner.ToString()))
                for file in fileList:
                    name = file.split("\\")[-1]
                    if name.startswith("$I"):
                        info = open(file, "r").read()
                        summary += "{0}\t{1}\n".format(name.replace("$I", "$R"), info[26::2])
            except IOError:
                pass

    return summary
Ejemplo n.º 4
0
def RunShapeFileImportTool():
    """
    <Script>
    <Author>admin</Author>
    <Description>Please enter script description here</Description>
    </Script>
    """
    # Get all the files in the directory
    directory = r"C:\temp\Del_Shape"  #directory with shape files
    FileList = Directory.GetFiles(directory)
    DB_folder = '/xx'  #folder to import shape files to

    for file in FileList:
        fullPath = Path.Combine(directory, file)
        if Path.GetExtension(fullPath) == '.shp':
            featureClassName = '/' + Path.GetFileNameWithoutExtension(
                fullPath)  #filenameWithoutExtension

            inputItems = gisMgr.FeatureClassGroupList.Get(DB_folder)
            if inputItems == None:
                inputItems = gisMgr.FeatureClassGroupList.CreateNew(DB_folder)

            coordinateSystem = gisMgr.DefaultCoordinateSystem
            ShapeFileImportTool(inputItems, coordinateSystem, featureClassName,
                                fullPath)
Ejemplo n.º 5
0
def all_files(root):
    for x in Directory.GetFiles(root):
        yield Path.Combine(root, x)
        
    dirs = Directory.GetDirectories(root)
    for d in dirs:
        for x in all_files(d):
            yield x
Ejemplo n.º 6
0
 def __getFolderItems(self, picturesOnly, count):
     if picturesOnly:
         list = []
     else:
         def IsSpecialFolder(dir):
             d = Path.GetFileName(dir).lower()
             return d.startswith('_vti_') or  d.startswith('app_') or d.startswith('bin') or d.startswith('aspnet_')
         list = [GetFolder(d) for d in Directory.GetDirectories(self.path)[:count] if not IsSpecialFolder(d)]
         count -= len(list)
     if count > 0:
         list += [GetPicture(p) for p in Directory.GetFiles(self.path, '*.jpg')[:count]]
     return list
def removeczi(removedir):

    # check directory for files to export
    czi2remove = Directory.GetFiles(removedir, '*.czi')
    print 'Number of files to be removed: ', len(czi2remove)

    for czi in czi2remove:
        # delete the splitted CZI files when option was checked
        try:
            File.Delete(czi)
            print 'Removed: ', czi
        except:
            print 'Could not remove: ', czi

    print 'Removal complete.'
Ejemplo n.º 8
0
def run_interactive_main():
    #if the commandline was invoked so: ipy run_interactive.py test_x.py then run just that one test.
    testName = sys.argv[1] if len(sys.argv) > 1 else None
    
    if testName:
        testsToRun = Directory.GetFiles(Directory.GetCurrentDirectory() , testName)        
    else:
	    print "No test name provided"
	    sys.exit(-1)
	    
    allErrors = []
    for test in testsToRun:
        try:
            print "\nRunning test in interactive mode - ", test
            con = FileConsole(test)        
            con.Run()
        except Exception, e:
            print e, e.clsException
            allErrors.append((test, sys.exc_info()[0], sys.exc_info()[1]))
Ejemplo n.º 9
0
def getFilesYoungerThan(dir, younger_than=0):
    if exists(dir):
        files = Directory.GetFiles(dir)
        date_to_check = DateTime.Parse(
            DateTime.Now.AddDays(-younger_than).ToString("yyyy.MM.dd"))
        files_of_age = []
        for file in files:
            file = FileInfo(file)
            print file
            result = DateTime.Compare(file.CreationTime, date_to_check)

            if result < 0:
                relationship = "is earlier than %s" % date_to_check
            elif result == 0:
                relationship = "is the same time as %s" % date_to_check
                files_of_age.append(file)
            else:
                relationship = "is later than %s" % date_to_check
                files_of_age.append(file)
            print relationship
        return files_of_age
Ejemplo n.º 10
0
def cleanUp():
    '''
    Just removes the DLLs directory we created.
    '''
    #the following while loop is necessary as
    #the Delete call fails (ipy.exe subprocess has
    #not really released some files yet).
    for i in xrange(5):
        threw = False
        for file in Directory.GetFiles(DLLS_DIR):
            if not file.endswith('IronPython.Wpf.dll'):
                try:
                    File.Delete(file)
                except:
                    print 'cannot delete', file
                    threw = True
                    pass
        if threw:
            from time import sleep
            sleep(1)
            continue
        else:
            break
Ejemplo n.º 11
0
#####################################################################################
#
#  Copyright (c) Microsoft Corporation. All rights reserved.
#
#  This source code is subject to terms and conditions of the Shared Source License
#  for IronPython. A copy of the license can be found in the License.html file
#  at the root of this distribution. If you can not locate the Shared Source License
#  for IronPython, please send an email to [email protected].
#  By using this source code in any fashion, you are agreeing to be bound by
#  the terms of the Shared Source License for IronPython.
#
#  You must not remove this notice, or any other, from this software.
#
######################################################################################

import sys
import clr
from System.IO import Path, Directory, FileInfo

dir = Path.Combine(sys.prefix, 'DLLs')
if Directory.Exists(dir):
    sys.path.append(dir)
    files = Directory.GetFiles(dir)
    for file in files:
        if file.lower().endswith('.dll'):
            try:
                clr.AddReference(FileInfo(file).Name)
            except:
                pass
Ejemplo n.º 12
0
###########################################################################

# clear console output
Zen.Application.MacroEditor.ClearMessages()

# check the location of experiment setups and image analysis settings are stored
docfolder = Zen.Application.Environment.GetFolderPath(
    ZenSpecialFolder.UserDocuments)
imgfolder = Zen.Application.Environment.GetFolderPath(
    ZenSpecialFolder.ImageAutoSave)
imgfolder = Path.Combine(imgfolder, 'Guided_Acquisition')
# imgfolder = r'c:\Output\Guided_Acquisition'
format = '%Y-%m-%d_%H-%M-%S'

# get list with all existing experiments and image analysis setup and a short version of that list
expfiles = Directory.GetFiles(Path.Combine(docfolder, 'Experiment Setups'),
                              '*.czexp')
ipfiles = Directory.GetFiles(
    Path.Combine(docfolder, 'Image Analysis Settings'), '*.czias')
expfiles_short = getshortfiles(expfiles)
ipfiles_short = getshortfiles(ipfiles)

# Initialize Dialog
GuidedAcqDialog = ZenWindow()
GuidedAcqDialog.Initialize('Guided Acquisition - Version : ' + str(version))
# add components to dialog
GuidedAcqDialog.AddLabel(
    '1) Select Overview Experiment  ------------------------------')
GuidedAcqDialog.AddDropDown('overview_exp', 'Overview Scan Experiment',
                            expfiles_short, 0)
GuidedAcqDialog.AddCheckbox('fs_before_overview',
                            'OPTION - FindSurface (DF only) before Overview',
# .Net module
from System.IO import Directory, File, FileAttributes, Path, SearchOption

# argument assigned the IN port
folders = IN[0]
search = IN[1]
deep = IN[2]

# instantiate error log
error_log = None

files = []
try:
    # determine if deepsearch from current directory is needed
    if deep:
        docs = Directory.GetFiles(folders, search, SearchOption.AllDirectories)
    else:
        docs = Directory.GetFiles(folders, search)

    # get only docs that are not read-only and hidden (and thereby system etc.)
    ro = FileAttributes.ReadOnly
    hi = FileAttributes.Hidden

    for doc in docs:
        if File.GetAttributes(doc).HasFlag(ro) == 0:
            if File.GetAttributes(doc).HasFlag(hi) == 0:
                files.append(Path.GetFullPath(doc))
        else:
            error_log = 'File(s) are read only, correct input!'
except BaseException:
    error_log = 'Directory does not exist, correct input!'
print '------ Module Parameters ------'
for p in params.Parameters:
    print p.Key, ' : ', p.Value

print '------ Outputs ------'
for op in params.Outputs.GetEnumerator():
    print op.Key, ' : ', op.Value

# define the list of input images and the allowed file extensions
sourcefolder = r'c:\Users\test\images\list_of_images'
itype = '*.ome.tiff'

# create list of images to be processed
imglist = []

for file in Directory.GetFiles(sourcefolder, itype):
    imglist.append(file)

# create the required dict with the correct key and value
# the required value here: list of the input images
input_images = {'list_input_images': imglist}

# define the savepath
savepath = Path.Combine(sourcefolder, 'saved_results')

# create the output directory if not existing
if not Directory.Exists(savepath):
    Directory.CreateDirectory(savepath)

# define the processing parameters (or use the defaults: params.Parameters
my_parameters = {'filtertype': 'Median', 'filter_kernel_size': 7}
Ejemplo n.º 15
0
## Check, if path exists
if (Directory.Exists(strFolder)== False):
    strMessage = 'Path: ' + strFolder + ' does not exist!\nRestart macro and select an existing path!'
    sys.exit(strMessage)
## Check, if newPath exists
if (Directory.Exists(newstrFolder)== False):
    strMessage = 'Path: ' + newstrFolder + ' does not exist!\nRestart macro and select an existing path!'
    sys.exit(strMessage)

imgSeries = ZenImage()

t = 0
c = 0
z = 0

files = Directory.GetFiles(strFolder, "*czi")

for z in range(0, files.Length):
    #--- Get the next image file ---
    file = files[z]
    fileInfo = FileInfo(file)
    strFilenameFullPath = strFolder + "\\" + fileInfo.Name
    img = Zen.Application.LoadImage(strFilenameFullPath, False)
    # separate channels
    for c in range(0, img.Bounds.SizeC):
        channelImage = img.CreateSubImage('C(' + str(c+1) + ')')
        #--- Add image to series ---
        imgSeries.AddSubImage(channelImage, t, c, z)
    #--- Clean up ---
    img.Close()
Ejemplo n.º 16
0
from System.IO import Directory, SearchOption
dir = IN[0]
searchstring = IN[1]
if Directory.Exists(dir):
    OUT = Directory.GetFiles(dir, searchstring, SearchOption.AllDirectories)
else:
    OUT = list()
Ejemplo n.º 17
0
def RunICM(Adapter):
    """
    <Script>
    <Author>ANK</Author>
    <Description>run an ICM model</Description>
    <Parameters>
    <Parameter name="Adapter" type="IRuntimeAdapter">handle to the adapter</Parameter>
    </Parameters>
    </Script>
    """
    tsMgr = app.Modules.Get("Time series Manager")

    # get the adapter root folder
    rootfolder = Adapter.RootFolderPath
    
    # convert dfs0-input files to Dummy_Inflow.csv
    
    # open dummy inflow and read all lines
    inflowPath = Path.Combine(rootfolder, "MODEL_SETUP\\import\\Dummy Inflow.csv")
    inflowLines = File.ReadAllLines(inflowPath)
    
    # read dfs0-files one by one
    l=8
    tslist = []
    while inflowLines[l].split(",")[0]!="P_DATETIME" :
        tsname = inflowLines[l].split(",")[0]
        tsFile = Path.Combine(rootfolder, "INPUT_DATA", tsname+".dfs0")
        tslist.extend(TsUtilities.ReadFromDFS0(tsMgr, tsFile))
        l = l + 1;

    # make new lines
    newLines = []
    i=0
    while True:
        if i==6:
            # replace startdate
            line = tslist[0].Start.ToString("dd/MM/yyyy HH:mm:ss") + inflowLines[i][19:]
        else:
            line = inflowLines[i]

        newLines.append(line)
        
        if inflowLines[i].split(",")[0]=="P_DATETIME" :
            break;
        i = i + 1;
    
    # continue with timesteps
    for t in range(tslist[0].Count):
        line = tslist[0].Get(t).XValue.ToString("dd/MM/yyyy HH:mm:ss")
        for ds in tslist:
            line += "," + ds.Get(t).YValue.ToString(CultureInfo.InvariantCulture)
        
        newLines.append(line)

    # rewrite the input file
    File.WriteAllLines(inflowPath, newLines)
        
    # run the adapter bat-file
    startInfo = ProcessStartInfo()
    startInfo.CreateNoWindow = False;
    startInfo.UseShellExecute = False;
    startInfo.FileName = Path.Combine(rootfolder, "MODEL_SETUP", "run.bat");
    startInfo.WorkingDirectory = Path.Combine(rootfolder, "MODEL_SETUP")
    with Process.Start(startInfo) as exeProcess :
        exeProcess.WaitForExit();

    # convert exported csv-files to dfs0
    # convert node depths
    dslist = []
    for fil in Directory.GetFiles(Path.Combine(rootfolder,"MODEL_SETUP\\export"),"Node_*_depnod.csv"):
        lines = File.ReadAllLines(fil)
        
        headers = lines[0].split(",")
        for h in headers[2:]:
            ds = tsMgr.TimeSeriesList.CreateNew()
            ds.Name = h.strip()
            ds.YAxisVariable = "Water Level"
            
            dslist.append(ds)
            
    
        for line in lines[1:] :
            if not "[" in line:
                values = line.split(",")
                t = DateTime.ParseExact(values[0].strip(),"dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture)
                for v in range(2,values.Count):
                    ds = dslist[v-2]
                    vp = ds.CreateNew()
                    vp.XValue = t
                    vp.YValue = Double.Parse(values[v].strip(), CultureInfo.InvariantCulture)
                    ds.Add(vp)    
        
        # save to dfs0
        for ds in dslist:
            fil = Path.Combine(rootfolder,"OUTPUT_DATA",ds.Name+".dfs0")
            TsUtilities.ExportToDfs0(ds,fil)
Ejemplo n.º 18
0
def import_animation(target):
    brres = BrawlAPI.RootNode

    # verify model exists
    model_wrapper = None
    model = None

    for mdl in BrawlAPI.NodeWrapperListOfType[MDL0Wrapper]():
        if mdl.Resource.Name == "course":
            model_wrapper = mdl
            model = mdl.Resource

    # verify material exists
    material = None

    for mat in model.FindChildrenByType("/", ResourceType.MDL0Material):
        if mat.Name == target:
            material = mat

    if material == None or model_wrapper == None or model == None:
        return

    ################
    ### Clean Up ###
    ################

    for reference in material.GetChildrenRecursive():
        # delete old textures
        for texture in BrawlAPI.NodeListOfType[TEX0Node]():
            if texture.Name == reference.Name:
                texture.Remove(True)

        # delete old mdl0 texture references
        for mdl0_tex in BrawlAPI.NodeListOfType[MDL0TextureNode]():
            if mdl0_tex.Name == reference.Name:
                mdl0_tex.Remove()

    # delete old animation
    for srt in BrawlAPI.NodeListOfType[SRT0Node]():
        for srt_subnode in srt.Children:
            if srt_subnode.Name == material.Name:
                srt.Remove()

    #################
    ### Importing ###
    #################

    for filename in Directory.GetFiles(preset_path):
        # import textures
        if filename.endswith(".tex0"):
            node = NodeFactory.FromFile(None, filename)
            brres.GetOrCreateFolder[TEX0Node]().AddChild(node)

        # import material
        if filename.endswith(".mdl0mat"):
            material.Replace(filename)
            material.Name = Path.GetFileNameWithoutExtension(filename)

        # import shader and set material shader
        if filename.endswith(".mdl0shade"):

            # replace shader if only in use by target
            if len(material.ShaderNode.Materials) == 1:
                material.ShaderNode.Replace(filename)

            # otherwise make a new shader
            else:
                shader = model_wrapper.NewShader()
                shader.Replace(filename)

                material.ShaderNode = shader

        # import animation and rename material
        if filename.endswith(".srt0"):
            node = NodeFactory.FromFile(None, filename)
            brres.GetOrCreateFolder[SRT0Node]().AddChild(node)
Ejemplo n.º 19
0
newPath = str(result.GetValue('destfolder'))

# Check, if path exists
if not Directory.Exists(path):
    strMessage = 'Path: ' + path + ' does not exist!\nRestart macro and select an existing path!'
    sys.exit(strMessage)

# Check, if newPath exists
if not Directory.Exists(newPath):
    strMessage = 'Path: ' + newPath + ' does not exist!\nRestart macro and select an existing path!'
    sys.exit(strMessage)

# get file type
itype = str(result.GetValue('isval'))
otype = str(result.GetValue('osval'))
files = Directory.GetFiles(path, itype)

# Check, if image type exists
if files.Length == 0:
    strMessage = 'Images of type : ' + itype + ' do not exist!\nRestart macro and select an existing image type!'
    sys.exit(strMessage)

# start loop over all images
saved = True

for slide in range(0, files.Length):

    try:
        file = files[slide]
        fileInfo = FileInfo(file)
        PathAndFile = Path.Combine(path, fileInfo.Name)
Ejemplo n.º 20
0
opendocs = Zen.Application.Documents
for doc in opendocs:
    image = Zen.Application.Documents.GetByName(doc.Name)

    if image.FileName.EndsWith('.czi'):
        # get the filename of the current document only when it ends with '.czi'
        CZIfiles_short.append(Path.GetFileName(image.FileName))
        CZIdict[Path.GetFileName(image.FileName)] = image.FileName

# check the location of experiment setups and image analysis settings are stored
docfolder = Zen.Application.Environment.GetFolderPath(
    ZenSpecialFolder.UserDocuments)
format = '%Y-%m-%d_%H-%M-%S'

# get list with all existing image analysis setups and a short version of that list
ipfiles = Directory.GetFiles(
    Path.Combine(docfolder, 'Image Analysis Settings'), '*.czias')
ipfiles_short = getshortfiles(ipfiles)

# get list with all existing models and a short version of that list
objmodelfolder = Path.Combine(docfolder, 'ObjectClassificationModels')
objmodelfiles = Directory.GetFiles(objmodelfolder, '*.xml')

if is_empty(objmodelfiles):
    # catch exception in case the folder contains no models at all
    message = 'No modelfiles found in specified folder: '
    print(message, objmodelfolder)
    raise SystemExit

# get the list of filename use only the basefilename
objmodelfiles_short = getshortfiles(objmodelfiles)
Ejemplo n.º 21
0
def replace_node(node, folder_path):
    new_node_path = Directory.GetFiles(folder_path, node.Name + ".*")
    if new_node_path:
        node.Replace(new_node_path[0])
    else:
        not_found.append(node.Name)
Ejemplo n.º 22
0
from System.IO import Path, File, Directory, FileInfo
from System.Diagnostics import Process
import sys
import os

# clear output
Zen.Application.MacroEditor.ClearMessages()

# Adapt this to your Fiji macro folder
default_macro_folder = r'C:\Users\Public\Documents\Fiji\macros\Zen_Test'
print 'Current Macro Folder : ', default_macro_folder

# Fiji macro for opening the CZI windowless --&gt; default macro for opening a CZI without the BioFormats input window
bf_windowless = r'c:\Users\Public\Documents\Fiji\macros\Zen_Test\Open_CZI_BioFormats_Windowless.ijm'

macros = Directory.GetFiles(default_macro_folder)
macrofiles_short = []
Macrodict = {}
# get all macros from folder
for macro in macros:
    macrofiles_short.append(Path.GetFileName(macro))
    Macrodict[Path.GetFileName(macro)] = macro

CZIfiles_short = []
CZIdict = {}

# get all open documents
opendocs = Zen.Application.Documents
for doc in opendocs:
    #print doc.Name
    image = Zen.Application.Documents.GetByName(doc.Name)
Ejemplo n.º 23
0
# check the location of folder where experiment setups and image analysis settings are stored
docfolder = Zen.Application.Environment.GetFolderPath(
    ZenSpecialFolder.UserDocuments)
imgfolder = Zen.Application.Environment.GetFolderPath(
    ZenSpecialFolder.ImageAutoSave)
# or you your own default folder
imgfolder = r'c:\Output\Intellesis_Batch_Test'

# maximum number of classes
maxclass = 16
classlist = createidstr(maxclass)

# get list with all existing models and a short version of that list
modelfolder = Path.Combine(docfolder, 'Model-Repository')
modelfiles = Directory.GetFiles(modelfolder, '*.xml')

if is_empty(modelfiles):
    # catch exception in case the folder contains no models at all
    message = 'No modelfiles found in specified folder: '
    print(message, Path.Combine(docfolder, 'Model-Repository'))
    raise SystemExit

# get the list of filename use only the basefilename
modelfiles_short = getshortfiles(modelfiles)
modeldict = {}

# create list for the short modelnames to be used iside UI of dialog
modelnames_short = []

for modelfile in modelfiles:
Ejemplo n.º 24
0
##############################################################################

# clear console output
Zen.Application.MacroEditor.ClearMessages()

# check the location of folder where experiment setups and image analysis settings are stored
docfolder = Zen.Application.Environment.GetFolderPath(
    ZenSpecialFolder.UserDocuments)
imgfolder = Zen.Application.Environment.GetFolderPath(
    ZenSpecialFolder.ImageAutoSave)
# or you your own default folder
imgfolder = r'c:\Output\Intellesis_Batch_Test'

# get list with all existing models and a short version of that list
modelfolder = Path.Combine(docfolder, 'Model-Repository')
modelfiles = Directory.GetFiles(modelfolder, '*.xml')

if is_empty(modelfiles):
    # catch exception in case the folder contains no models at all
    message = 'No modelfiles found in specified folder: '
    print(message, Path.Combine(docfolder, 'Model-Repository'))
    raise SystemExit

# get the list of filename use only the basefilename
modelfiles_short = getshortfiles(modelfiles)
modeldict = {}

# create list for the short modelnames to be used iside UI of dialog
modelnames_short = []

for modelfile in modelfiles:
# read results from dialog
exedir = result.GetValue('bftoolsdir')
sourcedir = result.GetValue('sourcedir')
split = result.GetValue('splitczi')
bfsplit = result.GetValue('bfsplitczi')
splitopt = result.GetValue('splitoption')
chadd = result.GetValue('addch')
omeexport = result.GetValue('omeexp')
chadd = result.GetValue('addch')
createomexml = result.GetValue('omexml')
waitforkey = result.GetValue('waitkey')
czidelete = result.GetValue('cziremove')

# check directory for files to export
czidir = Directory.GetFiles(sourcedir, '*.czi')
numczi = czidir.Length

# this list contains the subdirectories created for splitting
splitdirs = []

if split == True:

    print 'Split CZI using Split Scenes (Write Files): yes'
    # Batch Loop - Load all CZI images and do Split Scenes (Write Files)
    for i in range(0, numczi):
        # get current CZI file
        czifile = czidir[i]
        file_woExt = Path.GetFileNameWithoutExtension(czifile)
        # create separate directory for the current file
        splitdir = Path.Combine(sourcedir, file_woExt + '_Single')
Ejemplo n.º 26
0
# create dialog
defaultmodeldir = r'c:\Users\m1srh\OneDrive - Carl Zeiss AG\Testdata_Zeiss\Atomic\Trained_Models'
wd = ZenWindow()
wd.Initialize('Convert CZMODEL to old format - Version: ' + str(scriptversion))
wd.AddFolderBrowser('mf', 'Select folder with CZMODEL files.', defaultmodeldir)
result = wd.Show()

# check, if Cancel button was clicked
if result.HasCanceled:
    sys.exit('Macro aborted with Cancel!')

# get the folder
basedir = result.GetValue('mf')

# get all *.czmodel files inside the folder
czmodelfiles_long = Directory.GetFiles(basedir, '*.czmodel')
czmodelfiles_short = []
for cz in czmodelfiles_long:
    czmodelfiles_short.append(Path.GetFileName(cz))

# create dialog
wd = ZenWindow()
wd.Initialize('Convert CZMODEL to old format - Version: ' + str(scriptversion))
wd.AddDropDown('czmf', 'Select individual CZMODEL to be converted', czmodelfiles_short, 0)
result = wd.Show()

# check, if Cancel button was clicked
if result.HasCanceled:
    sys.exit('Macro aborted with Cancel!')

# get the full path of the selected czmodel file